diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-06-11 17:33:29 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-06-11 18:04:20 -0400 |
commit | 43f54cd52f6eea2017505d2a3ac82d372c33749b (patch) | |
tree | ae6a3181588da88fe5021aa4676f12f64828a653 | |
parent | 7e8e754a4b722216d18418b36c4b8976e7418f2b (diff) |
f2fs crypto: add alloc_bounce_page
This patch adds alloc_bounce_page likewise ext4.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/crypto.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/fs/f2fs/crypto.c b/fs/f2fs/crypto.c index 75d62fff8960..4a62ef14e932 100644 --- a/fs/f2fs/crypto.c +++ b/fs/f2fs/crypto.c | |||
@@ -376,6 +376,15 @@ static int f2fs_page_crypto(struct f2fs_crypto_ctx *ctx, | |||
376 | return 0; | 376 | return 0; |
377 | } | 377 | } |
378 | 378 | ||
379 | static struct page *alloc_bounce_page(struct f2fs_crypto_ctx *ctx) | ||
380 | { | ||
381 | ctx->w.bounce_page = mempool_alloc(f2fs_bounce_page_pool, GFP_NOWAIT); | ||
382 | if (ctx->w.bounce_page == NULL) | ||
383 | return ERR_PTR(-ENOMEM); | ||
384 | ctx->flags |= F2FS_WRITE_PATH_FL; | ||
385 | return ctx->w.bounce_page; | ||
386 | } | ||
387 | |||
379 | /** | 388 | /** |
380 | * f2fs_encrypt() - Encrypts a page | 389 | * f2fs_encrypt() - Encrypts a page |
381 | * @inode: The inode for which the encryption should take place | 390 | * @inode: The inode for which the encryption should take place |
@@ -405,19 +414,17 @@ struct page *f2fs_encrypt(struct inode *inode, | |||
405 | return (struct page *)ctx; | 414 | return (struct page *)ctx; |
406 | 415 | ||
407 | /* The encryption operation will require a bounce page. */ | 416 | /* The encryption operation will require a bounce page. */ |
408 | ciphertext_page = mempool_alloc(f2fs_bounce_page_pool, GFP_NOWAIT); | 417 | ciphertext_page = alloc_bounce_page(ctx); |
409 | if (!ciphertext_page) { | 418 | if (IS_ERR(ciphertext_page)) |
410 | err = -ENOMEM; | ||
411 | goto err_out; | 419 | goto err_out; |
412 | } | ||
413 | 420 | ||
414 | ctx->flags |= F2FS_WRITE_PATH_FL; | ||
415 | ctx->w.bounce_page = ciphertext_page; | ||
416 | ctx->w.control_page = plaintext_page; | 421 | ctx->w.control_page = plaintext_page; |
417 | err = f2fs_page_crypto(ctx, inode, F2FS_ENCRYPT, plaintext_page->index, | 422 | err = f2fs_page_crypto(ctx, inode, F2FS_ENCRYPT, plaintext_page->index, |
418 | plaintext_page, ciphertext_page); | 423 | plaintext_page, ciphertext_page); |
419 | if (err) | 424 | if (err) { |
425 | ciphertext_page = ERR_PTR(err); | ||
420 | goto err_out; | 426 | goto err_out; |
427 | } | ||
421 | 428 | ||
422 | SetPagePrivate(ciphertext_page); | 429 | SetPagePrivate(ciphertext_page); |
423 | set_page_private(ciphertext_page, (unsigned long)ctx); | 430 | set_page_private(ciphertext_page, (unsigned long)ctx); |
@@ -426,7 +433,7 @@ struct page *f2fs_encrypt(struct inode *inode, | |||
426 | 433 | ||
427 | err_out: | 434 | err_out: |
428 | f2fs_release_crypto_ctx(ctx); | 435 | f2fs_release_crypto_ctx(ctx); |
429 | return ERR_PTR(err); | 436 | return ciphertext_page; |
430 | } | 437 | } |
431 | 438 | ||
432 | /** | 439 | /** |