[PATCH 6/6] writeback: redirty a fully scanned inode

Wu Fengguang
2009-09-23T12:43:44Z

[-- Attachment #1: writeback-delay-rewrites.patch --]
[-- Type: text/plain, Size: 1438 bytes --]

Redirty inode when its writeback_index wrapped around.
This is mainly to avoid unnecessary IOs for fast dirtier
that do lots of overwrites.

CC: Jan Kara <jack@suse.cz>
CC: Theodore Ts'o <tytso@mit.edu>
CC: Dave Chinner <david@fromorbit.com>
CC: Jens Axboe <jens.axboe@oracle.com>
CC: Chris Mason <chris.mason@oracle.com>
CC: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
fs/fs-writeback.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

--- linux.orig/fs/fs-writeback.c 2009-09-23 18:44:56.000000000 +0800
+++ linux/fs/fs-writeback.c 2009-09-23 18:52:22.000000000 +0800
@@ -397,6 +397,7 @@ writeback_single_inode(struct inode *ino
{
struct address_space *mapping = inode->i_mapping;
int wait = wbc->sync_mode == WB_SYNC_ALL;
+ pgoff_t start_index;
unsigned dirty;
int ret;

@@ -434,6 +435,7 @@ writeback_single_inode(struct inode *ino

spin_unlock(&inode_lock);

+ start_index = mapping->writeback_index;
ret = do_writepages(mapping, wbc);

/* Don't write the inode if only I_DIRTY_PAGES was set */
@@ -485,7 +487,9 @@ writeback_single_inode(struct inode *ino
* soon as the queue becomes uncongested.
*/
inode->i_state |= I_DIRTY_PAGES;
- if (wbc->nr_to_write <= 0) {
+select_queue:
+ if (wbc->nr_to_write <= 0 &&
+ start_index < mapping->writeback_index) {
/*
* slice used up: queue for next turn
*/