Skip to contentSkip to conversation

xfs: test changing UUID on V5 sueprblock

PATCH In review Eric Sandeen 2 participants 2 messages May 14, 2015 – May 19, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: test changing UUID on V5 sueprblock

Tests xfs_db's ability to change & restore UUIDs on V5 filesystems, and tests xfs_copy's ability to change the UUID on the copy.

Update to _filter_uuid is so that it will catch the UUID output from xfs_admin -u, which is slightly different than the regexp it was expecting.

This requires new userspace which knows how to change the UUID on a V5 superblock.

---

(I dunno, is 60s "quick?" - I could cut down the fsstress ops, just wanted to populate the fs w/ metadata).

common/filter +2 -2
index 05dbae6..8db1b3e 100644
@@ -275,9 +275,9 @@ _filter_uuid()
 {
 	if [ ! -z $1 ]; then
 		UUID=$1
-		sed -e "s/\(uuid:\) $UUID/\1 <EXACTUUID>/i"
+		sed -e "s/\(uuid[ :=]\+\) $UUID/\1 <EXACTUUID>/i"
 	else
-		sed -e "s/\(uuid:\) *[0-9a-f-][0-9a-f-]*/\1 <UUID>/i"
+		sed -e "s/\(uuid[ :=]\+\) *[0-9a-f-][0-9a-f-]*/\1 <UUID>/ig"
 	fi
 }
 
tests/xfs/074 new file +139 -0

139 lines not on this page · raw message

tests/xfs/074.out new file +21 -0
new file mode 100644
index 0000000..b511107
@@ -0,0 +1,21 @@
+QA output created by 074
+== Generate new UUID
+Clearing log and setting UUID
+writing all SBs
+new UUID =  <UUID>
+== Rewrite UUID
+old UUID = <EXACTUUID>
+Clearing log and setting UUID
+writing all SBs
+new UUID = <EXACTUUID>
+== Restore old UUID
+Clearing log and setting UUID
+writing all SBs
+new UUID = <EXACTUUID>
+== Rewrite UUID
+old UUID = <EXACTUUID>
+Clearing log and setting UUID
+writing all SBs
+new UUID = <EXACTUUID>
+== xfs_copy with new UUID
+== xfs_copy with duplicate UUID
tests/xfs/group +1 -0
index 58144d2..d1f6121 100644
@@ -70,6 +71,7 @@
 071 rw auto
 072 rw auto prealloc quick
 073 copy auto
+074 auto quick copy
 078 growfs auto quick
 080 rw ioctl
 081 deprecated # log logprint quota
#1 lore raw
Quoted 8 lines · Eric Sandeen

Tests xfs_db's ability to change & restore UUIDs on V5 filesystems, and tests xfs_copy's ability to change the UUID on the copy.

Update to _filter_uuid is so that it will catch the UUID output from xfs_admin -u, which is slightly different than the regexp it was expecting.

Quoted 9 lines

This requires new userspace which knows how to change the UUID on a V5 superblock.

---

(I dunno, is 60s "quick?" - I could cut down the fsstress ops, just wanted to populate the fs w/ metadata).

Seems a bit on the long side to me, but not that bad. Might be worth a try to cut the fsstress activity in half or so?

Quoted 81 lines
common/filter +2 -2
index 05dbae6..8db1b3e 100644
@@ -275,9 +275,9 @@ _filter_uuid()
 {
 	if [ ! -z $1 ]; then
 		UUID=$1
-		sed -e "s/\(uuid:\) $UUID/\1 <EXACTUUID>/i"
+		sed -e "s/\(uuid[ :=]\+\) $UUID/\1 <EXACTUUID>/i"
 	else
-		sed -e "s/\(uuid:\) *[0-9a-f-][0-9a-f-]*/\1 <UUID>/i"
+		sed -e "s/\(uuid[ :=]\+\) *[0-9a-f-][0-9a-f-]*/\1 <UUID>/ig"
 	fi
 }
 
tests/xfs/074 new file +59 -0
new file mode 100755
index 0000000..738050e
@@ -0,0 +1,139 @@
+#! /bin/bash
+# FS QA Test 074
+#
+# test UUID modification of CRC-enabled filesystems
+#
+# CRC-enabled / V5 superblock filesystems have a UUID stamped into
+# every piece of metadata, and a mechanism was added later to allow
+# changing the user-visible UUID by copying the original UUID (which
+# matches all the existing metadata) to a new superblock location.
+# Exercise some of that behavior.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Red Hat, Inc.  All Rights Reserved.
+#
+# 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"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+
+_supported_fs xfs
+_supported_os Linux
+_require_scratch
+_require_xfs_crc
+
+_fs_has_META_UUID()
+{
+	FS=$1
+	$XFS_DB_PROG -r -c version $FS | grep -q META_UUID

tests/xfs/074 line 69

Quoted 10 lines
tests/xfs/074 new file +10 -0
+}
+
+rm -f $seqres.full
+
+_scratch_mkfs_xfs -m crc=1 >> $seqres.full 2>&1 || _fail "mkfs failed"
+
+xfs_admin -U restore $SCRATCH_DEV 2>&1 | \
+	grep -q "invalid UUID\|supported on V5 fs" && \
+		_notrun "Userspace does not support V5 super UUID modifications"
+

Could we use $XFS_DB_PROG throughout the test so it's possible to modify the test environment?

Quoted 6 lines
tests/xfs/074 new file +6 -0
+ORIG_UUID=`xfs_admin -u $SCRATCH_DEV | awk '{print $NF}'`
+
+_scratch_mount
+# Put some stuff on the fs
+$FSSTRESS_PROG -d $SCRATCH_MNT -n 1000 -p 4 >> $seqres.full 2>&1
+_scratch_unmount

tests/xfs/074 line 85

Quoted 10 lines
tests/xfs/074 new file +10 -0
+
+# Can xfs_db change it?
+
+echo "== Generate new UUID"
+xfs_admin -U generate $SCRATCH_DEV | _filter_uuid 
+NEW_UUID=`xfs_admin -u $SCRATCH_DEV | awk '{print $NF}'`
+[ "$NEW_UUID" == "$ORIG_UUID" ] && _fail "Failed to change UUID"
+_check_scratch_fs
+_scratch_mount || _notrun "Mount failed; no META_UUID kernel support?"
+_scratch_unmount

Could we define a helper somewhere in common/ that determines whether this works (e.g., change the uuid and mount)? Then this check can be a less ambiguous failure and we wouldn't run part of the test in the case where it's not supported.

tests/xfs/074 line 95

Quoted 10 lines
tests/xfs/074 new file +10 -0
+_fs_has_META_UUID $SCRATCH_DEV || _fail "META_UUID feature not set"
+
+# This should be a no-op
+echo "== Rewrite UUID"
+xfs_admin -U rewrite $SCRATCH_DEV | _filter_uuid $NEW_UUID
+_check_scratch_fs
+_scratch_mount || _fail "Mount failed after UUID rewrite"
+_scratch_unmount
+_fs_has_META_UUID $SCRATCH_DEV || _fail "META_UUID feature not set"
+

I also wonder if these hunks could be genericized a bit into a helper function above..? E.g., something invoked like:

echo "== Rewrite UUID"
_test_uuid "rewrite" $UUID_FILTER
_fs_has_META_UUID $SCRATCH_DEV || _fail "META_UUID feature not set"

... or maybe it could also return the current post-command uuid to support the explicit uuid checks as well. Just a thought, it might or might not be a worthwhile cleanup...

Quoted 21 lines
tests/xfs/074 new file +21 -0
+# Can we change it back?
+echo "== Restore old UUID"
+xfs_admin -U restore $SCRATCH_DEV | _filter_uuid $ORIG_UUID
+NEW_UUID=`xfs_admin -u $SCRATCH_DEV | awk '{print $NF}'`
+[ "$NEW_UUID" != "$ORIG_UUID" ] && _fail "Failed to restore UUID"
+_check_scratch_fs
+_scratch_mount || _fail "Mount failed after UUID restore"
+_scratch_unmount
+_fs_has_META_UUID $SCRATCH_DEV &&  _fail "META_UUID feature should not be not set"
+
+# This should be a no-op too.
+echo "== Rewrite UUID"
+xfs_admin -U rewrite $SCRATCH_DEV | _filter_uuid  $ORIG_UUID
+_check_scratch_fs
+_scratch_mount || _fail "Mount failed after UUID rewrite"
+_scratch_unmount
+_fs_has_META_UUID $SCRATCH_DEV && _fail "META_UUID feature should not be not set"
+
+# Ok, now what does xfs_copy do; it changes UUID by default
+
+IMGFILE=$TEST_DIR/$seq.copy.img

tests/xfs/074 line 126

Quoted 10 lines
tests/xfs/074 new file +10 -0
+rm -f $IMGFILE
+
+# xfs_copy changes the UUID by default
+echo "== xfs_copy with new UUID"
+$XFS_COPY_PROG $SCRATCH_DEV $IMGFILE 2>&1 >> $seqres.full || \
+	_fail "xfs_copy (new UUID) failed"
+_check_xfs_filesystem $IMGFILE none none || _fail "Copy looks corrupted"
+# The copy should have META_UUID feature set
+_fs_has_META_UUID $IMGFILE || _fail "META_UUID feature not set on copy"
+

I suppose repair might be sufficient, but a mount check of the copy target couldn't hurt here as well.

Brian

Quoted 57 lines
tests/xfs/074 new file +13 -0
+rm -f $IMGFILE
+
+# duplicating the UUID should be fine too
+echo "== xfs_copy with duplicate UUID"
+$XFS_COPY_PROG -d $SCRATCH_DEV $IMGFILE 2>&1 >> $seqres.full || \
+	_fail "xfs_copy (duplicate) failed"
+_check_xfs_filesystem $IMGFILE none none || _fail "Duplicate copy looks corrupted"
+# The copy should not have META_UUID feature set
+_fs_has_META_UUID $IMGFILE && _fail "META_UUID feature should not be set on copy"
+
+# success, all done
+status=0
+exit
tests/xfs/074.out new file +21 -0
new file mode 100644
index 0000000..b511107
@@ -0,0 +1,21 @@
+QA output created by 074
+== Generate new UUID
+Clearing log and setting UUID
+writing all SBs
+new UUID =  <UUID>
+== Rewrite UUID
+old UUID = <EXACTUUID>
+Clearing log and setting UUID
+writing all SBs
+new UUID = <EXACTUUID>
+== Restore old UUID
+Clearing log and setting UUID
+writing all SBs
+new UUID = <EXACTUUID>
+== Rewrite UUID
+old UUID = <EXACTUUID>
+Clearing log and setting UUID
+writing all SBs
+new UUID = <EXACTUUID>
+== xfs_copy with new UUID
+== xfs_copy with duplicate UUID
tests/xfs/group +1 -1
index 58144d2..d1f6121 100644
@@ -70,6 +71,7 @@
 071 rw auto
 072 rw auto prealloc quick
 073 copy auto
+074 auto quick copy
 078 growfs auto quick
 080 rw ioctl
 081 deprecated # log logprint quota
 
--

To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html