public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: NeilBrown <neilb@suse.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
	linux-fsdevel@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>, Daire Byrne <daire@dneg.com>,
	Andreas Dilger <adilger.kernel@dilger.ca>
Subject: Re: [PATCH/RFC] VFS: support parallel updates in the one directory.
Date: Thu, 24 Feb 2022 16:23:34 -0500	[thread overview]
Message-ID: <20220224212334.GB29410@fieldses.org> (raw)
In-Reply-To: <164567931673.25116.15009501732764258663@noble.neil.brown.name>

On Thu, Feb 24, 2022 at 04:08:36PM +1100, NeilBrown wrote:
> On Wed, 23 Feb 2022, J. Bruce Fields wrote:
> > For what it's worth, I applied this to recent upstream (038101e6b2cd)
> > and fed it through my usual scripts--tests all passed, but I did see
> > this lockdep warning.
> > 
> > I'm not actually sure what was running at the time--probably just cthon.
> > 
> > --b.
> > 
> > [  142.679891] ======================================================
> > [  142.680883] WARNING: possible circular locking dependency detected
> > [  142.681999] 5.17.0-rc5-00005-g64e79f877311 #1778 Not tainted
> > [  142.682970] ------------------------------------------------------
> > [  142.684059] test1/4557 is trying to acquire lock:
> > [  142.684881] ffff888023d85398 (DENTRY_PAR_UPDATE){+.+.}-{0:0}, at: d_lock_update_nested+0x5/0x6a0
> > [  142.686421] 
> >                but task is already holding lock:
> > [  142.687171] ffff88801f618bd0 (&type->i_mutex_dir_key#6){++++}-{3:3}, at: path_openat+0x7cb/0x24a0
> > [  142.689098] 
> >                which lock already depends on the new lock.
> > 
> > [  142.690045] 
> >                the existing dependency chain (in reverse order) is:
> > [  142.691171] 
> >                -> #1 (&type->i_mutex_dir_key#6){++++}-{3:3}:
> > [  142.692285]        down_write+0x82/0x130
> > [  142.692844]        vfs_rmdir+0xbd/0x560
> > [  142.693351]        do_rmdir+0x33d/0x400
> 
> Thanks.  I hadn't tested rmdir :-)

OK.  I tested with this applied and didn't see any issues.

--b.

> 
> "rmdir" and "open(O_CREATE)" take these locks in the opposite order.
> 
> I think the simplest fix might be to change the inode_lock(_shared) taken
> on the dir in open_last_Lookups() to use I_MUTEX_PARENT.  That is
> consistent with unlink and rmdir etc which use I_MUTEX_PARENT on the
> parent.
> 
> open() doesn't currently use I_MUTEX_PARENT because it never needs to
> lock the child.  But as it *is* a parent that is being locked, using
> I_MUTEX_PARENT probably make more sense.
> 
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -3513,9 +3513,9 @@ static const char *open_last_lookups(struct nameidata *nd,
>  	}
>  	shared = !!(dir->d_inode->i_flags & S_PAR_UPDATE);
>  	if ((open_flag & O_CREAT) && !shared)
> -		inode_lock(dir->d_inode);
> +		inode_lock_nested(dir->d_inode, I_MUTEX_PARENT);
>  	else
> -		inode_lock_shared(dir->d_inode);
> +		inode_lock_shared_nested(dir->d_inode, I_MUTEX_PARENT);
>  	dentry = lookup_open(nd, file, op, got_write);
>  	if (!IS_ERR(dentry) && (file->f_mode & FMODE_CREATED))
>  		fsnotify_create(dir->d_inode, dentry);
> 
> Thanks,
> NeilBrown

  reply	other threads:[~2022-02-24 21:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22  2:24 [PATCH/RFC] VFS: support parallel updates in the one directory NeilBrown
2022-02-22 19:07 ` J. Bruce Fields
2022-02-22 21:11   ` J. Bruce Fields
2022-02-24  5:08   ` NeilBrown
2022-02-24 21:23     ` J. Bruce Fields [this message]
2022-02-22 22:45 ` Dave Chinner
2022-02-24  4:43   ` Darrick J. Wong
2022-02-24  5:56     ` NeilBrown
2022-02-24 16:31       ` Andreas Dilger
2022-02-24 23:38         ` Darrick J. Wong
2022-02-25 23:16           ` Dave Chinner
2022-02-28  0:55           ` NeilBrown
2022-03-10 11:10             ` Daire Byrne
2022-02-25 23:07     ` Dave Chinner

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=20220224212334.GB29410@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=adilger.kernel@dilger.ca \
    --cc=daire@dneg.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=viro@zeniv.linux.org.uk \
    /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