[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250912023027.2526939-1-chao@kernel.org>
Date: Fri, 12 Sep 2025 10:30:27 +0800
From: Chao Yu <chao@...nel.org>
To: jaegeuk@...nel.org
Cc: linux-f2fs-devel@...ts.sourceforge.net,
linux-kernel@...r.kernel.org,
Chao Yu <chao@...nel.org>
Subject: [PATCH] f2fs: fix to update map->m_next_extent correctly in f2fs_map_blocks()
mkfs.f2fs -O extra_attr,compression /dev/vdb -f
mount /dev/vdb /mnt/f2fs -o mode=lfs,noextent_cache
cd /mnt/f2fs
f2fs_io write 1 0 1024 rand dsync testfile
xfs_io testfile -c "fsync"
f2fs_io write 1 0 512 rand dsync testfile
xfs_io testfile -c "fsync"
cd /
umount /mnt/f2fs
mount /dev/vdb /mnt/f2fs
f2fs_io precache_extents /mnt/f2fs/testfile
umount /mnt/f2fs
f2fs_io-760 [028] ..... 407.418603: f2fs_update_read_extent_tree_range: dev = (253,16), ino = 4, pgofs = 0, len = 512, blkaddr = 1055744, c_len = 0
f2fs_io-760 [028] ..... 407.418613: f2fs_update_read_extent_tree_range: dev = (253,16), ino = 4, pgofs = 513, len = 351, blkaddr = 17921, c_len = 0
f2fs_io-760 [028] ..... 407.418770: f2fs_update_read_extent_tree_range: dev = (253,16), ino = 4, pgofs = 864, len = 160, blkaddr = 18272, c_len = 0
During precache_extents, there is off-by-one issue, we should update
map->m_next_extent to pgofs rather than pgofs + 1, if last blkaddr is
valid and not contiguous to previous extent.
Fixes: c4020b2da4c9 ("f2fs: support F2FS_IOC_PRECACHE_EXTENTS")
Signed-off-by: Chao Yu <chao@...nel.org>
---
fs/f2fs/data.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index c4d80bffb559..35408f8c3d1c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1788,8 +1788,11 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)
start_pgofs, map->m_pblk + ofs,
map->m_len - ofs);
}
- if (map->m_next_extent)
- *map->m_next_extent = pgofs + 1;
+ if (map->m_next_extent) {
+ *map->m_next_extent = pgofs;
+ if (!__is_valid_data_blkaddr(blkaddr))
+ *map->m_next_extent += 1;
+ }
}
f2fs_put_dnode(&dn);
unlock_out:
--
2.49.0
Powered by blists - more mailing lists