SUNRPC: Clean up the sillyrename code
Fix a couple of bugs: - Don't rely on the parent dentry still being valid when the call completes. Fixes a race with shrink_dcache_for_umount_subtree() - Don't remove the file if the filehandle has been labelled as stale. Fix a couple of inefficiencies - Remove the global list of sillyrenamed files. Instead we can cache the sillyrename information in the dentry->d_fsdata - Move common code from unlink_setup/unlink_done into fs/nfs/unlink.c Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
@@ -1962,48 +1962,26 @@ static int nfs4_proc_remove(struct inode *dir, struct qstr *name)
|
||||
return err;
|
||||
}
|
||||
|
||||
struct unlink_desc {
|
||||
struct nfs_removeargs args;
|
||||
struct nfs_removeres res;
|
||||
};
|
||||
|
||||
static int nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir,
|
||||
struct qstr *name)
|
||||
static void nfs4_proc_unlink_setup(struct rpc_message *msg, struct inode *dir)
|
||||
{
|
||||
struct nfs_server *server = NFS_SERVER(dir->d_inode);
|
||||
struct unlink_desc *up;
|
||||
struct nfs_server *server = NFS_SERVER(dir);
|
||||
struct nfs_removeargs *args = msg->rpc_argp;
|
||||
struct nfs_removeres *res = msg->rpc_resp;
|
||||
|
||||
up = kmalloc(sizeof(*up), GFP_KERNEL);
|
||||
if (!up)
|
||||
return -ENOMEM;
|
||||
|
||||
up->args.fh = NFS_FH(dir->d_inode);
|
||||
up->args.name.len = name->len;
|
||||
up->args.name.name = name->name;
|
||||
up->args.bitmask = server->attr_bitmask;
|
||||
up->res.server = server;
|
||||
nfs_fattr_init(&up->res.dir_attr);
|
||||
|
||||
args->bitmask = server->attr_bitmask;
|
||||
res->server = server;
|
||||
msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE];
|
||||
msg->rpc_argp = &up->args;
|
||||
msg->rpc_resp = &up->res;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nfs4_proc_unlink_done(struct dentry *dir, struct rpc_task *task)
|
||||
static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir)
|
||||
{
|
||||
struct rpc_message *msg = &task->tk_msg;
|
||||
struct unlink_desc *up;
|
||||
|
||||
if (msg->rpc_resp != NULL) {
|
||||
up = container_of(msg->rpc_resp, struct unlink_desc, res);
|
||||
update_changeattr(dir->d_inode, &up->res.cinfo);
|
||||
nfs_post_op_update_inode(dir->d_inode, &up->res.dir_attr);
|
||||
kfree(up);
|
||||
msg->rpc_resp = NULL;
|
||||
msg->rpc_argp = NULL;
|
||||
}
|
||||
return 0;
|
||||
struct nfs_removeres *res = task->tk_msg.rpc_resp;
|
||||
|
||||
if (nfs4_async_handle_error(task, res->server) == -EAGAIN)
|
||||
return 0;
|
||||
update_changeattr(dir, &res->cinfo);
|
||||
nfs_post_op_update_inode(dir, &res->dir_attr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name,
|
||||
|
Reference in New Issue
Block a user