All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs@vger.kernel.org, dsterba@suse.com
Subject: Re: [PATCH v6 3/3] btrfs: consolidate device_list_mutex in prepare_sprout to its parent
Date: Thu, 23 Sep 2021 19:55:19 +0800	[thread overview]
Message-ID: <9ea1c8a0-2516-164c-23d7-c57e146c067c@oracle.com> (raw)
In-Reply-To: <45f5dfee-3cb5-8645-a0b4-3f0dcb14dce5@suse.com>



On 23/09/2021 14:52, Nikolay Borisov wrote:
> 
> 
> On 22.09.21 г. 14:41, Anand Jain wrote:
> 
> <snip>
> 
>>>> @@ -2419,7 +2414,23 @@ static int btrfs_prepare_sprout(struct
>>>> btrfs_fs_info *fs_info)
>>>>        INIT_LIST_HEAD(&seed_devices->devices);
>>>>        INIT_LIST_HEAD(&seed_devices->alloc_list);
>>>>    -    mutex_lock(&fs_devices->device_list_mutex);
>>>> +    *seed_devices_ret = seed_devices;
>>>> +
>>>> +    return 0;
>>>> +}
>>>> +
>>>> +/*
>>>> + * Splice seed devices into the sprout fs_devices.
>>>> + * Generate a new fsid for the sprouted readwrite btrfs.
>>>> + */
>>>> +static void btrfs_splice_sprout(struct btrfs_fs_info *fs_info,
>>>> +                struct btrfs_fs_devices *seed_devices)
>>>> +{
>>>
>>> This function is missing a lockdep_assert_held annotation and it depends
>>> on the device_list_mutex being held.
>>
>>   You mean
>>      lockdep_assert_held(&device_list_mutex);
>>   and not
>>      lockdep_assert_held(&uuid_mutex);
>>   right?
> 
> I meant that the new function - btrfs_splice_sprout doesn't have any
> lockdep annotation, and based on the old code it depends on
> device_list_mutex being locked. This is based on the following hunk in
> btrfs_init_new_device:
> 
> +	mutex_lock(&fs_devices->device_list_mutex);
> +	if (seeding_dev) {
> +		btrfs_splice_sprout(fs_info, seed_devices);
> 
> The way I understand this is btrfs_splice_sprout indeed requires
> device_list_mutex being locked, no?

  Yes it requires both uuid_mutex and device_list_mutex. I will add.
  With comments.

Thx.


>>> However looking at the resulting code it doesn't look good, because
>>> btrfs_splice_sporut suggests you simply add the seed device to a bunch
>>> of places, yet looking at the function's body it's evident it actually
>>> finishes some parts of the initialization, changes the uuid of the
>>> fs_devices. I'm not convinced it really makes the code better or at the
>>> very least the 'splice_sprout' needs to be changed, because splicing is
>>> a minot part of what this function really does.
>>
>> The purpose of the split of btrfs_prepare_sprout() was to use a common
>> device_list_mutex. So I tend to avoid any other changes, but I think I
>> will do it now based on the comments.
>>
>> Thanks, Anand
>>>
>>>
>>> <snip>
>>>
>>

      reply	other threads:[~2021-09-23 11:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21  4:33 [PATCH v6 0/3] btrfs: cleanup prepare_sprout Anand Jain
2021-09-21  4:33 ` [PATCH v6 1/3] btrfs: declare seeding_dev in init_new_device as bool Anand Jain
2021-09-21 11:01   ` Nikolay Borisov
2021-10-13  8:00   ` Anand Jain
2021-10-28  4:39     ` Anand Jain
2021-11-08 20:06       ` David Sterba
2021-09-21  4:33 ` [PATCH v6 2/3] btrfs: remove unused device_list_mutex for seed fs_devices Anand Jain
2021-09-21  6:44   ` Nikolay Borisov
2021-09-22 11:29     ` Anand Jain
2021-09-21  4:33 ` [PATCH v6 3/3] btrfs: consolidate device_list_mutex in prepare_sprout to its parent Anand Jain
2021-09-21 11:01   ` Nikolay Borisov
2021-09-22 11:41     ` Anand Jain
2021-09-23  6:52       ` Nikolay Borisov
2021-09-23 11:55         ` Anand Jain [this message]

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=9ea1c8a0-2516-164c-23d7-c57e146c067c@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.