NFS: Don't allow NFS silly-renamed files to be deleted, no signal
[linux-2.6.git] / fs / nfs / unlink.c
index 3210a03..2781563 100644 (file)
@@ -336,20 +336,14 @@ static void nfs_async_rename_done(struct rpc_task *task, void *calldata)
        struct inode *old_dir = data->old_dir;
        struct inode *new_dir = data->new_dir;
        struct dentry *old_dentry = data->old_dentry;
-       struct dentry *new_dentry = data->new_dentry;
 
        if (!NFS_PROTO(old_dir)->rename_done(task, old_dir, new_dir)) {
                rpc_restart_call_prepare(task);
                return;
        }
 
-       if (task->tk_status != 0) {
+       if (task->tk_status != 0)
                nfs_cancel_async_unlink(old_dentry);
-               return;
-       }
-
-       d_drop(old_dentry);
-       d_drop(new_dentry);
 }
 
 /**
@@ -550,6 +544,18 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
        error = rpc_wait_for_completion_task(task);
        if (error == 0)
                error = task->tk_status;
+       switch (error) {
+       case 0:
+               /* The rename succeeded */
+               nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
+               d_move(dentry, sdentry);
+               break;
+       case -ERESTARTSYS:
+               /* The result of the rename is unknown. Play it safe by
+                * forcing a new lookup */
+               d_drop(dentry);
+               d_drop(sdentry);
+       }
        rpc_put_task(task);
 out_dput:
        dput(sdentry);