[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1730354393-19672-2-git-send-email-zhiguo.niu@unisoc.com>
Date: Thu, 31 Oct 2024 13:59:53 +0800
From: Zhiguo Niu <zhiguo.niu@...soc.com>
To: <jaegeuk@...nel.org>, <chao@...nel.org>
CC: <linux-f2fs-devel@...ts.sourceforge.net>, <linux-kernel@...r.kernel.org>,
<niuzhiguo84@...il.com>, <zhiguo.niu@...soc.com>, <ke.wang@...soc.com>,
<Hao_hao.Wang@...soc.com>
Subject: [PATCH 2/2] f2fs: fix to adjust appropriate length for fiemap
If user give a file size as "length" parameter for fiemap
operations, but 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, please
note that this f2fs_io has been modified for testing.
./f2fs_io fiemap 0 19304 ylog/analyzer.py
Fiemap: offset = 0 len = 19304
logical addr. physical addr. length flags
0 0000000000000000 0000000020baa000 0000000000004000 00001000
1 0000000000004000 0000000020bae000 0000000000001000 00001001
after this patch:
./f2fs_io fiemap 0 19304 ylog/analyzer.py
Fiemap: offset = 0 len = 19304
logical addr. physical addr. length flags
0 0000000000000000 00000000315f3000 0000000000005000 00001000
Signed-off-by: Zhiguo Niu <zhiguo.niu@...soc.com>
---
f2fs_io has been modified for testing, the length for fiemap is
real file size, not block number
---
fs/f2fs/data.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 90fa8ab..8c9bb42 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1966,8 +1966,8 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
goto out;
}
- if (bytes_to_blks(inode, len) == 0)
- len = blks_to_bytes(inode, 1);
+ if (len & (blks_to_bytes(inode, 1) - 1))
+ len = round_up(len, blks_to_bytes(inode, 1));
start_blk = bytes_to_blks(inode, start);
last_blk = bytes_to_blks(inode, start + len - 1);
--
1.9.1
Powered by blists - more mailing lists