Patch "f2fs: fix to adjust appropriate length for fiemap" has been added to the 6.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    f2fs: fix to adjust appropriate length for fiemap

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     f2fs-fix-to-adjust-appropriate-length-for-fiemap.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 81e2825b514f3afa828b9682bda351ebc4a2bc06
Author: Zhiguo Niu <zhiguo.niu@xxxxxxxxxx>
Date:   Fri Nov 8 09:25:56 2024 +0800

    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@xxxxxxxxxx>
    Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx>
    Stable-dep-of: 6787a8224585 ("f2fs: fix to requery extent which cross boundary of inquiry")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 0f9728e0d5631..a126fecc808c4 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;
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index 3b2ad444c002e..c24f8bc01045d 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -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)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux