[v2,13/14] ext4: decrypt only the needed block in __ext4_block_zero_page_range()
diff mbox series

Message ID 20190520162952.156212-14-ebiggers@kernel.org
State Accepted
Headers show
  • fscrypt, ext4: prepare for blocksize != PAGE_SIZE
Related show

Commit Message

Eric Biggers May 20, 2019, 4:29 p.m. UTC
From: Chandan Rajendra <chandan@linux.ibm.com>

In __ext4_block_zero_page_range(), only decrypt the block that actually
needs to be decrypted, rather than assuming blocksize == PAGE_SIZE and
decrypting the whole page.

This is in preparation for allowing encryption on ext4 filesystems with
blocksize != PAGE_SIZE.

Signed-off-by: Chandan Rajendra <chandan@linux.ibm.com>
(EB: rebase onto previous changes, improve the commit message, and use
Signed-off-by: Eric Biggers <ebiggers@google.com>
 fs/ext4/inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff mbox series

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 8b3ea9c8ac988..77c43c50e4580 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4075,9 +4075,8 @@  static int __ext4_block_zero_page_range(handle_t *handle,
 		if (S_ISREG(inode->i_mode) && IS_ENCRYPTED(inode)) {
 			/* We expect the key to be set. */
-			BUG_ON(blocksize != PAGE_SIZE);
-						page, PAGE_SIZE, 0));
+					page, blocksize, bh_offset(bh)));
 	if (ext4_should_journal_data(inode)) {