mirror of https://github.com/torvalds/linux.git
ext4: support large block size in ext4_readdir()
In ext4_readdir(), page_cache_sync_readahead() is used to readahead mapped physical blocks. With LBS support, this can lead to a negative right shift. To fix this, the page index is now calculated by first converting the physical block number (pblk) to a file position (pos) before converting it to a page index. Also, the correct number of pages to readahead is now passed. Signed-off-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Pankaj Raghav <p.raghav@samsung.com> Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com> Message-ID: <20251121090654.631996-9-libaokun@huaweicloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
6a28b5c990
commit
609c5e0081
|
|
@ -192,13 +192,13 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (err > 0) {
|
if (err > 0) {
|
||||||
pgoff_t index = map.m_pblk >>
|
pgoff_t index = map.m_pblk << inode->i_blkbits >>
|
||||||
(PAGE_SHIFT - inode->i_blkbits);
|
PAGE_SHIFT;
|
||||||
if (!ra_has_index(&file->f_ra, index))
|
if (!ra_has_index(&file->f_ra, index))
|
||||||
page_cache_sync_readahead(
|
page_cache_sync_readahead(
|
||||||
sb->s_bdev->bd_mapping,
|
sb->s_bdev->bd_mapping,
|
||||||
&file->f_ra, file,
|
&file->f_ra, file, index,
|
||||||
index, 1);
|
1 << EXT4_SB(sb)->s_min_folio_order);
|
||||||
file->f_ra.prev_pos = (loff_t)index << PAGE_SHIFT;
|
file->f_ra.prev_pos = (loff_t)index << PAGE_SHIFT;
|
||||||
bh = ext4_bread(NULL, inode, map.m_lblk, 0);
|
bh = ext4_bread(NULL, inode, map.m_lblk, 0);
|
||||||
if (IS_ERR(bh)) {
|
if (IS_ERR(bh)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue