linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: 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: Mon, 8 Nov 2021 21:02:14 +0100	[thread overview]
Message-ID: <20211108200214.GO28560@twin.jikos.cz> (raw)
In-Reply-To: <1a168ce1-20b6-aabf-76ae-ea9914264f06@oracle.com>

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.

  reply	other threads:[~2021-11-08 20:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-30 12:16 [PATCH v7] btrfs: consolidate device_list_mutex in prepare_sprout to its parent Anand Jain
2021-09-30 13:42 ` Anand Jain
2021-10-13  8:01 ` [PATCH v8] " Anand Jain
2021-10-14 15:30   ` Josef Bacik
2021-10-14 22:34     ` Anand Jain
2021-11-08 20:02       ` David Sterba [this message]
2021-11-09  8:05         ` Anand Jain

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=20211108200214.GO28560@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --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 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).