summaryrefslogtreecommitdiffstats
path: root/fs/ext4/readpage.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/readpage.c')
-rw-r--r--fs/ext4/readpage.c45
1 files changed, 5 insertions, 40 deletions
diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c
index e24ec3bfe1b5..18b2cf23d40f 100644
--- a/fs/ext4/readpage.c
+++ b/fs/ext4/readpage.c
@@ -46,37 +46,6 @@
46 46
47#include "ext4.h" 47#include "ext4.h"
48 48
49/*
50 * Call ext4_decrypt on every single page, reusing the encryption
51 * context.
52 */
53static void completion_pages(struct work_struct *work)
54{
55#ifdef CONFIG_EXT4_FS_ENCRYPTION
56 struct ext4_crypto_ctx *ctx =
57 container_of(work, struct ext4_crypto_ctx, r.work);
58 struct bio *bio = ctx->r.bio;
59 struct bio_vec *bv;
60 int i;
61
62 bio_for_each_segment_all(bv, bio, i) {
63 struct page *page = bv->bv_page;
64
65 int ret = ext4_decrypt(page);
66 if (ret) {
67 WARN_ON_ONCE(1);
68 SetPageError(page);
69 } else
70 SetPageUptodate(page);
71 unlock_page(page);
72 }
73 ext4_release_crypto_ctx(ctx);
74 bio_put(bio);
75#else
76 BUG();
77#endif
78}
79
80static inline bool ext4_bio_encrypted(struct bio *bio) 49static inline bool ext4_bio_encrypted(struct bio *bio)
81{ 50{
82#ifdef CONFIG_EXT4_FS_ENCRYPTION 51#ifdef CONFIG_EXT4_FS_ENCRYPTION
@@ -104,14 +73,10 @@ static void mpage_end_io(struct bio *bio)
104 int i; 73 int i;
105 74
106 if (ext4_bio_encrypted(bio)) { 75 if (ext4_bio_encrypted(bio)) {
107 struct ext4_crypto_ctx *ctx = bio->bi_private;
108
109 if (bio->bi_error) { 76 if (bio->bi_error) {
110 ext4_release_crypto_ctx(ctx); 77 fscrypt_release_ctx(bio->bi_private);
111 } else { 78 } else {
112 INIT_WORK(&ctx->r.work, completion_pages); 79 fscrypt_decrypt_bio_pages(bio->bi_private, bio);
113 ctx->r.bio = bio;
114 queue_work(ext4_read_workqueue, &ctx->r.work);
115 return; 80 return;
116 } 81 }
117 } 82 }
@@ -274,11 +239,11 @@ int ext4_mpage_readpages(struct address_space *mapping,
274 bio = NULL; 239 bio = NULL;
275 } 240 }
276 if (bio == NULL) { 241 if (bio == NULL) {
277 struct ext4_crypto_ctx *ctx = NULL; 242 struct fscrypt_ctx *ctx = NULL;
278 243
279 if (ext4_encrypted_inode(inode) && 244 if (ext4_encrypted_inode(inode) &&
280 S_ISREG(inode->i_mode)) { 245 S_ISREG(inode->i_mode)) {
281 ctx = ext4_get_crypto_ctx(inode, GFP_NOFS); 246 ctx = fscrypt_get_ctx(inode, GFP_NOFS);
282 if (IS_ERR(ctx)) 247 if (IS_ERR(ctx))
283 goto set_error_page; 248 goto set_error_page;
284 } 249 }
@@ -286,7 +251,7 @@ int ext4_mpage_readpages(struct address_space *mapping,
286 min_t(int, nr_pages, BIO_MAX_PAGES)); 251 min_t(int, nr_pages, BIO_MAX_PAGES));
287 if (!bio) { 252 if (!bio) {
288 if (ctx) 253 if (ctx)
289 ext4_release_crypto_ctx(ctx); 254 fscrypt_release_ctx(ctx);
290 goto set_error_page; 255 goto set_error_page;
291 } 256 }
292 bio->bi_bdev = bdev; 257 bio->bi_bdev = bdev;