Btrfs: can_nocow_file_extent should pass down args->strict from callers
PATCH 1/1 Btrfs: can_nocow_file_extent should pass down args->strict from callers
619104ba453ad0 changed our call to btrfs_cross_ref_exist() to always pass false for the 'strict' parameter. We're passing this down through the stack so that we can do a full check for cross references during swapfile activation.
With strict always false, this test fails:
btrfs subvol create swappy
chattr +C swappy
fallocate -l1G swappy/swapfile
chmod 600 swappy/swapfile
mkswap swappy/swapfile
btrfs subvol snap swappy swapsnap
btrfs subvol del -C swapsnap
btrfs fi sync /
sync;sync;sync
swapon swappy/swapfile
The fix is to just use args->strict, and everyone except swapfile activation is passing false.
--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
@@ -1864,7 +1864,7 @@ static int can_nocow_file_extent(struct btrfs_path *path, ret =btrfs_cross_ref_exist (root,btrfs_ino (inode), key->offset - args->extent_offset, - args->disk_bytenr, false, path); + args->disk_bytenr, args->strict, path);WARN_ON_ONCE (ret >0 && is_freespace_inode);if (ret !=0 ) goto out;
Signature · 1 line
2.34.1
Quoted 20 lines · Chris Mason
619104ba453ad0changed our call tobtrfs_cross_ref_exist()to always pass false for the 'strict' parameter. We're passing this down through the stack so that we can do a full check for cross references during swapfile activation.With strict always false, this test fails:
btrfs subvol create swappy
chattr +C swappy
fallocate -l1G swappy/swapfile
chmod 600 swappy/swapfile
mkswap swappy/swapfilebtrfs subvol snap swappy swapsnap
btrfs subvol del -C swapsnapbtrfs fi sync /
sync;sync;sync
Quoted 7 lines
swapon swappy/swapfile
The fix is to just use
args->strict, and everyone except swapfile activation is passing false.Fixes 619104ba453ad0 ("btrfs: move common NOCOW checks against a file extent into a helper")Signed-off-by Chris Mason <[email protected]>
Looks good, thanks.
Quoted 20 lines
--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/inode.c +1
-2@@ -1864,7 +1864,7 @@ static int can_nocow_file_extent(struct btrfs_path *path, ret =btrfs_cross_ref_exist (root,btrfs_ino (inode), key->offset - args->extent_offset, - args->disk_bytenr, false, path); + args->disk_bytenr, args->strict, path);WARN_ON_ONCE (ret >0 && is_freespace_inode);if (ret !=0 ) goto out; --2.34.1
Quoted 19 lines · Chris Mason
619104ba453ad0changed our call tobtrfs_cross_ref_exist()to always pass false for the 'strict' parameter. We're passing this down through the stack so that we can do a full check for cross references during swapfile activation.With strict always false, this test fails:
btrfs subvol create swappy
chattr +C swappy
fallocate -l1G swappy/swapfile
chmod 600 swappy/swapfile
mkswap swappy/swapfilebtrfs subvol snap swappy swapsnap
btrfs subvol del -C swapsnapbtrfs fi sync /
sync;sync;sync
Quoted 7 lines
swapon swappy/swapfile
The fix is to just use
args->strict, and everyone except swapfile activation is passing false.Fixes 619104ba453ad0 ("btrfs: move common NOCOW checks against a file extent into a helper")Signed-off-by Chris Mason <[email protected]>
Added to misc-next, thanks.
Quoted 14 lines · Chris Mason
619104ba453ad0changed our call tobtrfs_cross_ref_exist()to always pass false for the 'strict' parameter. We're passing this down through the stack so that we can do a full check for cross references during swapfile activation.With strict always false, this test fails:
btrfs subvol create swappy
chattr +C swappy
fallocate -l1G swappy/swapfile
chmod 600 swappy/swapfile
mkswap swappy/swapfile
Quoted 7 lines
btrfs subvol snap swappy swapsnap
btrfs subvol del -C swapsnapbtrfs fi sync /
sync;sync;syncswapon swappy/swapfile
Btw, I just sent a test case for this and to verify as well that we can't activate swap files if there are snapshots.
Clearly something we lacked test coverage.
Quoted 26 lines
The fix is to just use
args->strict, and everyone except swapfile activation is passing false.Fixes 619104ba453ad0 ("btrfs: move common NOCOW checks against a file extent into a helper")Signed-off-by Chris Mason <[email protected]>--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/inode.c +1
-2@@ -1864,7 +1864,7 @@ static int can_nocow_file_extent(struct btrfs_path *path, ret =btrfs_cross_ref_exist (root,btrfs_ino (inode), key->offset - args->extent_offset, - args->disk_bytenr, false, path); + args->disk_bytenr, args->strict, path);WARN_ON_ONCE (ret >0 && is_freespace_inode);if (ret !=0 ) goto out; --2.34.1