ext4: Set the bio REQ_NOENCRYPT flag
Sets the REQ_NOENCRYPT flag for I/O requests that ext4 has already
encrypted. Lower layers such as dm-crypt can observe that flag to
avoid encrypting again if that's how the user configures the
environment.
Change-Id: I62a93e480a9f5788070446bd94694dfb9f83c277
Signed-off-by: Michael Halcrow <mhalcrow@google.com>
Git-repo: https://android.googlesource.com/kernel/common/
Git-commit: 7af2a1358e1577379c04d08b5c1d2ac4565c9418
[stummala@codeaurora.org: resolve merge conflicts]
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c38245d..2e4428c 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1150,11 +1150,12 @@
if (!buffer_uptodate(bh) && !buffer_delay(bh) &&
!buffer_unwritten(bh) &&
(block_start < from || block_end > to)) {
- ll_rw_block(REQ_OP_READ, 0, 1, &bh);
- *wait_bh++ = bh;
decrypt = ext4_encrypted_inode(inode) &&
S_ISREG(inode->i_mode) &&
!fscrypt_using_hardware_encryption(inode);
+ ll_rw_block(REQ_OP_READ, (decrypt ? REQ_NOENCRYPT : 0),
+ 1, &bh);
+ *wait_bh++ = bh;
}
}
/*
@@ -3772,6 +3773,7 @@
struct inode *inode = mapping->host;
struct buffer_head *bh;
struct page *page;
+ bool decrypt;
int err = 0;
page = find_or_create_page(mapping, from >> PAGE_SHIFT,
@@ -3814,14 +3816,15 @@
if (!buffer_uptodate(bh)) {
err = -EIO;
- ll_rw_block(REQ_OP_READ, 0, 1, &bh);
+ decrypt = S_ISREG(inode->i_mode) &&
+ ext4_encrypted_inode(inode) &&
+ !fscrypt_using_hardware_encryption(inode);
+ ll_rw_block(REQ_OP_READ, (decrypt ? REQ_NOENCRYPT : 0), 1, &bh);
wait_on_buffer(bh);
/* Uhhuh. Read error. Complain and punt. */
if (!buffer_uptodate(bh))
goto unlock;
- if (S_ISREG(inode->i_mode) &&
- ext4_encrypted_inode(inode) &&
- !fscrypt_using_hardware_encryption(inode)) {
+ if (decrypt) {
/* We expect the key to be set. */
BUG_ON(!fscrypt_has_encryption_key(inode));
BUG_ON(blocksize != PAGE_SIZE);