Message ID | 1443267613-9453-1-git-send-email-fdmanana@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Sat, Sep 26, 2015 at 12:40:13PM +0100, fdmanana@kernel.org wrote: > From: Filipe Manana <fdmanana@suse.com> > > Test that an incremental send works after a file from the parent snapshot > gets replaced in the send snapshot by another one at the same exact > location, with the same name and with the same inode number. > > This test used to fail after the linux kernel commit 8b191a684968 > ("Btrfs: incremental send, check if orphanized dir inode needs delayed > rename") and it's fixed by patch titled: > > "Btrfs: send, fix corner case for reference overwrite detection" I got "btrfs receive" error when testing this, with 4.3-rc1 kernel and btrfs-progs v4.2, not sure if this is expected At subvol /mnt/testarea/scratch/mysnap2_ro # /usr/bin/btrfs receive /mnt/testarea/scratch -f /mnt/testarea/test/btrfs-test-104/1.snap At subvol mysnap1 # /usr/bin/btrfs receive /mnt/testarea/scratch -f /mnt/testarea/test/btrfs-test-104/2.snap ERROR: unlink o258-7-0 failed. No such file or directory At snapshot mysnap2_ro failed: '/usr/bin/btrfs receive /mnt/testarea/scratch -f /mnt/testarea/test/btrfs-test-104/2.snap' Thanks, Eryu -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Sep 29, 2015 at 4:54 AM, Eryu Guan <eguan@redhat.com> wrote: > On Sat, Sep 26, 2015 at 12:40:13PM +0100, fdmanana@kernel.org wrote: >> From: Filipe Manana <fdmanana@suse.com> >> >> Test that an incremental send works after a file from the parent snapshot >> gets replaced in the send snapshot by another one at the same exact >> location, with the same name and with the same inode number. >> >> This test used to fail after the linux kernel commit 8b191a684968 >> ("Btrfs: incremental send, check if orphanized dir inode needs delayed >> rename") and it's fixed by patch titled: >> >> "Btrfs: send, fix corner case for reference overwrite detection" > > I got "btrfs receive" error when testing this, with 4.3-rc1 kernel and > btrfs-progs v4.2, not sure if this is expected Yes, it's expected. The fix isn't yet in any kernel release (nor rc). thanks > > At subvol /mnt/testarea/scratch/mysnap2_ro > # /usr/bin/btrfs receive /mnt/testarea/scratch -f /mnt/testarea/test/btrfs-test-104/1.snap > At subvol mysnap1 > # /usr/bin/btrfs receive /mnt/testarea/scratch -f /mnt/testarea/test/btrfs-test-104/2.snap > ERROR: unlink o258-7-0 failed. No such file or directory > At snapshot mysnap2_ro > failed: '/usr/bin/btrfs receive /mnt/testarea/scratch -f /mnt/testarea/test/btrfs-test-104/2.snap' > > Thanks, > Eryu -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Sep 29, 2015 at 09:33:34AM +0100, Filipe Manana wrote: > On Tue, Sep 29, 2015 at 4:54 AM, Eryu Guan <eguan@redhat.com> wrote: > > On Sat, Sep 26, 2015 at 12:40:13PM +0100, fdmanana@kernel.org wrote: > >> From: Filipe Manana <fdmanana@suse.com> > >> > >> Test that an incremental send works after a file from the parent snapshot > >> gets replaced in the send snapshot by another one at the same exact > >> location, with the same name and with the same inode number. > >> > >> This test used to fail after the linux kernel commit 8b191a684968 > >> ("Btrfs: incremental send, check if orphanized dir inode needs delayed > >> rename") and it's fixed by patch titled: > >> > >> "Btrfs: send, fix corner case for reference overwrite detection" > > > > I got "btrfs receive" error when testing this, with 4.3-rc1 kernel and > > btrfs-progs v4.2, not sure if this is expected > > Yes, it's expected. > The fix isn't yet in any kernel release (nor rc). Thanks for the clarification, I was somehow expecting a file md5 mismatch. Then the patch looks good to me. Reviewed-by: Eryu Guan <eguan@redhat.com> -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Sep 29, 2015 at 10:48 AM, Eryu Guan <eguan@redhat.com> wrote: > On Tue, Sep 29, 2015 at 09:33:34AM +0100, Filipe Manana wrote: >> On Tue, Sep 29, 2015 at 4:54 AM, Eryu Guan <eguan@redhat.com> wrote: >> > On Sat, Sep 26, 2015 at 12:40:13PM +0100, fdmanana@kernel.org wrote: >> >> From: Filipe Manana <fdmanana@suse.com> >> >> >> >> Test that an incremental send works after a file from the parent snapshot >> >> gets replaced in the send snapshot by another one at the same exact >> >> location, with the same name and with the same inode number. >> >> >> >> This test used to fail after the linux kernel commit 8b191a684968 >> >> ("Btrfs: incremental send, check if orphanized dir inode needs delayed >> >> rename") and it's fixed by patch titled: >> >> >> >> "Btrfs: send, fix corner case for reference overwrite detection" >> > >> > I got "btrfs receive" error when testing this, with 4.3-rc1 kernel and >> > btrfs-progs v4.2, not sure if this is expected >> >> Yes, it's expected. >> The fix isn't yet in any kernel release (nor rc). > > Thanks for the clarification, I was somehow expecting a file md5 mismatch. The expected failure is really btrfs receive to fail due to a an invalid path (file name) being sent by the kernel. The md5 digest check was added to the test just to verify that if the kernel generates the correct path, at the end of the test we get the correct file and not the old file (or something else due to some bug). > > Then the patch looks good to me. > > Reviewed-by: Eryu Guan <eguan@redhat.com> -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/tests/btrfs/104 b/tests/btrfs/104 new file mode 100755 index 0000000..df4d813 --- /dev/null +++ b/tests/btrfs/104 @@ -0,0 +1,112 @@ +#! /bin/bash +# FS QA Test No. btrfs/104 +# +# Test that an incremental send works after a file from the parent snapshot +# gets replaced in the send snapshot by another one at the same exact location, +# with the same name and with the same inode number. +# +#----------------------------------------------------------------------- +# Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved. +# Author: Filipe Manana <fdmanana@suse.com> +# Copyright (C) 2015 Martin Raiber <martin@urbackup.org> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -fr $send_files_dir + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs btrfs +_supported_os Linux +_require_scratch +_need_to_be_root + +send_files_dir=$TEST_DIR/btrfs-test-$seq + +rm -f $seqres.full +rm -fr $send_files_dir +mkdir $send_files_dir + +_scratch_mkfs >>$seqres.full 2>&1 +_scratch_mount + +# Create our test file with a single extent of 64K. +mkdir -p $SCRATCH_MNT/foo +$XFS_IO_PROG -f -c "pwrite -S 0xaa 0 64K" $SCRATCH_MNT/foo/bar | _filter_xfs_io + +_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1 +_run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/mysnap2 + +echo "File digest before being replaced:" +md5sum $SCRATCH_MNT/mysnap1/foo/bar | _filter_scratch + +# Remove the file and then create a new one in the same location with the same +# name but with different content. This new file ends up getting the same inode +# number as the previous one, because that inode number was the highest inode +# number used by the snapshot's root and therefore when attempting to find the +# a new inode number for the new file, we end up reusing the same inode number. +# This happens because currently btrfs uses the highest inode number summed by 1 +# for the first inode created once a snapshot's root is loaded (done at +# fs/btrfs/inode-map.c:btrfs_find_free_objectid in the linux kernel tree). +# Having these two different files in the snapshots with the same inode number +# (but different generation numbers) caused the btrfs send code to emit an +# incorrect path for the file when issuing an unlink operation because it failed +# to realize they were different files. +rm -f $SCRATCH_MNT/mysnap2/foo/bar +$XFS_IO_PROG -f -c "pwrite -S 0xbb 0 96K" \ + $SCRATCH_MNT/mysnap2/foo/bar | _filter_xfs_io + +_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT/mysnap2 \ + $SCRATCH_MNT/mysnap2_ro + +_run_btrfs_util_prog send $SCRATCH_MNT/mysnap1 -f $send_files_dir/1.snap +_run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 $SCRATCH_MNT/mysnap2_ro \ + -f $send_files_dir/2.snap + +echo "File digest in the original filesystem after being replaced:" +md5sum $SCRATCH_MNT/mysnap2_ro/foo/bar | _filter_scratch + +# Now recreate the filesystem by receiving both send streams and verify we get +# the same file contents that the original filesystem had. +_scratch_unmount +_scratch_mkfs >>$seqres.full 2>&1 +_scratch_mount + +_run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/1.snap +_run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/2.snap + +echo "File digest in the new filesystem:" +# Must match the digest from the new file. +md5sum $SCRATCH_MNT/mysnap2_ro/foo/bar | _filter_scratch + +status=0 +exit \ No newline at end of file diff --git a/tests/btrfs/104.out b/tests/btrfs/104.out new file mode 100644 index 0000000..ff3c001 --- /dev/null +++ b/tests/btrfs/104.out @@ -0,0 +1,11 @@ +QA output created by 104 +wrote 65536/65536 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +File digest before being replaced: +9802287a6faa01a1fd0e01732b732fca SCRATCH_MNT/mysnap1/foo/bar +wrote 98304/98304 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +File digest in the original filesystem after being replaced: +de277dfac706c359613033120349cf88 SCRATCH_MNT/mysnap2_ro/foo/bar +File digest in the new filesystem: +de277dfac706c359613033120349cf88 SCRATCH_MNT/mysnap2_ro/foo/bar diff --git a/tests/btrfs/group b/tests/btrfs/group index e92a65a..4d99714 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -106,3 +106,4 @@ 101 auto quick replace 102 auto quick metadata enospc 103 auto quick clone compress +104 auto quick send