ANDROID: f2fs: fix fscrypt direct I/O support
The upstream change to make f2fs use iomap for direct I/O was backported
to this kernel branch, which broke the out-of-tree support for fscrypt
direct I/O because f2fs_iomap_begin() isn't aware of encryption. Make
the needed change to f2fs_iomap_begin(), matching what I've proposed
upstream at
https://lore.kernel.org/r/20220120071215.123274-5-ebiggers@kernel.org.
Also drop the fscrypt support from fs/direct-io.c, which is no longer
used since both ext4 and f2fs now use iomap for direct I/O.
Bug: 162255927
Bug: 215554521
Fixes: 9ce2897801
("Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-5.15.y' into android13-5.15")
Change-Id: I6b99b623ad3b8a86099c260787b2086b415a0e12
Signed-off-by: Eric Biggers <ebiggers@google.com>
This commit is contained in:
parent
f5ea50a85b
commit
0c339121fc
|
@ -24,7 +24,6 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/fscrypt.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/highmem.h>
|
||||
|
@ -393,7 +392,6 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio,
|
|||
sector_t first_sector, int nr_vecs)
|
||||
{
|
||||
struct bio *bio;
|
||||
struct inode *inode = dio->inode;
|
||||
|
||||
/*
|
||||
* bio_alloc() is guaranteed to return a bio when allowed to sleep and
|
||||
|
@ -401,9 +399,6 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio,
|
|||
*/
|
||||
bio = bio_alloc(GFP_KERNEL, nr_vecs);
|
||||
|
||||
fscrypt_set_bio_crypt_ctx(bio, inode,
|
||||
sdio->cur_page_fs_offset >> inode->i_blkbits,
|
||||
GFP_KERNEL);
|
||||
bio_set_dev(bio, bdev);
|
||||
bio->bi_iter.bi_sector = first_sector;
|
||||
bio_set_op_attrs(bio, dio->op, dio->op_flags);
|
||||
|
@ -770,17 +765,9 @@ static inline int dio_send_cur_page(struct dio *dio, struct dio_submit *sdio,
|
|||
* current logical offset in the file does not equal what would
|
||||
* be the next logical offset in the bio, submit the bio we
|
||||
* have.
|
||||
*
|
||||
* When fscrypt inline encryption is used, data unit number
|
||||
* (DUN) contiguity is also required. Normally that's implied
|
||||
* by logical contiguity. However, certain IV generation
|
||||
* methods (e.g. IV_INO_LBLK_32) don't guarantee it. So, we
|
||||
* must explicitly check fscrypt_mergeable_bio() too.
|
||||
*/
|
||||
if (sdio->final_block_in_bio != sdio->cur_page_block ||
|
||||
cur_offset != bio_next_offset ||
|
||||
!fscrypt_mergeable_bio(sdio->bio, dio->inode,
|
||||
cur_offset >> dio->inode->i_blkbits))
|
||||
cur_offset != bio_next_offset)
|
||||
dio_bio_submit(dio, sdio);
|
||||
}
|
||||
|
||||
|
|
|
@ -4079,6 +4079,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) {
|
||||
|
|
Loading…
Reference in New Issue