Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fscrypt: pass a byte offset to fscrypt_mergeable_bio

Logical offsets into an inode are usually expressed as bytes in the VFS.
Switch fscrypt_mergeable_bio to that convention.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20260302141922.370070-8-hch@lst.de
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

authored by

Christoph Hellwig and committed by
Eric Biggers
22be86a2 60b4fcb4

+12 -9
+2 -1
fs/crypto/bio.c
··· 100 100 len -= blocks_this_page; 101 101 lblk += blocks_this_page; 102 102 sector += (bytes_this_page >> SECTOR_SHIFT); 103 - if (!len || !fscrypt_mergeable_bio(bio, inode, lblk)) 103 + if (!len || !fscrypt_mergeable_bio(bio, inode, 104 + (loff_t)lblk << blockbits)) 104 105 break; 105 106 } 106 107
+3 -3
fs/crypto/inline_crypt.c
··· 316 316 * fscrypt_mergeable_bio() - test whether data can be added to a bio 317 317 * @bio: the bio being built up 318 318 * @inode: the inode for the next part of the I/O 319 - * @next_lblk: the next file logical block number in the I/O 319 + * @pos: the next file position (in bytes) in the I/O 320 320 * 321 321 * When building a bio which may contain data which should undergo inline 322 322 * encryption (or decryption) via fscrypt, filesystems should call this function ··· 334 334 * Return: true iff the I/O is mergeable 335 335 */ 336 336 bool fscrypt_mergeable_bio(struct bio *bio, const struct inode *inode, 337 - u64 next_lblk) 337 + loff_t pos) 338 338 { 339 339 const struct bio_crypt_ctx *bc = bio->bi_crypt_context; 340 340 const struct fscrypt_inode_info *ci; ··· 354 354 if (bc->bc_key != ci->ci_enc_key.blk_key) 355 355 return false; 356 356 357 - fscrypt_generate_dun(ci, next_lblk << inode->i_blkbits, next_dun); 357 + fscrypt_generate_dun(ci, pos, next_dun); 358 358 return bio_crypt_dun_is_contiguous(bc, bio->bi_iter.bi_size, next_dun); 359 359 } 360 360 EXPORT_SYMBOL_GPL(fscrypt_mergeable_bio);
+1 -1
fs/ext4/page-io.c
··· 447 447 if (bh->b_blocknr != io->io_next_block) 448 448 return true; 449 449 if (!fscrypt_mergeable_bio(io->io_bio, inode, 450 - (folio_pos(folio) + bh_offset(bh)) >> inode->i_blkbits)) 450 + folio_pos(folio) + bh_offset(bh))) 451 451 return true; 452 452 return false; 453 453 }
+2 -1
fs/ext4/readpage.c
··· 342 342 * BIO off first? 343 343 */ 344 344 if (bio && (last_block_in_bio != first_block - 1 || 345 - !fscrypt_mergeable_bio(bio, inode, next_block))) { 345 + !fscrypt_mergeable_bio(bio, inode, 346 + (loff_t)next_block << blkbits))) { 346 347 submit_and_realloc: 347 348 blk_crypto_submit_bio(bio); 348 349 bio = NULL;
+2 -1
fs/f2fs/data.c
··· 541 541 if (fio && fio->encrypted_page) 542 542 return !bio_has_crypt_ctx(bio); 543 543 544 - return fscrypt_mergeable_bio(bio, inode, next_idx); 544 + return fscrypt_mergeable_bio(bio, inode, 545 + (loff_t)next_idx << inode->i_blkbits); 545 546 } 546 547 547 548 void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, struct bio *bio,
+2 -2
include/linux/fscrypt.h
··· 870 870 gfp_t gfp_mask); 871 871 872 872 bool fscrypt_mergeable_bio(struct bio *bio, const struct inode *inode, 873 - u64 next_lblk); 873 + loff_t pos); 874 874 875 875 bool fscrypt_dio_supported(struct inode *inode); 876 876 ··· 889 889 890 890 static inline bool fscrypt_mergeable_bio(struct bio *bio, 891 891 const struct inode *inode, 892 - u64 next_lblk) 892 + loff_t pos) 893 893 { 894 894 return true; 895 895 }