提交 89e12190 编写于 作者: F Federico Cuello 提交者: Linus Torvalds

writeback: fix break condition

Commit dcf6a79d ("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: NNick Piggin <npiggin@suse.de>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 6c597963
...@@ -1051,20 +1051,23 @@ int write_cache_pages(struct address_space *mapping, ...@@ -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--; nr_to_write--;
else if (wbc->sync_mode == WB_SYNC_NONE) { 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 * We stop writing back only if we are
* sync we have to keep going because someone * not doing integrity sync. In case of
* may be concurrently dirtying pages, and we * integrity sync we have to keep going
* might have synced a lot of newly appeared * because someone may be concurrently
* dirty pages, but have not synced all of the * dirtying pages, and we might have
* old dirty pages. * synced a lot of newly appeared dirty
*/ * pages, but have not synced all of the
done = 1; * old dirty pages.
break; */
done = 1;
break;
}
} }
if (wbc->nonblocking && bdi_write_congested(bdi)) { if (wbc->nonblocking && bdi_write_congested(bdi)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册