Loading fs/nfs/inode.c +23 −17 Original line number Diff line number Diff line Loading @@ -461,7 +461,6 @@ static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, str ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); if (ctx != NULL) { atomic_set(&ctx->count, 1); ctx->path.dentry = dget(dentry); ctx->path.mnt = mntget(mnt); ctx->cred = get_rpccred(cred); Loading @@ -469,6 +468,7 @@ static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, str ctx->lockowner = current->files; ctx->error = 0; ctx->dir_cookie = 0; kref_init(&ctx->kref); } return ctx; } Loading @@ -476,13 +476,15 @@ static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, str struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx) { if (ctx != NULL) atomic_inc(&ctx->count); kref_get(&ctx->kref); return ctx; } void put_nfs_open_context(struct nfs_open_context *ctx) static void nfs_free_open_context(struct kref *kref) { if (atomic_dec_and_test(&ctx->count)) { struct nfs_open_context *ctx = container_of(kref, struct nfs_open_context, kref); if (!list_empty(&ctx->list)) { struct inode *inode = ctx->path.dentry->d_inode; spin_lock(&inode->i_lock); Loading @@ -497,6 +499,10 @@ void put_nfs_open_context(struct nfs_open_context *ctx) mntput(ctx->path.mnt); kfree(ctx); } void put_nfs_open_context(struct nfs_open_context *ctx) { kref_put(&ctx->kref, nfs_free_open_context); } /* Loading include/linux/nfs_fs.h +2 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #ifdef __KERNEL__ #include <linux/in.h> #include <linux/kref.h> #include <linux/mm.h> #include <linux/namei.h> #include <linux/pagemap.h> Loading Loading @@ -70,7 +71,7 @@ struct nfs_access_entry { struct nfs4_state; struct nfs_open_context { atomic_t count; struct kref kref; struct path path; struct rpc_cred *cred; struct nfs4_state *state; Loading Loading
fs/nfs/inode.c +23 −17 Original line number Diff line number Diff line Loading @@ -461,7 +461,6 @@ static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, str ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); if (ctx != NULL) { atomic_set(&ctx->count, 1); ctx->path.dentry = dget(dentry); ctx->path.mnt = mntget(mnt); ctx->cred = get_rpccred(cred); Loading @@ -469,6 +468,7 @@ static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, str ctx->lockowner = current->files; ctx->error = 0; ctx->dir_cookie = 0; kref_init(&ctx->kref); } return ctx; } Loading @@ -476,13 +476,15 @@ static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, str struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx) { if (ctx != NULL) atomic_inc(&ctx->count); kref_get(&ctx->kref); return ctx; } void put_nfs_open_context(struct nfs_open_context *ctx) static void nfs_free_open_context(struct kref *kref) { if (atomic_dec_and_test(&ctx->count)) { struct nfs_open_context *ctx = container_of(kref, struct nfs_open_context, kref); if (!list_empty(&ctx->list)) { struct inode *inode = ctx->path.dentry->d_inode; spin_lock(&inode->i_lock); Loading @@ -497,6 +499,10 @@ void put_nfs_open_context(struct nfs_open_context *ctx) mntput(ctx->path.mnt); kfree(ctx); } void put_nfs_open_context(struct nfs_open_context *ctx) { kref_put(&ctx->kref, nfs_free_open_context); } /* Loading
include/linux/nfs_fs.h +2 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #ifdef __KERNEL__ #include <linux/in.h> #include <linux/kref.h> #include <linux/mm.h> #include <linux/namei.h> #include <linux/pagemap.h> Loading Loading @@ -70,7 +71,7 @@ struct nfs_access_entry { struct nfs4_state; struct nfs_open_context { atomic_t count; struct kref kref; struct path path; struct rpc_cred *cred; struct nfs4_state *state; Loading