@@ -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;
@@ -24,6 +24,7 @@
#define NEW_ADDR ((block_t)-1) /* used as block_t addresses */
#define COMPRESS_ADDR ((block_t)-2) /* used as compressed data flag */
+#define F2FS_BLKSIZE_MASK (F2FS_BLKSIZE - 1)
#define F2FS_BYTES_TO_BLK(bytes) ((unsigned long long)(bytes) >> F2FS_BLKSIZE_BITS)
#define F2FS_BLK_TO_BYTES(blk) ((unsigned long long)(blk) << F2FS_BLKSIZE_BITS)
#define F2FS_BLK_END_BYTES(blk) (F2FS_BLK_TO_BYTES(blk + 1) - 1)