Commit 15494511 authored by Trond Myklebust's avatar Trond Myklebust Committed by Anna Schumaker

NFS: Ensure that all nfs lock contexts have a valid open context

Force the lock context to keep a reference to the parent open
context so that we can guarantee the validity of the latter.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent 0688e64b
...@@ -885,10 +885,14 @@ struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx) ...@@ -885,10 +885,14 @@ struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx)
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
res = __nfs_find_lock_context(ctx); res = __nfs_find_lock_context(ctx);
if (res == NULL) { if (res == NULL) {
list_add_tail_rcu(&new->list, &ctx->lock_context.list); new->open_context = get_nfs_open_context(ctx);
new->open_context = ctx; if (new->open_context) {
list_add_tail_rcu(&new->list,
&ctx->lock_context.list);
res = new; res = new;
new = NULL; new = NULL;
} else
res = ERR_PTR(-EBADF);
} }
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
kfree(new); kfree(new);
...@@ -906,6 +910,7 @@ void nfs_put_lock_context(struct nfs_lock_context *l_ctx) ...@@ -906,6 +910,7 @@ void nfs_put_lock_context(struct nfs_lock_context *l_ctx)
return; return;
list_del_rcu(&l_ctx->list); list_del_rcu(&l_ctx->list);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
put_nfs_open_context(ctx);
kfree_rcu(l_ctx, rcu_head); kfree_rcu(l_ctx, rcu_head);
} }
EXPORT_SYMBOL_GPL(nfs_put_lock_context); EXPORT_SYMBOL_GPL(nfs_put_lock_context);
......
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