Lines Matching refs:ctx
70 void ext4_release_crypto_ctx(struct ext4_crypto_ctx *ctx) in ext4_release_crypto_ctx() argument
74 if (ctx->flags & EXT4_WRITE_PATH_FL && ctx->w.bounce_page) in ext4_release_crypto_ctx()
75 mempool_free(ctx->w.bounce_page, ext4_bounce_page_pool); in ext4_release_crypto_ctx()
76 ctx->w.bounce_page = NULL; in ext4_release_crypto_ctx()
77 ctx->w.control_page = NULL; in ext4_release_crypto_ctx()
78 if (ctx->flags & EXT4_CTX_REQUIRES_FREE_ENCRYPT_FL) { in ext4_release_crypto_ctx()
79 kmem_cache_free(ext4_crypto_ctx_cachep, ctx); in ext4_release_crypto_ctx()
82 list_add(&ctx->free_list, &ext4_free_crypto_ctxs); in ext4_release_crypto_ctx()
98 struct ext4_crypto_ctx *ctx = NULL; in ext4_get_crypto_ctx() local
117 ctx = list_first_entry_or_null(&ext4_free_crypto_ctxs, in ext4_get_crypto_ctx()
119 if (ctx) in ext4_get_crypto_ctx()
120 list_del(&ctx->free_list); in ext4_get_crypto_ctx()
122 if (!ctx) { in ext4_get_crypto_ctx()
123 ctx = kmem_cache_zalloc(ext4_crypto_ctx_cachep, GFP_NOFS); in ext4_get_crypto_ctx()
124 if (!ctx) { in ext4_get_crypto_ctx()
128 ctx->flags |= EXT4_CTX_REQUIRES_FREE_ENCRYPT_FL; in ext4_get_crypto_ctx()
130 ctx->flags &= ~EXT4_CTX_REQUIRES_FREE_ENCRYPT_FL; in ext4_get_crypto_ctx()
132 ctx->flags &= ~EXT4_WRITE_PATH_FL; in ext4_get_crypto_ctx()
136 if (!IS_ERR_OR_NULL(ctx)) in ext4_get_crypto_ctx()
137 ext4_release_crypto_ctx(ctx); in ext4_get_crypto_ctx()
138 ctx = ERR_PTR(res); in ext4_get_crypto_ctx()
140 return ctx; in ext4_get_crypto_ctx()
200 struct ext4_crypto_ctx *ctx; in ext4_init_crypto() local
202 ctx = kmem_cache_zalloc(ext4_crypto_ctx_cachep, GFP_NOFS); in ext4_init_crypto()
203 if (!ctx) { in ext4_init_crypto()
207 list_add(&ctx->free_list, &ext4_free_crypto_ctxs); in ext4_init_crypto()
227 struct ext4_crypto_ctx *ctx = in ext4_restore_control_page() local
233 ext4_release_crypto_ctx(ctx); in ext4_restore_control_page()
312 static struct page *alloc_bounce_page(struct ext4_crypto_ctx *ctx) in alloc_bounce_page() argument
314 ctx->w.bounce_page = mempool_alloc(ext4_bounce_page_pool, GFP_NOWAIT); in alloc_bounce_page()
315 if (ctx->w.bounce_page == NULL) in alloc_bounce_page()
317 ctx->flags |= EXT4_WRITE_PATH_FL; in alloc_bounce_page()
318 return ctx->w.bounce_page; in alloc_bounce_page()
339 struct ext4_crypto_ctx *ctx; in ext4_encrypt() local
345 ctx = ext4_get_crypto_ctx(inode); in ext4_encrypt()
346 if (IS_ERR(ctx)) in ext4_encrypt()
347 return (struct page *) ctx; in ext4_encrypt()
350 ciphertext_page = alloc_bounce_page(ctx); in ext4_encrypt()
353 ctx->w.control_page = plaintext_page; in ext4_encrypt()
359 ext4_release_crypto_ctx(ctx); in ext4_encrypt()
363 set_page_private(ciphertext_page, (unsigned long)ctx); in ext4_encrypt()
389 struct ext4_crypto_ctx *ctx; in ext4_encrypted_zeroout() local
405 ctx = ext4_get_crypto_ctx(inode); in ext4_encrypted_zeroout()
406 if (IS_ERR(ctx)) in ext4_encrypted_zeroout()
407 return PTR_ERR(ctx); in ext4_encrypted_zeroout()
409 ciphertext_page = alloc_bounce_page(ctx); in ext4_encrypted_zeroout()
450 ext4_release_crypto_ctx(ctx); in ext4_encrypted_zeroout()