[PATCH 25/45] writeback: convert wbc.nr_to_write to per-file parameter

From: Wu Fengguang
Date: Wed Oct 07 2009 - 04:08:51 EST


CC: Theodore Ts'o <tytso@xxxxxxx>
CC: Chris Mason <chris.mason@xxxxxxxxxx>
CC: Dave Chinner <david@xxxxxxxxxxxxx>
CC: Christoph Hellwig <hch@xxxxxxxxxxxxx>
CC: Jan Kara <jack@xxxxxxx>
CC: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
CC: Jens Axboe <jens.axboe@xxxxxxxxxx>
Signed-off-by: Wu Fengguang <fengguang.wu@xxxxxxxxx>
---
fs/fs-writeback.c | 24 ++++++++++++------------
include/linux/writeback.h | 5 +++--
mm/backing-dev.c | 1 -
3 files changed, 15 insertions(+), 15 deletions(-)

--- linux.orig/fs/fs-writeback.c 2009-10-06 23:38:45.000000000 +0800
+++ linux/fs/fs-writeback.c 2009-10-06 23:38:56.000000000 +0800
@@ -661,12 +661,13 @@ pinned:
return 0;
}

-static void writeback_inodes_wb(struct bdi_writeback *wb,
+static long writeback_inodes_wb(struct bdi_writeback *wb,
struct writeback_control *wbc)
{
struct super_block *sb = wbc->sb, *pin_sb = NULL;
const unsigned long start = jiffies; /* livelock avoidance */
unsigned long stop_time = 0;
+ unsigned long wrote = 0;

if (wbc->timeout)
stop_time = (start + wbc->timeout) | 1;
@@ -709,7 +710,10 @@ static void writeback_inodes_wb(struct b
BUG_ON(inode->i_state & (I_FREEING | I_CLEAR));
__iget(inode);
pages_skipped = wbc->pages_skipped;
+ wbc->nr_to_write = bdi_writeback_chunk(wb->bdi);
+ wrote += wbc->nr_to_write;
writeback_single_inode(inode, wbc);
+ wrote -= wbc->nr_to_write;
if (wbc->pages_skipped != pages_skipped) {
/*
* writeback is not making progress due to locked
@@ -735,6 +739,7 @@ static void writeback_inodes_wb(struct b

spin_unlock(&inode_lock);
/* Leave any unwritten inodes on b_io */
+ return wrote;
}

void writeback_inodes_wbc(struct writeback_control *wbc)
@@ -782,6 +787,7 @@ static long wb_writeback(struct bdi_writ
};
unsigned long oldest_jif;
long wrote = 0;
+ long nr;
struct inode *inode;

if (wbc.for_kupdate) {
@@ -810,26 +816,20 @@ static long wb_writeback(struct bdi_writ

wbc.more_io = 0;
wbc.encountered_congestion = 0;
- wbc.nr_to_write = MAX_WRITEBACK_PAGES;
wbc.pages_skipped = 0;
- writeback_inodes_wb(wb, &wbc);
- args->nr_pages -= MAX_WRITEBACK_PAGES - wbc.nr_to_write;
- wrote += MAX_WRITEBACK_PAGES - wbc.nr_to_write;
+ nr = writeback_inodes_wb(wb, &wbc);
+ args->nr_pages -= nr;
+ wrote += nr;

/*
- * If we consumed everything, see if we have more
- */
- if (wbc.nr_to_write <= 0)
- continue;
- /*
- * Didn't write everything and we don't have more IO, bail
+ * Bail if no more IO
*/
if (!wbc.more_io)
break;
/*
* Did we write something? Try for more
*/
- if (wbc.nr_to_write < MAX_WRITEBACK_PAGES)
+ if (nr)
continue;
/*
* Nothing written. Wait for some inode to
--- linux.orig/include/linux/writeback.h 2009-10-06 23:38:45.000000000 +0800
+++ linux/include/linux/writeback.h 2009-10-06 23:38:52.000000000 +0800
@@ -45,8 +45,9 @@ struct writeback_control {
int timeout;
unsigned long *older_than_this; /* If !NULL, only write back inodes
older than this */
- long nr_to_write; /* Write this many pages, and decrement
- this for each page written */
+ long nr_to_write; /* Max pages to write per file, and
+ decrement this for each page written
+ */
long pages_skipped; /* Pages which were not written */

/*
--- linux.orig/mm/backing-dev.c 2009-10-06 23:38:45.000000000 +0800
+++ linux/mm/backing-dev.c 2009-10-06 23:38:52.000000000 +0800
@@ -338,7 +338,6 @@ static void bdi_flush_io(struct backing_
.sync_mode = WB_SYNC_NONE,
.older_than_this = NULL,
.range_cyclic = 1,
- .nr_to_write = 1024,
.timeout = HZ,
};



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/