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: use a byte granularity cursor in ext4_mpage_readpages

Replace the next_block variable that is in units of file system blocks
and incorrectly uses the sector_t type with a byte offset, as that is
what both users want.

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

authored by

Christoph Hellwig and committed by
Eric Biggers
4377a22d 5ca1a1f0

+5 -6
+5 -6
fs/ext4/readpage.c
··· 215 215 sector_t last_block_in_bio = 0; 216 216 const unsigned blkbits = inode->i_blkbits; 217 217 const unsigned blocksize = 1 << blkbits; 218 - sector_t next_block; 219 218 sector_t block_in_file; 220 219 sector_t last_block; 221 220 sector_t last_block_in_file; 222 221 sector_t first_block; 222 + loff_t pos; 223 223 unsigned page_block; 224 224 struct block_device *bdev = inode->i_sb->s_bdev; 225 225 int length; ··· 249 249 250 250 blocks_per_folio = folio_size(folio) >> blkbits; 251 251 first_hole = blocks_per_folio; 252 - block_in_file = next_block = EXT4_PG_TO_LBLK(inode, folio->index); 252 + pos = folio_pos(folio); 253 + block_in_file = pos >> blkbits; 253 254 last_block = EXT4_PG_TO_LBLK(inode, folio->index + nr_pages); 254 255 last_block_in_file = (ext4_readpage_limit(inode) + 255 256 blocksize - 1) >> blkbits; ··· 343 342 * BIO off first? 344 343 */ 345 344 if (bio && (last_block_in_bio != first_block - 1 || 346 - !fscrypt_mergeable_bio(bio, inode, 347 - (loff_t)next_block << blkbits))) { 345 + !fscrypt_mergeable_bio(bio, inode, pos))) { 348 346 submit_and_realloc: 349 347 blk_crypto_submit_bio(bio); 350 348 bio = NULL; ··· 355 355 */ 356 356 bio = bio_alloc(bdev, bio_max_segs(nr_pages), 357 357 REQ_OP_READ, GFP_KERNEL); 358 - fscrypt_set_bio_crypt_ctx(bio, inode, 359 - (loff_t)next_block << blkbits, GFP_KERNEL); 358 + fscrypt_set_bio_crypt_ctx(bio, inode, pos, GFP_KERNEL); 360 359 ext4_set_bio_post_read_ctx(bio, inode, vi); 361 360 bio->bi_iter.bi_sector = first_block << (blkbits - 9); 362 361 bio->bi_end_io = mpage_end_io;