]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
xfs/270: actually test log recovery with unknown rocompat features
authorDarrick J. Wong <djwong@kernel.org>
Tue, 29 Aug 2023 23:09:59 +0000 (16:09 -0700)
committerZorro Lang <zlang@kernel.org>
Wed, 20 Sep 2023 07:49:54 +0000 (15:49 +0800)
Make sure that log recovery will not succeed if there are unknown
rocompat features in the superblock and the log is dirty.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/xfs/270
tests/xfs/270.out

index 900ae5d5ab1bc36977e5d230723c292814b2b527..7d4e1f6a87414d63525c77034d081739137d1d47 100755 (executable)
@@ -23,41 +23,48 @@ _fixed_by_kernel_commit xxxxxxxxxxxx \
 _require_scratch_nocheck
 # Only V5 XFS disallow rw mount/remount with unknown ro-compat features
 _require_scratch_xfs_crc
-
-_scratch_mkfs_xfs >>$seqres.full 2>&1
-_scratch_mount
-echo moo > $SCRATCH_MNT/testfile
-_scratch_unmount
+_require_scratch_shutdown
 
 # set the highest bit of features_ro_compat, use it as an unknown
 # feature bit. If one day this bit become known feature, please
 # change this case.
+set_bad_rocompat() {
+       ro_compat=$(_scratch_xfs_get_metadata_field "features_ro_compat" "sb 0")
+       echo $ro_compat | grep -q -E '^0x[[:xdigit:]]$'
+       if [[ $? != 0  ]]; then
+               echo "features_ro_compat has an invalid value."
+               return 1
+       fi
 
-ro_compat=$(_scratch_xfs_get_metadata_field "features_ro_compat" "sb 0")
-echo $ro_compat | grep -q -E '^0x[[:xdigit:]]$'
-if [[ $? != 0  ]]; then
-       echo "features_ro_compat has an invalid value."
-fi
+       ro_compat=$(echo $ro_compat | \
+                           awk '/^0x[[:xdigit:]]+/ {
+                                       printf("0x%x\n", or(strtonum($1), 0x80000000))
+                               }')
 
-ro_compat=$(echo $ro_compat | \
-                   awk '/^0x[[:xdigit:]]+/ {
-                               printf("0x%x\n", or(strtonum($1), 0x80000000))
-                       }')
+       # write the new ro compat field to the superblock
+       _scratch_xfs_set_metadata_field "features_ro_compat" "$ro_compat" "sb 0" \
+                                       > $seqres.full 2>&1
 
-# write the new ro compat field to the superblock
-_scratch_xfs_set_metadata_field "features_ro_compat" "$ro_compat" "sb 0" \
-                               > $seqres.full 2>&1
+       # read the newly set ro compat filed for verification
+       new_ro_compat=$(_scratch_xfs_get_metadata_field "features_ro_compat" "sb 0" \
+                                                       2>/dev/null)
 
-# read the newly set ro compat filed for verification
-new_ro_compat=$(_scratch_xfs_get_metadata_field "features_ro_compat" "sb 0" \
-                                               2>/dev/null)
+       # verify the new ro_compat field is correct. Without xfsprogs commit
+       # f4afdcb0ad ("xfs_db: clean up the salvage read callsites in set_cur()"),
+       # we can't get new_ro_compat value.
+       if [ "$new_ro_compat" != "$ro_compat" ]; then
+               echo "Unable to set new features_ro_compat. Wanted $ro_compat, got $new_ro_compat"
+               return 1
+       fi
+       return 0
+}
 
-# verify the new ro_compat field is correct. Without xfsprogs commit
-# f4afdcb0ad ("xfs_db: clean up the salvage read callsites in set_cur()"),
-# we can't get new_ro_compat value.
-if [ "$new_ro_compat" != "$ro_compat" ]; then
-       echo "Unable to set new features_ro_compat. Wanted $ro_compat, got $new_ro_compat"
-fi
+# Once with a clean filesystem...
+_scratch_mkfs_xfs >>$seqres.full 2>&1
+_scratch_mount
+echo moo > $SCRATCH_MNT/testfile
+_scratch_unmount
+set_bad_rocompat
 
 # rw mount with unknown ro-compat feature should fail
 echo "rw mount test"
@@ -87,6 +94,29 @@ fi
 
 _scratch_unmount
 
+# And again with a dirty filesystem...
+_scratch_mkfs_xfs >>$seqres.full 2>&1
+_scratch_mount
+echo moo > $SCRATCH_MNT/testfile
+$XFS_IO_PROG -x -c 'shutdown -f' "${SCRATCH_MNT}"
+_scratch_unmount
+set_bad_rocompat
+
+# rw mount with unknown ro-compat feature should fail
+echo "rw mount test"
+_try_scratch_mount 2>>$seqres.full
+if [ $? -eq 0 ]; then
+       _fail "rw mount test failed"
+fi
+
+# ro mount should succeed even with log recovery
+echo "ro mount test"
+_try_scratch_mount -o ro 2>>$seqres.full
+if [ $? -ne 0 ]; then
+       _fail "ro mount test failed"
+fi
+cat $SCRATCH_MNT/testfile > /dev/null
+
 # success, all done
 status=0
 exit
index edf4c25489ff1493de9d4b16482a0bbe5c755917..a519d2f328fa462f80947694a70c6bbf0e7992d8 100644 (file)
@@ -2,3 +2,5 @@ QA output created by 270
 rw mount test
 ro mount test
 rw remount test
+rw mount test
+ro mount test