xfs: Do not unshare ranges beyond EOF
Subsystems (3)
PATCH 1/3 xfs: Do not unshare ranges beyond EOF
Attempting to unshare extents beyond EOF will trigger the need zeroing case, which in turn triggers a warning. Therefore, let's skip the unshare process if extents are beyond EOF.
--- fs/xfs/xfs_reflink.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/xfs/xfs_reflink.c +4 -0
@@ -3,6 +3,7 @@* Copyright (C) 2016 Oracle. All Rights Reserved. * Author: Darrick J. Wong <[email protected]> */ +#include "linux/fs.h" #include "xfs.h" #include "xfs_fs.h" #include "xfs_shared.h"
@@ -1669,6 +1670,9 @@ xfs_reflink_unshare(if (!xfs_is_reflink_inode (ip))return 0 ; +/* don't try to unshare any ranges beyond EOF. */ +if (offset + len >i_size_read (inode)) + len =i_size_read (inode) - offset;trace_xfs_reflink_unshare (ip, offset, len);
Signature · 1 line
2.39.2
kernel test robot
build botFYI: kernel test robot notices the stable kernel rule is not satisfied.
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH 1/3] xfs: Do not unshare ranges beyond EOF
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 19 lines · Julian Sun
Attempting to unshare extents beyond EOF will trigger the need zeroing case, which in turn triggers a warning. Therefore, let's skip the unshare process if extents are beyond EOF.
Reported-and-tested-by [email protected]Fixes 32a38a499104 ("iomap: use write_begin to read pages to unshare")Inspired-by Dave Chinner <[email protected]>Signed-off-by Julian Sun <[email protected]>--- fs/xfs/xfs_reflink.c | 4 ++++ 1 file changed, 4 insertions(+)fs/xfs/xfs_reflink.c +0
-0
fs/xfs/xfs_reflink.c line 6
Quoted 4 lines
fs/xfs/xfs_reflink.c +1
-0@@ -3,6 +3,7 @@* Copyright (C) 2016 Oracle. All Rights Reserved. * Author: Darrick J. Wong <[email protected]> */ +#include "linux/fs.h"
This really should not be needed (and is the wrong way to include non-local headers anyway).
fs/xfs/xfs_reflink.c xfs_reflink_unshare( · line 1675
Quoted 10 lines
fs/xfs/xfs_reflink.c +3
-0#include "xfs.h" #include "xfs_fs.h" #include "xfs_shared.h" @@ -1669,6 +1670,9 @@ xfs_reflink_unshare(if (!xfs_is_reflink_inode (ip))return 0 ; +/* don't try to unshare any ranges beyond EOF. */ +if (offset + len >i_size_read (inode)) + len =i_size_read (inode) - offset;
So i_size is a byte granularity value, but later on iomap_file_unshare operates on blocks. If you reduce the value like this here this means we can't ever unshare the last block of a file if the file size is not block aligned, which feels odd.
Quoted 16 lines · Christoph Hellwig <[email protected]> 于2024年9月20日周五 22:23写道:
Quoted 14 lines · Julian Sun
Attempting to unshare extents beyond EOF will trigger the need zeroing case, which in turn triggers a warning. Therefore, let's skip the unshare process if extents are beyond EOF.
Reported-and-tested-by [email protected]Fixes 32a38a499104 ("iomap: use write_begin to read pages to unshare")Inspired-by Dave Chinner <[email protected]>Signed-off-by Julian Sun <[email protected]>--- fs/xfs/xfs_reflink.c | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 12 lines
fs/xfs/xfs_reflink.c line 6
Quoted 9 lines
fs/xfs/xfs_reflink.c +1
-0@@ -3,6 +3,7 @@* Copyright (C) 2016 Oracle. All Rights Reserved. * Author: Darrick J. Wong <[email protected]> */ +#include "linux/fs.h" This really should not be needed (and is the wrong way to include non-local headers anyway).
Yes, it was added automatically by vscode... I will recheck the patch before sending it.
Quoted 6 lines
Quoted 6 lines
fs/xfs/xfs_reflink.c +0
-0#include "xfs.h" #include "xfs_fs.h" #include "xfs_shared.h" @@ -1669,6 +1670,9 @@ xfs_reflink_unshare(
Quoted 10 lines
fs/xfs/xfs_reflink.c xfs_reflink_unshare( · line 1675
Quoted 5 lines
fs/xfs/xfs_reflink.c +3
-0if (!xfs_is_reflink_inode (ip))return 0 ; +/* don't try to unshare any ranges beyond EOF. */ +if (offset + len >i_size_read (inode)) + len =i_size_read (inode) - offset;So
i_sizeis a byte granularity value, but later oniomap_file_unshareoperates on blocks. If you reduce the value like this here this means we can't ever unshare the last block of a file if the file size is not block aligned, which feels odd.
Got it, will fix it in patch v2. Thanks for your review and explantion.
Quoted 1 line
Thanks,
Signature · 1 line
Julian Sun <[email protected]>