NFS: Really fix put_nfs_open_context()
In nfs_open_revalidate(), if the open_context() call returns an inode that is not the same as dentry->d_inode, then we will call put_nfs_open_context() with a valid dentry->d_inode, but without the context being part of the nfsi->open_files list. In this case too, we want to just skip the list removal, but we do want to call the ->close_context() callback in order to close the NFSv4 state. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Acked-by: Jeff Layton <jlayton@redhat.com>hifive-unleashed-5.1
parent
dfb4f30983
commit
5c78f58e2d
|
@ -639,6 +639,7 @@ struct nfs_open_context *alloc_nfs_open_context(struct path *path, struct rpc_cr
|
||||||
ctx->dir_cookie = 0;
|
ctx->dir_cookie = 0;
|
||||||
nfs_init_lock_context(&ctx->lock_context);
|
nfs_init_lock_context(&ctx->lock_context);
|
||||||
ctx->lock_context.open_context = ctx;
|
ctx->lock_context.open_context = ctx;
|
||||||
|
INIT_LIST_HEAD(&ctx->list);
|
||||||
}
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
@ -654,14 +655,15 @@ static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync)
|
||||||
{
|
{
|
||||||
struct inode *inode = ctx->path.dentry->d_inode;
|
struct inode *inode = ctx->path.dentry->d_inode;
|
||||||
|
|
||||||
if (inode) {
|
if (!list_empty(&ctx->list)) {
|
||||||
if (!atomic_dec_and_lock(&ctx->lock_context.count, &inode->i_lock))
|
if (!atomic_dec_and_lock(&ctx->lock_context.count, &inode->i_lock))
|
||||||
return;
|
return;
|
||||||
list_del(&ctx->list);
|
list_del(&ctx->list);
|
||||||
spin_unlock(&inode->i_lock);
|
spin_unlock(&inode->i_lock);
|
||||||
NFS_PROTO(inode)->close_context(ctx, is_sync);
|
|
||||||
} else if (!atomic_dec_and_test(&ctx->lock_context.count))
|
} else if (!atomic_dec_and_test(&ctx->lock_context.count))
|
||||||
return;
|
return;
|
||||||
|
if (inode != NULL)
|
||||||
|
NFS_PROTO(inode)->close_context(ctx, is_sync);
|
||||||
if (ctx->cred != NULL)
|
if (ctx->cred != NULL)
|
||||||
put_rpccred(ctx->cred);
|
put_rpccred(ctx->cred);
|
||||||
path_put(&ctx->path);
|
path_put(&ctx->path);
|
||||||
|
|
Loading…
Reference in New Issue