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.

ext4, fscrypt: merge fscrypt_mergeable_bio_bh into io_submit_need_new_bio

ext4 already has the inode and folio and can't have a NULL
folio->mapping in this path. Open code fscrypt_mergeable_bio_bh in
io_submit_need_new_bio based on these simplifying assumptions.

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

authored by

Christoph Hellwig and committed by
Eric Biggers
588e7c04 5f18a9d2

+5 -34
-23
fs/crypto/inline_crypt.c
··· 407 407 EXPORT_SYMBOL_GPL(fscrypt_mergeable_bio); 408 408 409 409 /** 410 - * fscrypt_mergeable_bio_bh() - test whether data can be added to a bio 411 - * @bio: the bio being built up 412 - * @next_bh: the next buffer_head for which I/O will be submitted 413 - * 414 - * Same as fscrypt_mergeable_bio(), except this takes a buffer_head instead of 415 - * an inode and block number directly. 416 - * 417 - * Return: true iff the I/O is mergeable 418 - */ 419 - bool fscrypt_mergeable_bio_bh(struct bio *bio, 420 - const struct buffer_head *next_bh) 421 - { 422 - const struct inode *inode; 423 - u64 next_lblk; 424 - 425 - if (!bh_get_inode_and_lblk_num(next_bh, &inode, &next_lblk)) 426 - return !bio->bi_crypt_context; 427 - 428 - return fscrypt_mergeable_bio(bio, inode, next_lblk); 429 - } 430 - EXPORT_SYMBOL_GPL(fscrypt_mergeable_bio_bh); 431 - 432 - /** 433 410 * fscrypt_dio_supported() - check whether DIO (direct I/O) is supported on an 434 411 * inode, as far as encryption is concerned 435 412 * @inode: the inode in question
+5 -2
fs/ext4/page-io.c
··· 440 440 } 441 441 442 442 static bool io_submit_need_new_bio(struct ext4_io_submit *io, 443 + struct inode *inode, 444 + struct folio *folio, 443 445 struct buffer_head *bh) 444 446 { 445 447 if (bh->b_blocknr != io->io_next_block) 446 448 return true; 447 - if (!fscrypt_mergeable_bio_bh(io->io_bio, bh)) 449 + if (!fscrypt_mergeable_bio(io->io_bio, inode, 450 + (folio_pos(folio) + bh_offset(bh)) >> inode->i_blkbits)) 448 451 return true; 449 452 return false; 450 453 } ··· 458 455 struct folio *io_folio, 459 456 struct buffer_head *bh) 460 457 { 461 - if (io->io_bio && io_submit_need_new_bio(io, bh)) { 458 + if (io->io_bio && io_submit_need_new_bio(io, inode, folio, bh)) { 462 459 submit_and_retry: 463 460 ext4_io_submit(io); 464 461 }
-9
include/linux/fscrypt.h
··· 876 876 bool fscrypt_mergeable_bio(struct bio *bio, const struct inode *inode, 877 877 u64 next_lblk); 878 878 879 - bool fscrypt_mergeable_bio_bh(struct bio *bio, 880 - const struct buffer_head *next_bh); 881 - 882 879 bool fscrypt_dio_supported(struct inode *inode); 883 880 884 881 u64 fscrypt_limit_io_blocks(const struct inode *inode, u64 lblk, u64 nr_blocks); ··· 899 902 static inline bool fscrypt_mergeable_bio(struct bio *bio, 900 903 const struct inode *inode, 901 904 u64 next_lblk) 902 - { 903 - return true; 904 - } 905 - 906 - static inline bool fscrypt_mergeable_bio_bh(struct bio *bio, 907 - const struct buffer_head *next_bh) 908 905 { 909 906 return true; 910 907 }