Merge tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt
[sfrench/cifs-2.6.git] / fs / f2fs / data.c
index fc077bce679d9612aca4454f75e6f8f86df5d6d1..79c9ed74bd8bd402fee5f3ab5297c18259014b79 100644 (file)
@@ -4032,6 +4032,13 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 
        iomap->offset = blks_to_bytes(inode, map.m_lblk);
 
+       /*
+        * 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);
+
        if (map.m_flags & (F2FS_MAP_MAPPED | F2FS_MAP_UNWRITTEN)) {
                iomap->length = blks_to_bytes(inode, map.m_len);
                if (map.m_flags & F2FS_MAP_MAPPED) {