lkml.org 
[lkml]   [2009]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 01/10] fs: Fix busyloop in wb_writeback()
On Thu, Sep 24, 2009 at 10:40:27PM +0800, Jens Axboe wrote:
> From: Jan Kara <jack@suse.cz>
>
> If all inodes are under writeback (e.g. in case when there's only one inode
> with dirty pages), wb_writeback() with WB_SYNC_NONE work basically degrades
> to busylooping until I_SYNC flags of the inode is cleared. Fix the problem by
> waiting on I_SYNC flags of an inode on b_more_io list in case we failed to
> write anything.
>
> CC: Wu Fengguang <fengguang.wu@intel.com>

Tested-by: Wu Fengguang <fengguang.wu@intel.com>

> Signed-off-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
> ---
> fs/fs-writeback.c | 19 ++++++++++++++++++-
> 1 files changed, 18 insertions(+), 1 deletions(-)
>
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 8e1e5e1..c59d673 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -706,6 +706,7 @@ static long wb_writeback(struct bdi_writeback *wb,
> };
> unsigned long oldest_jif;
> long wrote = 0;
> + struct inode *inode;
>
> if (wbc.for_kupdate) {
> wbc.older_than_this = &oldest_jif;
> @@ -747,8 +748,24 @@ static long wb_writeback(struct bdi_writeback *wb,
> * If we ran out of stuff to write, bail unless more_io got set
> */
> if (wbc.nr_to_write > 0 || wbc.pages_skipped > 0) {
> - if (wbc.more_io && !wbc.for_kupdate)
> + if (wbc.more_io && !wbc.for_kupdate) {
> + if (wbc.nr_to_write < MAX_WRITEBACK_PAGES)
> + continue;
> + /*
> + * Nothing written. Wait for some inode to
> + * become available for writeback. Otherwise
> + * we'll just busyloop.
> + */
> + spin_lock(&inode_lock);
> + if (!list_empty(&wb->b_more_io)) {
> + inode = list_entry(
> + wb->b_more_io.prev,
> + struct inode, i_list);
> + inode_wait_for_writeback(inode);
> + }
> + spin_unlock(&inode_lock);
> continue;
> + }
> break;
> }
> }
> --
> 1.6.4.1.207.g68ea


\
 
 \ /
  Last update: 2009-09-25 02:51    [W:0.096 / U:3.532 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site