]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
fstests: test xfs_copy V5 XFS without -d option
authorZorro Lang <zlang@redhat.com>
Tue, 8 Nov 2016 05:33:50 +0000 (13:33 +0800)
committerEryu Guan <eguan@redhat.com>
Sun, 13 Nov 2016 06:01:06 +0000 (14:01 +0800)
Before xfsprogs commit a872b62 (xfs_copy: band-aids for CRC
filesystems), xfs_copy requires the "-d" option to copy a V5 XFS,
because it can't rewrite the UUID of V5 XFS properly.

Now xfs_copy already full support to copy a V5 XFS. But for above
old problem, xfstests use below patch to make sure xfs_copy always
use "-d" option to copy a V5 XFS:

  8346e53 common: append -d option to XFS_COPY_PROG when testing v5 xfs

That cause xfstests miss the coverage of copying a V5 XFS without
"-d". For test this feature I did below things:

  1. Changed init_rc(), add "-d" to $XFS_COPY_PROG if xfs_copy can't
     copy a V5 XFS properly.
  2. xfs/073 test V4 xfs forcibly by specify "-m crc=0" in case. I
     think it's useless now, so remove it.
  3. Changed xfs/032. If xfs_copy full support to copy a V5 XFS, test
     with and without "-d" option, or only test with "-d" option.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/rc
tests/xfs/032
tests/xfs/073

index f33bbc6a1d5d56170a988810223908aa4e514ffd..20675fb991a9fee70487835a16cf3122d99f076a 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -3819,9 +3819,17 @@ init_rc()
        $XFS_IO_PROG -i -c quit 2>/dev/null && \
                export XFS_IO_PROG="$XFS_IO_PROG -i"
 
-       # xfs_copy doesn't work on v5 xfs yet without -d option
-       if [ "$FSTYP" == "xfs" ] && [[ $MKFS_OPTIONS =~ crc=1 ]]; then
-               export XFS_COPY_PROG="$XFS_COPY_PROG -d"
+       # xfs_copy on v5 filesystems do not require the "-d" option if xfs_db
+       # can change the UUID on v5 filesystems
+       if [ "$FSTYP" == "xfs" ]; then
+               touch /tmp/$$.img
+               $MKFS_XFS_PROG -d file,name=/tmp/$$.img,size=512m >/dev/null 2>&1
+               # xfs_db will return 0 even if it can't generate a new uuid, so
+               # check the output to make sure if it can change UUID of V5 xfs
+               $XFS_DB_PROG -x -c "uuid generate" /tmp/$$.img \
+                       | grep -q "invalid UUID\|supported on V5 fs" \
+                       && export XFS_COPY_PROG="$XFS_COPY_PROG -d"
+               rm -f /tmp/$$.img
        fi
 }
 
index 4b675ee30c3612497d3cb99db379f9670e0bfc36..6d644ad86a68cefcfe3f542f051172028c0c4f1d 100755 (executable)
@@ -53,6 +53,17 @@ IMGFILE=$TEST_DIR/${seq}_copy.img
 
 echo "Silence is golden."
 
+do_copy()
+{
+       local opts="$*"
+
+       $XFS_COPY_PROG $opts $SCRATCH_DEV $IMGFILE >> $seqres.full 2>&1 || \
+               _fail "xfs_copy $opts failed for Sector size $SECTORSIZE Block size $BLOCKSIZE"
+       # Must use "-n" to get exit code; without it xfs_repair always returns 0
+       $XFS_REPAIR_PROG -n -f $IMGFILE >> $seqres.full 2>&1 || \
+               _fail "xfs_copy $opts corrupted for Sector size $SECTORSIZE Block size $BLOCKSIZE"
+}
+
 while [ $SECTORSIZE -le $PAGESIZE ]; do
        BLOCKSIZE=$SECTORSIZE;
 
@@ -70,11 +81,11 @@ while [ $SECTORSIZE -le $PAGESIZE ]; do
                $FSSTRESS_PROG -n 100 -d $SCRATCH_MNT >> $seqres.full 2>&1
                _scratch_unmount
 
-               $XFS_COPY_PROG -d $SCRATCH_DEV $IMGFILE >> $seqres.full 2>&1 || \
-                       _fail "Copy failed for Sector size $SECTORSIZE Block size $BLOCKSIZE"
-               # Must use "-n" to get exit code; without it xfs_repair always returns 0
-               $XFS_REPAIR_PROG -n -f $IMGFILE >> $seqres.full 2>&1 || \
-                       _fail "Copy corrupted for Sector size $SECTORSIZE Block size $BLOCKSIZE"
+               # Test "duplicate" copy at first, if $XFS_COPY_PROG won't do it.
+               if [[ ! "$XFS_COPY_PROG" =~ -d ]]; then
+                       do_copy -d
+               fi
+               do_copy
 
                BLOCKSIZE=$(($BLOCKSIZE * 2));
        done
index 9e292234350b0e16ee969cb3e412e25c04a22b91..7228dd92d6ae67c6c707a23a2f31e6704e8873e2 100755 (executable)
@@ -138,7 +138,7 @@ _require_loop
 
 rm -f $seqres.full
 
-_scratch_mkfs_xfs -m crc=0 -dsize=41m,agcount=2 >>$seqres.full 2>&1
+_scratch_mkfs_xfs -dsize=41m,agcount=2 >>$seqres.full 2>&1
 _scratch_mount 2>/dev/null || _fail "initial scratch mount failed"
 
 echo
@@ -158,11 +158,7 @@ _verify_copy $imgs.image $SCRATCH_DEV $SCRATCH_MNT
 
 echo 
 echo === copying scratch device to single target, large ro device
-mkfs_crc_opts="-m crc=0"
-if [ -n "$XFS_MKFS_HAS_NO_META_SUPPORT" ]; then
-       mkfs_crc_opts=""
-fi
-${MKFS_XFS_PROG} $mkfs_crc_opts -dfile,name=$imgs.source,size=100g \
+${MKFS_XFS_PROG} -dfile,name=$imgs.source,size=100g \
        | _filter_mkfs 2>/dev/null
 rmdir $imgs.source_dir 2>/dev/null
 mkdir $imgs.source_dir