linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Christoph Hellwig <hch@lst.de>
Cc: axboe@kernel.dk, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 3/6] writeback: enforce s_umount locking in writeback_inodes_sb
Date: Tue, 15 Jun 2010 19:54:13 +0200	[thread overview]
Message-ID: <20100615175413.GG3347@quack.suse.cz> (raw)
In-Reply-To: <20100608161451.GD11735@lst.de>

On Tue 08-06-10 18:14:51, Christoph Hellwig wrote:
> Make sure that not only sync_filesystem but all callers of writeback_inodes_sb
> have the superblock protected against remount.  As-is this disables all
> functionality for these callers, but the next patch relies on this locking to
> fix writeback_inodes_sb for sync_filesystem.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Index: linux-2.6/fs/fs-writeback.c
> ===================================================================
> --- linux-2.6.orig/fs/fs-writeback.c	2010-06-08 16:25:35.000000000 +0200
> +++ linux-2.6/fs/fs-writeback.c	2010-06-08 16:27:47.846255651 +0200
> @@ -1180,6 +1180,8 @@ void writeback_inodes_sb(struct super_bl
>  		.sync_mode	= WB_SYNC_NONE,
>  	};
>  
> +	WARN_ON(!rwsem_is_locked(&sb->s_umount));
> +
>  	args.nr_pages = nr_dirty + nr_unstable +
>  			(inodes_stat.nr_inodes - inodes_stat.nr_unused);
>  
> @@ -1197,7 +1199,9 @@ EXPORT_SYMBOL(writeback_inodes_sb);
>  int writeback_inodes_sb_if_idle(struct super_block *sb)
>  {
>  	if (!writeback_in_progress(sb->s_bdi)) {
> +		down_read(&sb->s_umount);
>  		writeback_inodes_sb(sb);
> +		up_read(&sb->s_umount);
  But this is buggy isn't it? writeback_inodes_sb() returns as soon as
flusher threads start submitting the IO. So we release s_umount too early -
flusher threads can be still writing out inodes for our work. It's exactly
cases like this why I don't like the work to be called "done" when flusher
threads actually still do it...

								Honza
>  		return 1;
>  	} else
>  		return 0;
> @@ -1220,6 +1224,8 @@ void sync_inodes_sb(struct super_block *
>  		.range_cyclic	= 0,
>  	};
>  
> +	WARN_ON(!rwsem_is_locked(&sb->s_umount));
> +
>  	bdi_queue_work_onstack(&args);
>  	wait_sb_inodes(sb);
>  }
> Index: linux-2.6/fs/ubifs/budget.c
> ===================================================================
> --- linux-2.6.orig/fs/ubifs/budget.c	2010-06-08 16:22:16.000000000 +0200
> +++ linux-2.6/fs/ubifs/budget.c	2010-06-08 16:26:50.464004778 +0200
> @@ -62,7 +62,9 @@
>   */
>  static void shrink_liability(struct ubifs_info *c, int nr_to_write)
>  {
> +	down_read(&c->vfs_sb->s_umount);
>  	writeback_inodes_sb(c->vfs_sb);
> +	up_read(&c->vfs_sb->s_umount);
>  }
>  
>  /**
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

  reply	other threads:[~2010-06-15 17:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-08 16:14 [PATCH 0/6] writeback fixes - slow unmount and others Christoph Hellwig
2010-06-08 16:14 ` [PATCH 1/6] writeback: fix writeback completion notifications Christoph Hellwig
2010-06-08 19:50   ` Jens Axboe
2010-06-15 17:25   ` Jan Kara
2010-06-15 17:30     ` Christoph Hellwig
2010-06-08 16:14 ` [PATCH 2/6] writeback: queue work on stack in writeback_inodes_sb Christoph Hellwig
2010-06-08 19:51   ` Jens Axboe
2010-06-08 16:14 ` [PATCH 3/6] writeback: enforce s_umount locking " Christoph Hellwig
2010-06-15 17:54   ` Jan Kara [this message]
2010-06-15 17:59     ` Christoph Hellwig
2010-06-15 18:04       ` Jan Kara
2010-06-08 16:14 ` [PATCH 4/6] writeback: fix writeback_inodes_wb from writeback_inodes_sb Christoph Hellwig
2010-06-08 19:51   ` Jens Axboe
2010-06-09 12:25     ` Christoph Hellwig
2010-06-09 12:29       ` Jens Axboe
2010-06-08 16:15 ` [PATCH 5/6] writeback: simplify wakeup_flusher_threads Christoph Hellwig
2010-06-08 19:51   ` Jens Axboe
2010-06-08 16:15 ` [PATCH 6/6] writeback: simplify and split bdi_start_writeback Christoph Hellwig
2010-06-08 19:52   ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100615175413.GG3347@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).