mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chuck Lever III <chuck.lever@oracle.com>
To: Neil Brown <neilb@suse.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>, Daire Byrne <daire@dneg.com>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 09/12] nfsd: support concurrent renames.
Date: Fri, 24 Jun 2022 14:43:24 +0000	[thread overview]
Message-ID: <7FDF6A0F-CD8A-4813-A5CA-FC2D69E84F29@oracle.com> (raw)
In-Reply-To: <165516230201.21248.13160043266041158437.stgit@noble.brown>



> On Jun 13, 2022, at 7:18 PM, NeilBrown <neilb@suse.de> wrote:
> 
> If the filesystem supports it, renames can now be concurrent with other
> updates.
> We use lock_rename_lookup_one() to do the appropriate locking in the
> right order and to look up the names.
> 
> Signed-off-by: NeilBrown <neilb@suse.de>

Reviewed-by: Chuck Lever <chuck.lever@oracle.com>


> ---
> fs/nfsd/vfs.c |   49 +++++++++++++++++++------------------------------
> 1 file changed, 19 insertions(+), 30 deletions(-)
> 
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index 6cdd5e407600..b0df216ab3e4 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -1584,6 +1584,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
> 	__be32		err;
> 	int		host_err;
> 	bool		close_cached = false;
> +	DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);

Ditto.


> 
> 	err = fh_verify(rqstp, ffhp, S_IFDIR, NFSD_MAY_REMOVE);
> 	if (err)
> @@ -1611,41 +1612,37 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
> 
> 	/* cannot use fh_lock as we need deadlock protective ordering
> 	 * so do it by hand */
> -	trap = lock_rename(tdentry, fdentry);
> -	ffhp->fh_locked = tfhp->fh_locked = true;
> -	fh_fill_pre_attrs(ffhp, true);
> -	fh_fill_pre_attrs(tfhp, true);
> -
> -	odentry = lookup_one_len(fname, fdentry, flen);
> -	host_err = PTR_ERR(odentry);
> -	if (IS_ERR(odentry))
> +	trap = lock_rename_lookup_one(tdentry, fdentry, &ndentry, &odentry,
> +				      tname, tlen, fname, flen, 0, 0, &wq);
> +	host_err = PTR_ERR(trap);
> +	if (IS_ERR(trap))
> 		goto out_nfserr;
> +	ffhp->fh_locked = tfhp->fh_locked = true;
> +	fh_fill_pre_attrs(ffhp, (ndentry->d_flags & DCACHE_PAR_UPDATE) == 0);
> +	fh_fill_pre_attrs(tfhp, (ndentry->d_flags & DCACHE_PAR_UPDATE) == 0);
> 
> 	host_err = -ENOENT;
> 	if (d_really_is_negative(odentry))
> -		goto out_dput_old;
> +		goto out_unlock;
> 	host_err = -EINVAL;
> 	if (odentry == trap)
> -		goto out_dput_old;
> +		goto out_unlock;
> 
> -	ndentry = lookup_one_len(tname, tdentry, tlen);
> -	host_err = PTR_ERR(ndentry);
> -	if (IS_ERR(ndentry))
> -		goto out_dput_old;
> 	host_err = -ENOTEMPTY;
> 	if (ndentry == trap)
> -		goto out_dput_new;
> +		goto out_unlock;
> 
> 	host_err = -EXDEV;
> 	if (ffhp->fh_export->ex_path.mnt != tfhp->fh_export->ex_path.mnt)
> -		goto out_dput_new;
> +		goto out_unlock;
> 	if (ffhp->fh_export->ex_path.dentry != tfhp->fh_export->ex_path.dentry)
> -		goto out_dput_new;
> +		goto out_unlock;
> 
> 	if ((ndentry->d_sb->s_export_op->flags & EXPORT_OP_CLOSE_BEFORE_UNLINK) &&
> 	    nfsd_has_cached_files(ndentry)) {
> 		close_cached = true;
> -		goto out_dput_old;
> +		dget(ndentry);
> +		goto out_unlock;
> 	} else {
> 		struct renamedata rd = {
> 			.old_mnt_userns	= &init_user_ns,
> @@ -1662,23 +1659,15 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
> 				host_err = commit_metadata(ffhp);
> 		}
> 	}
> - out_dput_new:
> -	dput(ndentry);
> - out_dput_old:
> -	dput(odentry);
> - out_nfserr:
> -	err = nfserrno(host_err);
> -	/*
> -	 * We cannot rely on fh_unlock on the two filehandles,
> -	 * as that would do the wrong thing if the two directories
> -	 * were the same, so again we do it by hand.
> -	 */
> 	if (!close_cached) {
> 		fh_fill_post_attrs(ffhp);
> 		fh_fill_post_attrs(tfhp);
> 	}
> -	unlock_rename(tdentry, fdentry);
> + out_unlock:
> +	unlock_rename_lookup(tdentry, fdentry, ndentry, odentry);
> 	ffhp->fh_locked = tfhp->fh_locked = false;
> + out_nfserr:
> +	err = nfserrno(host_err);
> 	fh_drop_write(ffhp);
> 
> 	/*
> 
> 

--
Chuck Lever




  reply	other threads:[~2022-06-24 14:45 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-13 23:18 [PATCH RFC 00/12] Allow concurrent directory updates NeilBrown
2022-06-13 23:18 ` [PATCH 01/12] VFS: support parallel updates in the one directory NeilBrown
2022-06-13 23:18 ` [PATCH 02/12] VFS: move EEXIST and ENOENT tests into lookup_hash_update() NeilBrown
2022-06-13 23:18 ` [PATCH 04/12] VFS: move dput() and mnt_drop_write() into done_path_update() NeilBrown
2022-06-13 23:18 ` [PATCH 05/12] VFS: export done_path_update() NeilBrown
2022-06-13 23:18 ` [PATCH 03/12] VFS: move want_write checks into lookup_hash_update() NeilBrown
2022-06-13 23:18 ` [PATCH 08/12] nfsd: allow parallel creates from nfsd NeilBrown
2022-06-24 14:43   ` Chuck Lever III
2022-06-28 22:35   ` Chuck Lever III
2022-06-28 23:09     ` NeilBrown
2022-07-04 17:17       ` Chuck Lever III
2022-06-13 23:18 ` [PATCH 10/12] nfsd: reduce locking in nfsd_lookup() NeilBrown
2022-06-24 14:43   ` Chuck Lever III
2022-06-13 23:18 ` [PATCH 07/12] NFS: support parallel updates in the one directory NeilBrown
2022-06-13 23:18 ` [PATCH 09/12] nfsd: support concurrent renames NeilBrown
2022-06-24 14:43   ` Chuck Lever III [this message]
2022-06-13 23:18 ` [PATCH 06/12] VFS: " NeilBrown
2022-06-14  4:35   ` kernel test robot
2022-06-14 12:37   ` kernel test robot
2022-06-14 13:28   ` kernel test robot
2022-06-26 13:07   ` [VFS] 46a2afd9f6: ltp.rename10.fail kernel test robot
2022-06-13 23:18 ` [PATCH 12/12] nfsd: discard fh_locked flag and fh_lock/fh_unlock NeilBrown
2022-06-24 14:43   ` Chuck Lever III
2022-06-13 23:18 ` [PATCH 11/12] nfsd: use (un)lock_inode instead of fh_(un)lock NeilBrown
2022-06-24 14:43   ` Chuck Lever III
2022-06-15 13:46 ` [PATCH RFC 00/12] Allow concurrent directory updates Daire Byrne
2022-06-16  0:55   ` NeilBrown
2022-06-16 10:48     ` Daire Byrne
2022-06-17  5:49       ` NeilBrown
2022-06-17 15:27         ` Daire Byrne
2022-06-20 10:18           ` Daire Byrne
2022-06-16 13:49     ` Anna Schumaker

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=7FDF6A0F-CD8A-4813-A5CA-FC2D69E84F29@oracle.com \
    --to=chuck.lever@oracle.com \
    --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=trond.myklebust@hammerspace.com \
    --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

all inboxes | Powered by JetHome®