aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/page-io.c
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2016-07-10 14:01:03 -0400
committerTheodore Ts'o <tytso@mit.edu>2016-07-10 14:01:03 -0400
commita7550b30ab709ffb9bbe48669adf7d8556f3698f (patch)
tree5ed986d93b2df41cad68bdfa0851604bb039d1d1 /fs/ext4/page-io.c
parentff0031d848a0cd7002606f9feef958de8d5edf19 (diff)
ext4 crypto: migrate into vfs's crypto engine
This patch removes the most parts of internal crypto codes. And then, it modifies and adds some ext4-specific crypt codes to use the generic facility. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/page-io.c')
-rw-r--r--fs/ext4/page-io.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 2a01df9cc1c3..5ad05af51dd8 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -24,6 +24,7 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/backing-dev.h> 26#include <linux/backing-dev.h>
27#include <linux/fscrypto.h>
27 28
28#include "ext4_jbd2.h" 29#include "ext4_jbd2.h"
29#include "xattr.h" 30#include "xattr.h"
@@ -67,7 +68,6 @@ static void ext4_finish_bio(struct bio *bio)
67 struct page *page = bvec->bv_page; 68 struct page *page = bvec->bv_page;
68#ifdef CONFIG_EXT4_FS_ENCRYPTION 69#ifdef CONFIG_EXT4_FS_ENCRYPTION
69 struct page *data_page = NULL; 70 struct page *data_page = NULL;
70 struct ext4_crypto_ctx *ctx = NULL;
71#endif 71#endif
72 struct buffer_head *bh, *head; 72 struct buffer_head *bh, *head;
73 unsigned bio_start = bvec->bv_offset; 73 unsigned bio_start = bvec->bv_offset;
@@ -82,8 +82,7 @@ static void ext4_finish_bio(struct bio *bio)
82 if (!page->mapping) { 82 if (!page->mapping) {
83 /* The bounce data pages are unmapped. */ 83 /* The bounce data pages are unmapped. */
84 data_page = page; 84 data_page = page;
85 ctx = (struct ext4_crypto_ctx *)page_private(data_page); 85 fscrypt_pullback_bio_page(&page, false);
86 page = ctx->w.control_page;
87 } 86 }
88#endif 87#endif
89 88
@@ -113,8 +112,8 @@ static void ext4_finish_bio(struct bio *bio)
113 local_irq_restore(flags); 112 local_irq_restore(flags);
114 if (!under_io) { 113 if (!under_io) {
115#ifdef CONFIG_EXT4_FS_ENCRYPTION 114#ifdef CONFIG_EXT4_FS_ENCRYPTION
116 if (ctx) 115 if (data_page)
117 ext4_restore_control_page(data_page); 116 fscrypt_restore_control_page(data_page);
118#endif 117#endif
119 end_page_writeback(page); 118 end_page_writeback(page);
120 } 119 }
@@ -472,7 +471,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io,
472 gfp_t gfp_flags = GFP_NOFS; 471 gfp_t gfp_flags = GFP_NOFS;
473 472
474 retry_encrypt: 473 retry_encrypt:
475 data_page = ext4_encrypt(inode, page, gfp_flags); 474 data_page = fscrypt_encrypt_page(inode, page, gfp_flags);
476 if (IS_ERR(data_page)) { 475 if (IS_ERR(data_page)) {
477 ret = PTR_ERR(data_page); 476 ret = PTR_ERR(data_page);
478 if (ret == -ENOMEM && wbc->sync_mode == WB_SYNC_ALL) { 477 if (ret == -ENOMEM && wbc->sync_mode == WB_SYNC_ALL) {
@@ -510,7 +509,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io,
510 if (ret) { 509 if (ret) {
511 out: 510 out:
512 if (data_page) 511 if (data_page)
513 ext4_restore_control_page(data_page); 512 fscrypt_restore_control_page(data_page);
514 printk_ratelimited(KERN_ERR "%s: ret = %d\n", __func__, ret); 513 printk_ratelimited(KERN_ERR "%s: ret = %d\n", __func__, ret);
515 redirty_page_for_writepage(wbc, page); 514 redirty_page_for_writepage(wbc, page);
516 do { 515 do {