All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: dsterba@suse.cz, Josef Bacik <josef@toxicpanda.com>,
	linux-btrfs@vger.kernel.org, dsterba@suse.com
Subject: Re: [PATCH v8] btrfs: consolidate device_list_mutex in prepare_sprout to its parent
Date: Tue, 9 Nov 2021 16:05:18 +0800	[thread overview]
Message-ID: <62358dac-9302-b3ba-8ca3-9c1e42693a97@oracle.com> (raw)
In-Reply-To: <20211108200214.GO28560@twin.jikos.cz>

On 9/11/21 4:02 am, David Sterba wrote:
> On Fri, Oct 15, 2021 at 06:34:51AM +0800, Anand Jain wrote:
>> On 14/10/2021 23:30, Josef Bacik wrote:
>>> On Wed, Oct 13, 2021 at 04:01:37PM +0800, Anand Jain wrote:
>>>>    	seed_devices = alloc_fs_devices(NULL, NULL);
>>>>    	if (IS_ERR(seed_devices))
>>>> -		return PTR_ERR(seed_devices);
>>>> +		return seed_devices;
>>>>    
>>>>    	/*
>>>>    	 * It's necessary to retain a copy of the original seed fs_devices in
>>>> @@ -2411,9 +2404,10 @@ static int btrfs_prepare_sprout(struct btrfs_fs_info *fs_info)
>>>>    	old_devices = clone_fs_devices(fs_devices);
>>>>    	if (IS_ERR(old_devices)) {
>>>>    		kfree(seed_devices);
>>>> -		return PTR_ERR(old_devices);
>>>> +		return old_devices;
>>>>    	}
>>>>    
>>>> +	lockdep_assert_held(&uuid_mutex);
>>>
>>> There's no reason to move this down here, you can leave it at the top of this
>>> function.  Fix that up and you can add
>>
>>    I thought placing the lockdep_assert_held()s just before the critical
>>    section that wanted the lock makes it easy to reason. In this case, it
>>    is the next line that is
>>
>>         list_add(&old_devices->fs_list, &fs_uuids);
>>
>>    No? I can move it back if it is unnecessary.
> 
> I think the most common placement is near the top of the function so
> it's immediately visible that the lock is assumed to be held. If it's
> too deep in the function, it could be overlooked.

  Yeah agreed. V9 had it moved back to the top of the function as before
  and added a comment so that we don't have to wonder why uuid_mutex is 
essential.


      reply	other threads:[~2021-11-09  8:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13  8:01 [PATCH v8] btrfs: consolidate device_list_mutex in prepare_sprout to its parent Anand Jain
2021-10-13  8:01 ` Anand Jain
2021-09-30 13:42   ` [PATCH v7] " Anand Jain
2021-10-14 15:30 ` [PATCH v8] " Josef Bacik
2021-10-14 22:34   ` Anand Jain
2021-11-08 20:02     ` David Sterba
2021-11-09  8:05       ` 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=62358dac-9302-b3ba-8ca3-9c1e42693a97@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@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 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.