summaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-03-22 09:50:16 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2022-03-22 09:50:16 -0700
commit881b568756ae55ce7d87b9f001cbbe9d1289893e (patch)
treeef01162f9685a0560e6a732f62203140924d315b /fs/ext4/inode.c
parent0313bc278dac7cd9ce83a8d384581dc043156965 (diff)
parentcdaa1b1941f667814300799ddb74f3079517cd5a (diff)
downloadlinux-stable-881b568756ae55ce7d87b9f001cbbe9d1289893e.tar.gz
linux-stable-881b568756ae55ce7d87b9f001cbbe9d1289893e.tar.bz2
linux-stable-881b568756ae55ce7d87b9f001cbbe9d1289893e.zip
Merge tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt
Pull fscrypt updates from Eric Biggers: "Add support for direct I/O on encrypted files when blk-crypto (inline encryption) is being used for file contents encryption" * tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt: fscrypt: update documentation for direct I/O support f2fs: support direct I/O with fscrypt using blk-crypto ext4: support direct I/O with fscrypt using blk-crypto iomap: support direct I/O with fscrypt using blk-crypto fscrypt: add functions for direct I/O support
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 01c9e4f743ba..4cf55ef54193 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3409,6 +3409,13 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
if (ret < 0)
return ret;
out:
+ /*
+ * When inline encryption is enabled, sometimes I/O to an encrypted file
+ * has to be broken up to guarantee DUN contiguity. Handle this by
+ * limiting the length of the mapping returned.
+ */
+ map.m_len = fscrypt_limit_io_blocks(inode, map.m_lblk, map.m_len);
+
ext4_set_iomap(inode, iomap, &map, offset, length, flags);
return 0;