aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r--fs/nfs/inode.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 50a15fa8cf9..6f00086e340 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -629,23 +629,28 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
629 nfs_revalidate_inode(server, inode); 629 nfs_revalidate_inode(server, inode);
630} 630}
631 631
632struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct rpc_cred *cred, fmode_t f_mode) 632struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode)
633{ 633{
634 struct nfs_open_context *ctx; 634 struct nfs_open_context *ctx;
635 struct rpc_cred *cred = rpc_lookup_cred();
636 if (IS_ERR(cred))
637 return ERR_CAST(cred);
635 638
636 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); 639 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
637 if (ctx != NULL) { 640 if (!ctx) {
638 nfs_sb_active(dentry->d_sb); 641 put_rpccred(cred);
639 ctx->dentry = dget(dentry); 642 return ERR_PTR(-ENOMEM);
640 ctx->cred = get_rpccred(cred);
641 ctx->state = NULL;
642 ctx->mode = f_mode;
643 ctx->flags = 0;
644 ctx->error = 0;
645 nfs_init_lock_context(&ctx->lock_context);
646 ctx->lock_context.open_context = ctx;
647 INIT_LIST_HEAD(&ctx->list);
648 } 643 }
644 nfs_sb_active(dentry->d_sb);
645 ctx->dentry = dget(dentry);
646 ctx->cred = cred;
647 ctx->state = NULL;
648 ctx->mode = f_mode;
649 ctx->flags = 0;
650 ctx->error = 0;
651 nfs_init_lock_context(&ctx->lock_context);
652 ctx->lock_context.open_context = ctx;
653 INIT_LIST_HEAD(&ctx->list);
649 return ctx; 654 return ctx;
650} 655}
651 656
@@ -738,15 +743,10 @@ static void nfs_file_clear_open_context(struct file *filp)
738int nfs_open(struct inode *inode, struct file *filp) 743int nfs_open(struct inode *inode, struct file *filp)
739{ 744{
740 struct nfs_open_context *ctx; 745 struct nfs_open_context *ctx;
741 struct rpc_cred *cred;
742 746
743 cred = rpc_lookup_cred(); 747 ctx = alloc_nfs_open_context(filp->f_path.dentry, filp->f_mode);
744 if (IS_ERR(cred)) 748 if (IS_ERR(ctx))
745 return PTR_ERR(cred); 749 return PTR_ERR(ctx);
746 ctx = alloc_nfs_open_context(filp->f_path.dentry, cred, filp->f_mode);
747 put_rpccred(cred);
748 if (ctx == NULL)
749 return -ENOMEM;
750 nfs_file_set_open_context(filp, ctx); 750 nfs_file_set_open_context(filp, ctx);
751 put_nfs_open_context(ctx); 751 put_nfs_open_context(ctx);
752 nfs_fscache_set_inode_cookie(inode, filp); 752 nfs_fscache_set_inode_cookie(inode, filp);
@@ -1464,7 +1464,6 @@ struct inode *nfs_alloc_inode(struct super_block *sb)
1464static void nfs_i_callback(struct rcu_head *head) 1464static void nfs_i_callback(struct rcu_head *head)
1465{ 1465{
1466 struct inode *inode = container_of(head, struct inode, i_rcu); 1466 struct inode *inode = container_of(head, struct inode, i_rcu);
1467 INIT_LIST_HEAD(&inode->i_dentry);
1468 kmem_cache_free(nfs_inode_cachep, NFS_I(inode)); 1467 kmem_cache_free(nfs_inode_cachep, NFS_I(inode));
1469} 1468}
1470 1469