4 # test UUID modification of CRC-enabled filesystems
6 # CRC-enabled / V5 superblock filesystems have a UUID stamped into
7 # every piece of metadata, and a mechanism was added later to allow
8 # changing the user-visible UUID by copying the original UUID (which
9 # matches all the existing metadata) to a new superblock location.
10 # Exercise some of that behavior.
12 #-----------------------------------------------------------------------
13 # Copyright (c) 2015 Red Hat, Inc. All Rights Reserved.
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #-----------------------------------------------------------------------
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
36 status=1 # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
45 # get standard environment, filters and checks
49 # real QA test starts here
57 # Takes 2 args, 2nd optional:
58 # 1: generate, rewrite, or restore
59 # 2: Expected UUID after the action. Blank if new uuid generated
60 # After the action check the fs, and make sure it can be mounted
61 # Sets NEW_UUID to the resulting UUID.
67 _scratch_xfs_db -x -c "uuid $ACTION" \
68 | _filter_uuid $EXPECTED_UUID
69 NEW_UUID=`_scratch_xfs_db -c "uuid" | awk '{print $NF}'`
71 _scratch_mount || _fail "Mount failed after UUID $ACTION"
79 $XFS_DB_PROG -r -c version $FS | grep -q META_UUID
84 _scratch_mkfs_xfs -m crc=1 >> $seqres.full 2>&1 || _fail "mkfs failed"
86 ORIG_UUID=`_scratch_xfs_db -c "uuid" | awk '{print $NF}'`
89 # Put some stuff on the fs
90 $FSSTRESS_PROG -d $SCRATCH_MNT -n 100 -p 4 >> $seqres.full 2>&1
93 # Can xfs_db change it?
95 echo "== Generate new UUID"
97 [ "$NEW_UUID" == "$ORIG_UUID" ] && _fail "Failed to change UUID"
98 _fs_has_META_UUID $SCRATCH_DEV || _fail "META_UUID feature not set"
100 # This should be a no-op
101 echo "== Rewrite UUID"
102 _test_uuid rewrite $NEW_UUID
103 _fs_has_META_UUID $SCRATCH_DEV || _fail "META_UUID feature not set"
105 # Can we change it back?
106 echo "== Restore old UUID"
107 _test_uuid restore $ORIG_UUID
108 [ "$NEW_UUID" != "$ORIG_UUID" ] && _fail "Failed to restore UUID"
109 _fs_has_META_UUID $SCRATCH_DEV && _fail "META_UUID feature should not be not set"
111 # This should be a no-op too.
112 echo "== Rewrite UUID"
113 _test_uuid rewrite $ORIG_UUID
114 _fs_has_META_UUID $SCRATCH_DEV && _fail "META_UUID feature should not be not set"
116 # Ok, now what does xfs_copy do; it changes UUID by default
118 IMGFILE=$TEST_DIR/$seq.copy.img
121 # xfs_copy changes the UUID by default
122 echo "== xfs_copy with new UUID"
123 $XFS_COPY_PROG $SCRATCH_DEV $IMGFILE 2>&1 >> $seqres.full || \
124 _fail "xfs_copy (new UUID) failed"
125 _check_xfs_filesystem $IMGFILE none none || _fail "Copy looks corrupted"
126 # The copy should have META_UUID feature set
127 _fs_has_META_UUID $IMGFILE || _fail "META_UUID feature not set on copy"
128 _scratch_mount || _fail "Mount failed after UUID rewrite"
133 # duplicating the UUID should be fine too
134 echo "== xfs_copy with duplicate UUID"
135 $XFS_COPY_PROG -d $SCRATCH_DEV $IMGFILE 2>&1 >> $seqres.full || \
136 _fail "xfs_copy (duplicate) failed"
137 _check_xfs_filesystem $IMGFILE none none || _fail "Duplicate copy looks corrupted"
138 # The copy should not have META_UUID feature set
139 _fs_has_META_UUID $IMGFILE && _fail "META_UUID feature should not be set on copy"