From: Li Zefan <lizf@cn.fujitsu.com>
To: Ian Kent <raven@themaw.net>
Cc: Josef Bacik <josef@redhat.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: setup blank root and fs_info for mount time
Date: Mon, 22 Nov 2010 17:21:40 +0800 [thread overview]
Message-ID: <4CEA3624.8050002@cn.fujitsu.com> (raw)
In-Reply-To: <1290392498.2602.21.camel@perseus.themaw.net>
> Have a look in fs/super.c:generic_shutdown_super(), called by
> fs/super.c:kill_anon_super(), where the super method ->put_super() is
> called, setting the super s_fs_info to NULL, before taking the sb_lock
> and removing it from the list of supers.
>
> Here's my patch.
>
> btrfs - fix race between btrfs_get_sb() and umount
>
> From: Ian Kent <raven@themaw.net>
>
> When mounting a btrfs file system btrfs_test_super() may attempt to
> use sb->s_fs_info, the btrfs root, of a super block that is going away
> and that has had the btrfs root set to NULL in its ->put_super(). But
> if the super block is going away it cannot be an existing super block
> so we can return false in this case.
I think your analysis is right.
Actually I ran the test script (posted in an earlier email), and it
still crashed without your supplementary patch.
>
> Signed-off-by: Ian Kent <raven@themaw.net>
> ---
>
> fs/btrfs/super.c | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
>
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 6b57da3..960b320 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -565,6 +565,12 @@ static int btrfs_test_super(struct super_block *s, void *data)
> struct btrfs_fs_devices *test_fs_devices = data->fs_info->fs_devices;
> struct btrfs_root *root = btrfs_sb(s);
>
> + /*
> + * If this super block is going away, return false as it
> + * can't match as an existing super block.
> + */
> + if (!atomic_read(&s->s_active))
> + return 0;
> return root->fs_info->fs_devices == test_fs_devices;
> }
>
>
next prev parent reply other threads:[~2010-11-22 9:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-19 19:59 [PATCH] Btrfs: setup blank root and fs_info for mount time Josef Bacik
2010-11-22 1:25 ` Li Zefan
2010-11-22 1:49 ` Ian Kent
2010-11-22 1:51 ` Josef Bacik
2010-11-22 2:01 ` Li Zefan
2010-11-22 2:22 ` Ian Kent
2010-11-22 2:21 ` Ian Kent
2010-11-22 9:21 ` Li Zefan [this message]
2010-11-22 12:59 ` Ian Kent
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=4CEA3624.8050002@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=josef@redhat.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=raven@themaw.net \
/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).