@@ -1914,6 +1914,39 @@ _scratch_xfs_find_agbtree_height() {
return 1
}
+# Find us the path to the inode containing a realtime btree with a specific
+# height.
+_scratch_xfs_find_rgbtree_height() {
+ local bt_type="$1"
+ local bt_height="$2"
+ local rgcount=$(_xfs_mount_rgcount $SCRATCH_DEV)
+ local path
+ local path_format
+ local bt_prefix
+
+ case "${bt_type}" in
+ "rmap")
+ path_format="/realtime/%u.rmap"
+ bt_prefix="u3.rtrmapbt"
+ ;;
+ *)
+ _fail "Don't know about rt btree ${bt_type}"
+ ;;
+ esac
+
+ for ((rgno = 0; rgno < rgcount; rgno++)); do
+ path="$(printf "${path_format}" "${rgno}")"
+ bt_level=$(_scratch_xfs_db -c "path -m ${path}" -c "p ${bt_prefix}.level" | awk '{print $3}')
+ # "level" is the actual level within the btree
+ if [ "${bt_level}" -eq "$((bt_height - 1))" ]; then
+ echo "${path}"
+ return 0
+ fi
+ done
+
+ return 1
+}
+
_require_xfs_mkfs_atomicswap()
{
# atomicswap can be activated on rmap or reflink filesystems.
@@ -26,10 +26,12 @@ _require_scratch_xfs_fuzz_fields
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
-inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'sb 0' 'addr rrmapino')
+path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \
+ _fail "could not find two-level rtrmapbt"
+inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path")
echo "Fuzz rtrmapbt recs"
-_scratch_xfs_fuzz_metadata '' 'offline' 'sb 0' 'addr rrmapino' "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full
+_scratch_xfs_fuzz_metadata '' 'offline' "path -m $path" "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full
echo "Done fuzzing rtrmapbt recs"
# success, all done
@@ -26,10 +26,12 @@ _require_scratch_xfs_fuzz_fields
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
-inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'sb 0' 'addr rrmapino')
+path="$(_scratch_xfs_find_rgbtree_height 'rmap' 1)" || \
+ _fail "could not find two-level rtrmapbt"
+inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path")
echo "Fuzz rtrmapbt recs"
-_scratch_xfs_fuzz_metadata '' 'online' 'sb 0' 'addr rrmapino' "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full
+_scratch_xfs_fuzz_metadata '' 'online' "path -m $path" "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full
echo "Done fuzzing rtrmapbt recs"
# success, all done
@@ -4,7 +4,7 @@
#
# FS QA Test No. 408
#
-# Populate a XFS filesystem and fuzz every rtrmapbt keyptr field.
+# Populate a XFS filesystem and fuzz every rtrmapbt key/pointer field.
# Use xfs_repair to fix the corruption.
#
. ./common/preamble
@@ -26,8 +26,11 @@ _require_scratch_xfs_fuzz_fields
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
+path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \
+ _fail "could not find two-level rtrmapbt"
+
echo "Fuzz rtrmapbt keyptrs"
-_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' 'sb 0' 'addr rrmapino' >> $seqres.full
+_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' "path -m $path" >> $seqres.full
echo "Done fuzzing rtrmapbt keyptrs"
# success, all done
@@ -4,7 +4,7 @@
#
# FS QA Test No. 409
#
-# Populate a XFS filesystem and fuzz every rtrmapbt keyptr field.
+# Populate a XFS filesystem and fuzz every rtrmapbt key/pointer field.
# Use xfs_scrub to fix the corruption.
#
. ./common/preamble
@@ -26,8 +26,11 @@ _require_scratch_xfs_fuzz_fields
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
+path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \
+ _fail "could not find two-level rtrmapbt"
+
echo "Fuzz rtrmapbt keyptrs"
-_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' 'sb 0' 'addr rrmapino' >> $seqres.full
+_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'online' "path -m $path" >> $seqres.full
echo "Done fuzzing rtrmapbt keyptrs"
# success, all done
@@ -27,10 +27,12 @@ _disable_dmesg_check
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
-inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'sb 0' 'addr rrmapino')
+path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \
+ _fail "could not find two-level rtrmapbt"
+inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path")
echo "Fuzz rtrmapbt recs"
-_scratch_xfs_fuzz_metadata '' 'none' 'sb 0' 'addr rrmapino' "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full
+_scratch_xfs_fuzz_metadata '' 'none' "path -m $path" "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full
echo "Done fuzzing rtrmapbt recs"
# success, all done
@@ -4,7 +4,7 @@
#
# FS QA Test No. 482
#
-# Populate a XFS filesystem and fuzz every rtrmapbt keyptr field.
+# Populate a XFS filesystem and fuzz every rtrmapbt key/pointer field.
# Do not fix the filesystem, to test metadata verifiers.
. ./common/preamble
@@ -27,8 +27,11 @@ _disable_dmesg_check
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
+path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \
+ _fail "could not find two-level rtrmapbt"
+
echo "Fuzz rtrmapbt keyptrs"
-_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' 'sb 0' 'addr rrmapino' >> $seqres.full
+_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' "path -m $path" >> $seqres.full
echo "Done fuzzing rtrmapbt keyptrs"
# success, all done