Lines Matching defs:msg_ctx
30 * @msg_ctx: The context that was acquired from the free list
33 * on the context. Sets the msg_ctx task to current. Returns zero on
38 static int ecryptfs_acquire_free_msg_ctx(struct ecryptfs_msg_ctx **msg_ctx)
53 *msg_ctx = list_entry(p, struct ecryptfs_msg_ctx, node);
54 if (mutex_trylock(&(*msg_ctx)->mux)) {
55 (*msg_ctx)->task = current;
67 * @msg_ctx: The context to move from the free list to the alloc list
71 static void ecryptfs_msg_ctx_free_to_alloc(struct ecryptfs_msg_ctx *msg_ctx)
73 list_move(&msg_ctx->node, &ecryptfs_msg_ctx_alloc_list);
74 msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_PENDING;
75 msg_ctx->counter = ++ecryptfs_msg_counter;
80 * @msg_ctx: The context to move from the alloc list to the free list
84 void ecryptfs_msg_ctx_alloc_to_free(struct ecryptfs_msg_ctx *msg_ctx)
86 list_move(&(msg_ctx->node), &ecryptfs_msg_ctx_free_list);
87 kfree(msg_ctx->msg);
88 msg_ctx->msg = NULL;
89 msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_FREE;
158 struct ecryptfs_msg_ctx *msg_ctx, *msg_ctx_tmp;
168 list_for_each_entry_safe(msg_ctx, msg_ctx_tmp,
170 list_del(&msg_ctx->daemon_out_list);
174 ecryptfs_msg_ctx_alloc_to_free(msg_ctx);
194 * msg_ctx from the ecryptfs_msg_ctx_arr at a particular index. The
196 * response message into the msg_ctx that the process holds a
198 * that msg_ctx->state == ECRYPTFS_MSG_CTX_STATE_DONE, and then
208 struct ecryptfs_msg_ctx *msg_ctx;
220 msg_ctx = &ecryptfs_msg_ctx_arr[msg->index];
221 mutex_lock(&msg_ctx->mux);
222 if (msg_ctx->state != ECRYPTFS_MSG_CTX_STATE_PENDING) {
227 } else if (msg_ctx->counter != seq) {
231 msg_ctx->counter, seq);
235 msg_ctx->msg = kmemdup(msg, msg_size, GFP_KERNEL);
236 if (!msg_ctx->msg) {
240 msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_DONE;
241 wake_up_process(msg_ctx->task);
244 mutex_unlock(&msg_ctx->mux);
253 * @msg_ctx: The message context allocated for the send
261 struct ecryptfs_msg_ctx **msg_ctx)
272 rc = ecryptfs_acquire_free_msg_ctx(msg_ctx);
279 ecryptfs_msg_ctx_free_to_alloc(*msg_ctx);
280 mutex_unlock(&(*msg_ctx)->mux);
282 rc = ecryptfs_send_miscdev(data, data_len, *msg_ctx, msg_type, 0,
295 * @msg_ctx: The message context allocated for the send
302 struct ecryptfs_msg_ctx **msg_ctx)
308 msg_ctx);
315 * @msg_ctx: The context that was assigned when sending a message
324 int ecryptfs_wait_for_response(struct ecryptfs_msg_ctx *msg_ctx,
333 mutex_lock(&msg_ctx->mux);
334 if (msg_ctx->state != ECRYPTFS_MSG_CTX_STATE_DONE) {
336 mutex_unlock(&msg_ctx->mux);
342 *msg = msg_ctx->msg;
343 msg_ctx->msg = NULL;
345 ecryptfs_msg_ctx_alloc_to_free(msg_ctx);
346 mutex_unlock(&msg_ctx->mux);