Lines Matching refs:ctx

937 static struct nfs_lock_context *__nfs_find_lock_context(struct nfs_open_context *ctx)
941 list_for_each_entry_rcu(pos, &ctx->lock_context.list, list) {
950 struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx)
953 struct inode *inode = d_inode(ctx->dentry);
956 res = __nfs_find_lock_context(ctx);
964 res = __nfs_find_lock_context(ctx);
966 new->open_context = get_nfs_open_context(ctx);
969 &ctx->lock_context.list);
984 struct nfs_open_context *ctx = l_ctx->open_context;
985 struct inode *inode = d_inode(ctx->dentry);
991 put_nfs_open_context(ctx);
998 * @ctx: pointer to context
1005 void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
1010 if (!(ctx->mode & FMODE_WRITE))
1014 inode = d_inode(ctx->dentry);
1035 struct nfs_open_context *ctx;
1037 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL_ACCOUNT);
1038 if (!ctx)
1041 ctx->dentry = dget(dentry);
1043 ctx->cred = get_cred(filp->f_cred);
1045 ctx->cred = get_current_cred();
1046 rcu_assign_pointer(ctx->ll_cred, NULL);
1047 ctx->state = NULL;
1048 ctx->mode = f_mode;
1049 ctx->flags = 0;
1050 ctx->error = 0;
1051 ctx->flock_owner = (fl_owner_t)filp;
1052 nfs_init_lock_context(&ctx->lock_context);
1053 ctx->lock_context.open_context = ctx;
1054 INIT_LIST_HEAD(&ctx->list);
1055 ctx->mdsthreshold = NULL;
1056 return ctx;
1060 struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx)
1062 if (ctx != NULL && refcount_inc_not_zero(&ctx->lock_context.count))
1063 return ctx;
1068 static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync)
1070 struct inode *inode = d_inode(ctx->dentry);
1071 struct super_block *sb = ctx->dentry->d_sb;
1073 if (!refcount_dec_and_test(&ctx->lock_context.count))
1075 if (!list_empty(&ctx->list)) {
1077 list_del_rcu(&ctx->list);
1081 NFS_PROTO(inode)->close_context(ctx, is_sync);
1082 put_cred(ctx->cred);
1083 dput(ctx->dentry);
1085 put_rpccred(rcu_dereference_protected(ctx->ll_cred, 1));
1086 kfree(ctx->mdsthreshold);
1087 kfree_rcu(ctx, rcu_head);
1090 void put_nfs_open_context(struct nfs_open_context *ctx)
1092 __put_nfs_open_context(ctx, 0);
1096 static void put_nfs_open_context_sync(struct nfs_open_context *ctx)
1098 __put_nfs_open_context(ctx, 1);
1105 void nfs_inode_attach_open_context(struct nfs_open_context *ctx)
1107 struct inode *inode = d_inode(ctx->dentry);
1115 list_add_tail_rcu(&ctx->list, &nfsi->open_files);
1120 void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx)
1122 filp->private_data = get_nfs_open_context(ctx);
1123 set_bit(NFS_CONTEXT_FILE_OPEN, &ctx->flags);
1124 if (list_empty(&ctx->list))
1125 nfs_inode_attach_open_context(ctx);
1135 struct nfs_open_context *pos, *ctx = NULL;
1145 ctx = get_nfs_open_context(pos);
1146 if (ctx)
1150 return ctx;
1155 struct nfs_open_context *ctx = nfs_file_open_context(filp);
1157 if (ctx) {
1158 struct inode *inode = d_inode(ctx->dentry);
1160 clear_bit(NFS_CONTEXT_FILE_OPEN, &ctx->flags);
1165 if (ctx->error < 0)
1168 put_nfs_open_context_sync(ctx);
1177 struct nfs_open_context *ctx;
1179 ctx = alloc_nfs_open_context(file_dentry(filp),
1181 if (IS_ERR(ctx))
1182 return PTR_ERR(ctx);
1183 nfs_file_set_open_context(filp, ctx);
1184 put_nfs_open_context(ctx);