_scratch_xfs_db "${cmds[@]}" -c print | __filter_xfs_db_print_fields "${filter}"
}
-# Get a metadata field
-# The first arg is the field name
-# The rest of the arguments are xfs_db commands to find the metadata.
-_scratch_xfs_get_metadata_field() {
- key="$1"
- shift
-
- grep_key="$(echo "${key}" | tr '[]()' '....')"
- local cmds=()
- for arg in "$@"; do
- cmds+=("-c" "${arg}")
- done
- _scratch_xfs_db "${cmds[@]}" -c "print ${key}" | grep "^${grep_key}" | \
- sed -e 's/^.* = //g'
-}
-
-# Set a metadata field
-# The first arg is the field name
-# The second arg is the new value
-# The rest of the arguments are xfs_db commands to find the metadata.
-_scratch_xfs_set_metadata_field() {
- key="$1"
- value="$2"
- shift; shift
-
- local cmds=()
- for arg in "$@"; do
- cmds+=("-c" "${arg}")
- done
- _scratch_xfs_db -x "${cmds[@]}" -c "write -d ${key} ${value}"
- echo
-}
-
# Fuzz a metadata field
# The first arg is the field name
# The second arg is the xfs_db fuzz verb
for arg in "$@"; do
cmds+=("-c" "${arg}")
done
- _scratch_xfs_db -x "${cmds[@]}" -c "fuzz ${fuzz_arg} ${key} ${value}"
- echo
- newval="$(_scratch_xfs_get_metadata_field "${key}" "$@" 2> /dev/null)"
+ while true; do
+ _scratch_xfs_db -x "${cmds[@]}" -c "fuzz ${fuzz_arg} ${key} ${value}"
+ echo
+ newval="$(_scratch_xfs_get_metadata_field "${key}" "$@" 2> /dev/null)"
+ if [ "${key}" != "random" ] || [ "${oldval}" != "${newval}" ]; then
+ break;
+ fi
+ done
if [ "${oldval}" = "${newval}" ]; then
echo "Field ${key} already set to ${newval}, skipping test."
return 1
# Try fixing the filesystem online?!
if [ "${repair}" = "online" ] || [ "${repair}" = "both" ]; then
__fuzz_notify "++ Try to repair filesystem online"
- _scratch_scrub -y 2>&1
+ _scratch_scrub 2>&1
res=$?
test $res -ne 0 && \
(>&2 echo "online repair failed ($res) with ${field} = ${fuzzverb}.")