Introduce writeback_control.inodes_written to count successful ->write_inode() calls. A non-zero value means there are some progress on writeback, in which case more writeback will be tried. This prevents aborting a background writeback work prematually when the current set of inodes for IO happen to be metadata-only dirty. Signed-off-by: Wu Fengguang --- fs/fs-writeback.c | 5 +++++ include/linux/writeback.h | 1 + 2 files changed, 6 insertions(+) --- linux-next.orig/fs/fs-writeback.c 2010-07-22 13:07:54.000000000 +0800 +++ linux-next/fs/fs-writeback.c 2010-07-22 13:07:58.000000000 +0800 @@ -379,6 +379,8 @@ writeback_single_inode(struct inode *ino int err = write_inode(inode, wbc); if (ret == 0) ret = err; + if (!err) + wbc->inodes_written++; } spin_lock(&inode_lock); @@ -628,6 +630,7 @@ static long wb_writeback(struct bdi_writ wbc.nr_to_write = MAX_WRITEBACK_PAGES; wbc.pages_skipped = 0; + wbc.inodes_written = 0; trace_wbc_writeback_start(&wbc, wb->bdi); if (work->sb) @@ -650,6 +653,8 @@ static long wb_writeback(struct bdi_writ */ if (wbc.nr_to_write < MAX_WRITEBACK_PAGES) continue; + if (wbc.inodes_written) + continue; /* * Nothing written and no more inodes for IO, bail --- linux-next.orig/include/linux/writeback.h 2010-07-22 11:24:46.000000000 +0800 +++ linux-next/include/linux/writeback.h 2010-07-22 13:07:58.000000000 +0800 @@ -34,6 +34,7 @@ struct writeback_control { long nr_to_write; /* Write this many pages, and decrement this for each page written */ long pages_skipped; /* Pages which were not written */ + long inodes_written; /* Number of inodes(metadata) synced */ /* * For a_ops->writepages(): is start or end are non-zero then this is -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/