From: "Mika Penttilä" <mika.penttila@kolumbus.fi>
To: Chris Mason <mason@suse.com>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] writeback_inodes can race with unmount
Date: Tue, 08 Jun 2004 22:57:20 +0300 [thread overview]
Message-ID: <40C61A20.4000906@kolumbus.fi> (raw)
In-Reply-To: <1086722523.10973.157.camel@watt.suse.com>
Chris Mason wrote:
>There's a small window where the filesystem can be unmounted during
>writeback_inodes. The end result is the iput done by sync_sb_inodes
>could be done after the FS put_super and and the super has been removed
>from all lists.
>
>
Why don't we have the same race in the sync() path as well? Moving the
locking to sync_sb_inodes() itself would fix it also.
>The fix is to hold the s_umount sem during sync_sb_inodes to make sure
>the FS doesn't get unmounted.
>
>Index: linux.t/fs/fs-writeback.c
>===================================================================
>--- linux.t.orig/fs/fs-writeback.c 2004-06-08 14:45:49.000000000 -0400
>+++ linux.t/fs/fs-writeback.c 2004-06-08 14:47:58.000000000 -0400
>@@ -360,9 +360,18 @@ restart:
> sb = sb_entry(super_blocks.prev);
> for (; sb != sb_entry(&super_blocks); sb = sb_entry(sb->s_list.prev)) {
> if (!list_empty(&sb->s_dirty) || !list_empty(&sb->s_io)) {
>+ /* we're making our own get_super here */
> sb->s_count++;
> spin_unlock(&sb_lock);
>- sync_sb_inodes(sb, wbc);
>+ /* if we can't get the readlock, there's no sense in
>+ * waiting around, most of the time the FS is going
>+ * to be unmounted by the time it is released
>+ */
>+ if (down_read_trylock(&sb->s_umount)) {
>+ if (sb->s_root)
>+ sync_sb_inodes(sb, wbc);
>+ up_read(&sb->s_umount);
>+ }
> spin_lock(&sb_lock);
> if (__put_super(sb))
> goto restart;
>
>
--Mika
next prev parent reply other threads:[~2004-06-08 19:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-08 19:22 [PATCH] writeback_inodes can race with unmount Chris Mason
2004-06-08 19:57 ` Mika Penttilä [this message]
2004-06-08 20:18 ` Chris Mason
2004-06-08 21:56 ` Andrew Morton
2004-06-09 1:29 ` Chris Mason
2004-06-09 3:22 ` Andrew Morton
2004-06-09 5:24 ` Andrew Morton
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=40C61A20.4000906@kolumbus.fi \
--to=mika.penttila@kolumbus.fi \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@suse.com \
/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