diff options
author | Zhiguo Niu <zhiguo.niu@unisoc.com> | 2024-11-08 04:25:56 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-12-14 22:03:12 +0300 |
commit | e6a91ed4b9e5baffbf3c7f77a92381eb4730ed66 (patch) | |
tree | 93af033917d66d906862f6141decdcc399c972c4 /fs/f2fs | |
parent | 6358df316dd8f1fe1a2b3d4b2d6d6bc5acd02e21 (diff) | |
download | linux-e6a91ed4b9e5baffbf3c7f77a92381eb4730ed66.tar.xz |
f2fs: fix to adjust appropriate length for fiemap
[ Upstream commit 77569f785c8624fa4189795fb52e635a973672e5 ]
If user give a file size as "length" parameter for fiemap
operations, but if this size is non-block size aligned,
it will show 2 segments fiemap results even this whole file
is contiguous on disk, such as the following results:
./f2fs_io fiemap 0 19034 ylog/analyzer.py
Fiemap: offset = 0 len = 19034
logical addr. physical addr. length flags
0 0000000000000000 0000000020baa000 0000000000004000 00001000
1 0000000000004000 0000000020bae000 0000000000001000 00001001
after this patch:
./f2fs_io fiemap 0 19034 ylog/analyzer.py
Fiemap: offset = 0 len = 19034
logical addr. physical addr. length flags
0 0000000000000000 00000000315f3000 0000000000005000 00001001
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Stable-dep-of: 6787a8224585 ("f2fs: fix to requery extent which cross boundary of inquiry")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/data.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 0f9728e0d563..a126fecc808c 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1938,12 +1938,12 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, goto out; } - if (F2FS_BYTES_TO_BLK(len) == 0) - len = F2FS_BLKSIZE; - start_blk = F2FS_BYTES_TO_BLK(start); last_blk = F2FS_BYTES_TO_BLK(start + len - 1); + if (len & F2FS_BLKSIZE_MASK) + len = round_up(len, F2FS_BLKSIZE); + next: memset(&map, 0, sizeof(map)); map.m_lblk = start_blk; |