Commit 003192c3 authored by Benjamin Coddington's avatar Benjamin Coddington Committed by Greg Kroah-Hartman

Revert "NFS: nfs_rename() handle -ERESTARTSYS dentry left behind"

commit d9f29500 upstream.

This reverts commit 920b4530 which could
call d_move() without holding the directory's i_mutex, and reverts commit
d4ea7e3c "NFS: Fix old dentry rehash after
move", which was a follow-up fix.
Signed-off-by: default avatarBenjamin Coddington <bcodding@redhat.com>
Fixes: 920b4530 ("NFS: nfs_rename() handle -ERESTARTSYS dentry left behind")
Reviewed-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 95b2e088
...@@ -2002,29 +2002,6 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) ...@@ -2002,29 +2002,6 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
} }
EXPORT_SYMBOL_GPL(nfs_link); EXPORT_SYMBOL_GPL(nfs_link);
static void
nfs_complete_rename(struct rpc_task *task, struct nfs_renamedata *data)
{
struct dentry *old_dentry = data->old_dentry;
struct dentry *new_dentry = data->new_dentry;
struct inode *old_inode = d_inode(old_dentry);
struct inode *new_inode = d_inode(new_dentry);
nfs_mark_for_revalidate(old_inode);
switch (task->tk_status) {
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(data->new_dir));
break;
case -ENOENT:
nfs_dentry_handle_enoent(old_dentry);
}
}
/* /*
* RENAME * RENAME
* FIXME: Some nfsds, like the Linux user space nfsd, may generate a * FIXME: Some nfsds, like the Linux user space nfsd, may generate a
...@@ -2055,7 +2032,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2055,7 +2032,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
{ {
struct inode *old_inode = d_inode(old_dentry); struct inode *old_inode = d_inode(old_dentry);
struct inode *new_inode = d_inode(new_dentry); struct inode *new_inode = d_inode(new_dentry);
struct dentry *dentry = NULL; struct dentry *dentry = NULL, *rehash = NULL;
struct rpc_task *task; struct rpc_task *task;
int error = -EBUSY; int error = -EBUSY;
...@@ -2078,8 +2055,10 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2078,8 +2055,10 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
* To prevent any new references to the target during the * To prevent any new references to the target during the
* rename, we unhash the dentry in advance. * rename, we unhash the dentry in advance.
*/ */
if (!d_unhashed(new_dentry)) if (!d_unhashed(new_dentry)) {
d_drop(new_dentry); d_drop(new_dentry);
rehash = new_dentry;
}
if (d_count(new_dentry) > 2) { if (d_count(new_dentry) > 2) {
int err; int err;
...@@ -2096,6 +2075,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2096,6 +2075,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
goto out; goto out;
new_dentry = dentry; new_dentry = dentry;
rehash = NULL;
new_inode = NULL; new_inode = NULL;
} }
} }
...@@ -2104,8 +2084,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2104,8 +2084,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (new_inode != NULL) if (new_inode != NULL)
NFS_PROTO(new_inode)->return_delegation(new_inode); NFS_PROTO(new_inode)->return_delegation(new_inode);
task = nfs_async_rename(old_dir, new_dir, old_dentry, new_dentry, task = nfs_async_rename(old_dir, new_dir, old_dentry, new_dentry, NULL);
nfs_complete_rename);
if (IS_ERR(task)) { if (IS_ERR(task)) {
error = PTR_ERR(task); error = PTR_ERR(task);
goto out; goto out;
...@@ -2115,9 +2094,27 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2115,9 +2094,27 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (error == 0) if (error == 0)
error = task->tk_status; error = task->tk_status;
rpc_put_task(task); rpc_put_task(task);
nfs_mark_for_revalidate(old_inode);
out: out:
if (rehash)
d_rehash(rehash);
trace_nfs_rename_exit(old_dir, old_dentry, trace_nfs_rename_exit(old_dir, old_dentry,
new_dir, new_dentry, error); new_dir, new_dentry, error);
if (!error) {
if (new_inode != NULL)
nfs_drop_nlink(new_inode);
/*
* The d_move() should be here instead of in an async RPC completion
* handler because we need the proper locks to move the dentry. If
* we're interrupted by a signal, the async RPC completion handler
* should mark the directories for revalidation.
*/
d_move(old_dentry, new_dentry);
nfs_set_verifier(new_dentry,
nfs_save_change_attribute(new_dir));
} else if (error == -ENOENT)
nfs_dentry_handle_enoent(old_dentry);
/* new dentry created? */ /* new dentry created? */
if (dentry) if (dentry)
dput(dentry); dput(dentry);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment