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);
195 * msg_ctx from the ecryptfs_msg_ctx_arr at a particular index. The
197 * response message into the msg_ctx that the process holds a
199 * that msg_ctx->state == ECRYPTFS_MSG_CTX_STATE_DONE, and then
209 struct ecryptfs_msg_ctx *msg_ctx;
221 msg_ctx = &ecryptfs_msg_ctx_arr[msg->index];
222 mutex_lock(&msg_ctx->mux);
223 if (msg_ctx->state != ECRYPTFS_MSG_CTX_STATE_PENDING) {
228 } else if (msg_ctx->counter != seq) {
232 msg_ctx->counter, seq);
236 msg_ctx->msg = kmemdup(msg, msg_size, GFP_KERNEL);
237 if (!msg_ctx->msg) {
241 msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_DONE;
242 wake_up_process(msg_ctx->task);
245 mutex_unlock(&msg_ctx->mux);
255 * @msg_ctx: The message context allocated for the send
263 struct ecryptfs_msg_ctx **msg_ctx)
274 rc = ecryptfs_acquire_free_msg_ctx(msg_ctx);
281 ecryptfs_msg_ctx_free_to_alloc(*msg_ctx);
282 mutex_unlock(&(*msg_ctx)->mux);
284 rc = ecryptfs_send_miscdev(data, data_len, *msg_ctx, msg_type, 0,
297 * @msg_ctx: The message context allocated for the send
304 struct ecryptfs_msg_ctx **msg_ctx)
310 msg_ctx);
317 * @msg_ctx: The context that was assigned when sending a message
326 int ecryptfs_wait_for_response(struct ecryptfs_msg_ctx *msg_ctx,
335 mutex_lock(&msg_ctx->mux);
336 if (msg_ctx->state != ECRYPTFS_MSG_CTX_STATE_DONE) {
338 mutex_unlock(&msg_ctx->mux);
344 *msg = msg_ctx->msg;
345 msg_ctx->msg = NULL;
347 ecryptfs_msg_ctx_alloc_to_free(msg_ctx);
348 mutex_unlock(&msg_ctx->mux);