Linux NFS development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: Benjamin Coddington <bcodding@redhat.com>,
	Trond Myklebust <trond.myklebust@primarydata.com>,
	Anna Schumaker <anna.schumaker@netapp.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH] NFS: nfs_rename() handle -ERESTARTSYS dentry left behind
Date: Thu, 15 Dec 2016 10:02:55 -0500	[thread overview]
Message-ID: <1481814175.2699.13.camel@redhat.com> (raw)
In-Reply-To: <11625082826baa811b3ad5b87e1e6e712c6e582d.1481813137.git.bcodding@redhat.com>

On Thu, 2016-12-15 at 09:48 -0500, Benjamin Coddington wrote:
> An interrupted rename will leave the old dentry behind if the rename
> succeeds.  Fix this by forcing a lookup the next time through
> ->d_revalidate.
> 
> Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
> ---
>  fs/nfs/dir.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 5f1af4cd1a33..5d409616f77e 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -2100,14 +2100,24 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  		d_rehash(rehash);
>  	trace_nfs_rename_exit(old_dir, old_dentry,
>  			new_dir, new_dentry, error);
> -	if (!error) {
> +
> +	switch (error) {
> +	case 0:
>  		if (new_inode != NULL)
>  			nfs_drop_nlink(new_inode);
>  		d_move(old_dentry, new_dentry);
>  		nfs_set_verifier(new_dentry,
>  					nfs_save_change_attribute(new_dir));
> -	} else if (error == -ENOENT)
> +		break;
> +	case -ENOENT:
>  		nfs_dentry_handle_enoent(old_dentry);
> +		break;
> +	case -ERESTARTSYS:
> +		/* The result of the rename is unknown. Play it safe by
> +		 * forcing a new lookup */
> +		nfs_force_lookup_revalidate(old_dir);
> +		nfs_force_lookup_revalidate(new_dir);
> +	}
>  
>  	/* new dentry created? */
>  	if (dentry)

Looks reasonable to me. 

Reviewed-by: Jeff Layton <jlayton@redhat.com>

  reply	other threads:[~2016-12-15 15:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-15 14:48 [PATCH] NFS: nfs_rename() handle -ERESTARTSYS dentry left behind Benjamin Coddington
2016-12-15 15:02 ` Jeff Layton [this message]
2016-12-15 22:38 ` Trond Myklebust
2016-12-16 11:09   ` Benjamin Coddington
2016-12-16 14:23     ` Trond Myklebust
2016-12-16 14:35       ` Jeff Layton
2016-12-16 14:44         ` Trond Myklebust

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=1481814175.2699.13.camel@redhat.com \
    --to=jlayton@redhat.com \
    --cc=anna.schumaker@netapp.com \
    --cc=bcodding@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@primarydata.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox