Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 230702
b: refs/heads/master
c: b9543da
h: refs/heads/master
v: v3
  • Loading branch information
Jan Kara authored and Linus Torvalds committed Jan 14, 2011
1 parent 56d0c2f commit 51c6d0c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aa373cf550994623efb5d49a4d8775bafd10bbc1
refs/heads/master: b9543dac5bbc4aef0a598965b6b34f6259ab9a9b
27 changes: 23 additions & 4 deletions trunk/fs/fs-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ static long wb_writeback(struct bdi_writeback *wb,
};
unsigned long oldest_jif;
long wrote = 0;
long write_chunk;
struct inode *inode;

if (wbc.for_kupdate) {
Expand All @@ -642,6 +643,24 @@ static long wb_writeback(struct bdi_writeback *wb,
wbc.range_end = LLONG_MAX;
}

/*
* WB_SYNC_ALL mode does livelock avoidance by syncing dirty
* inodes/pages in one big loop. Setting wbc.nr_to_write=LONG_MAX
* here avoids calling into writeback_inodes_wb() more than once.
*
* The intended call sequence for WB_SYNC_ALL writeback is:
*
* wb_writeback()
* __writeback_inodes_sb() <== called only once
* write_cache_pages() <== called once for each inode
* (quickly) tag currently dirty pages
* (maybe slowly) sync all tagged pages
*/
if (wbc.sync_mode == WB_SYNC_NONE)
write_chunk = MAX_WRITEBACK_PAGES;
else
write_chunk = LONG_MAX;

wbc.wb_start = jiffies; /* livelock avoidance */
for (;;) {
/*
Expand All @@ -668,7 +687,7 @@ static long wb_writeback(struct bdi_writeback *wb,
break;

wbc.more_io = 0;
wbc.nr_to_write = MAX_WRITEBACK_PAGES;
wbc.nr_to_write = write_chunk;
wbc.pages_skipped = 0;

trace_wbc_writeback_start(&wbc, wb->bdi);
Expand All @@ -678,8 +697,8 @@ static long wb_writeback(struct bdi_writeback *wb,
writeback_inodes_wb(wb, &wbc);
trace_wbc_writeback_written(&wbc, wb->bdi);

work->nr_pages -= MAX_WRITEBACK_PAGES - wbc.nr_to_write;
wrote += MAX_WRITEBACK_PAGES - wbc.nr_to_write;
work->nr_pages -= write_chunk - wbc.nr_to_write;
wrote += write_chunk - wbc.nr_to_write;

/*
* If we consumed everything, see if we have more
Expand All @@ -694,7 +713,7 @@ static long wb_writeback(struct bdi_writeback *wb,
/*
* Did we write something? Try for more
*/
if (wbc.nr_to_write < MAX_WRITEBACK_PAGES)
if (wbc.nr_to_write < write_chunk)
continue;
/*
* Nothing written. Wait for some inode to
Expand Down

0 comments on commit 51c6d0c

Please sign in to comment.