Skip to content

Commit

Permalink
writeback: fix break condition
Browse files Browse the repository at this point in the history
Commit dcf6a79 ("write-back: fix
nr_to_write counter") fixed nr_to_write counter, but didn't set the break
condition properly.

If nr_to_write == 0 after being decremented it will loop one more time
before setting done = 1 and breaking the loop.

[akpm@linux-foundation.org: coding-style fixes]
Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Acked-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Federico Cuello authored and Linus Torvalds committed Feb 11, 2009
1 parent 6c59796 commit 89e1219
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions mm/page-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,20 +1051,23 @@ int write_cache_pages(struct address_space *mapping,
}
}

if (nr_to_write > 0)
if (nr_to_write > 0) {
nr_to_write--;
else if (wbc->sync_mode == WB_SYNC_NONE) {
/*
* We stop writing back only if we are not
* doing integrity sync. In case of integrity
* sync we have to keep going because someone
* may be concurrently dirtying pages, and we
* might have synced a lot of newly appeared
* dirty pages, but have not synced all of the
* old dirty pages.
*/
done = 1;
break;
if (nr_to_write == 0 &&
wbc->sync_mode == WB_SYNC_NONE) {
/*
* We stop writing back only if we are
* not doing integrity sync. In case of
* integrity sync we have to keep going
* because someone may be concurrently
* dirtying pages, and we might have
* synced a lot of newly appeared dirty
* pages, but have not synced all of the
* old dirty pages.
*/
done = 1;
break;
}
}

if (wbc->nonblocking && bdi_write_congested(bdi)) {
Expand Down

0 comments on commit 89e1219

Please sign in to comment.