From: Filipe David Manana <fdmanana@gmail.com>
To: Zach Brown <zab@redhat.com>
Cc: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] Btrfs: race free update of super flags
Date: Mon, 5 Aug 2013 23:27:24 +0100 [thread overview]
Message-ID: <CAL3q7H6yq=Y_iX4w40t5k0-UOmnghphTRc7T56jn-PAeK5HzWA@mail.gmail.com> (raw)
In-Reply-To: <20130805221059.GJ12314@lenny.home.zabbo.net>
On Mon, Aug 5, 2013 at 11:10 PM, Zach Brown <zab@redhat.com> wrote:
> On Sat, Aug 03, 2013 at 07:43:17PM +0100, Filipe David Borba Manana wrote:
>> Before updating the super block's flags, which is a non-atomic
>> operation, grab the super_lock in the fs_info structure. At
>> the moment only 2 different code paths can update these flags
>> in parallel:
>
> Hmm. You say "the" super block, but it's not clear to me that it's that
> simple.
>
>> --- a/fs/btrfs/disk-io.c
>> +++ b/fs/btrfs/disk-io.c
>> @@ -3357,8 +3357,10 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors)
>> memcpy(dev_item->uuid, dev->uuid, BTRFS_UUID_SIZE);
>> memcpy(dev_item->fsid, dev->fs_devices->fsid, BTRFS_UUID_SIZE);
>>
>> + spin_lock(&root->fs_info->super_lock);
>> flags = btrfs_super_flags(sb);
>> btrfs_set_super_flags(sb, flags | BTRFS_HEADER_FLAG_WRITTEN);
>> + spin_unlock(&root->fs_info->super_lock);
>
> sb = root->fs_info->super_for_commit;
>
>> --- a/fs/btrfs/volumes.c
>> +++ b/fs/btrfs/volumes.c
>> @@ -1862,9 +1862,11 @@ static int btrfs_prepare_sprout(struct btrfs_root *root)
>> generate_random_uuid(fs_devices->fsid);
>> memcpy(root->fs_info->fsid, fs_devices->fsid, BTRFS_FSID_SIZE);
>> memcpy(disk_super->fsid, fs_devices->fsid, BTRFS_FSID_SIZE);
>> + spin_lock(&root->fs_info->super_lock);
>> super_flags = btrfs_super_flags(disk_super) &
>> ~BTRFS_SUPER_FLAG_SEEDING;
>> btrfs_set_super_flags(disk_super, super_flags);
>> + spin_unlock(&root->fs_info->super_lock);
>
> struct btrfs_super_block *disk_super = root->fs_info->super_copy;
>
> Can you explain why the lock is needed given the different super blocks
> and the mutexes that each path holds?
I guess got confused, must have thought both referred to
root->fs_info->super_copy.
Thanks for the heads up and review.
So yes, just ignore this as it's useless.
>
> What lead you to write this patch?
>
> - z
next prev parent reply other threads:[~2013-08-05 22:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-03 18:43 [PATCH] Btrfs: race free update of super flags Filipe David Borba Manana
2013-08-05 22:10 ` Zach Brown
2013-08-05 22:27 ` Filipe David Manana [this message]
2013-08-05 22:47 ` Zach Brown
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='CAL3q7H6yq=Y_iX4w40t5k0-UOmnghphTRc7T56jn-PAeK5HzWA@mail.gmail.com' \
--to=fdmanana@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=zab@redhat.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;
as well as URLs for NNTP newsgroup(s).