#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
+#
# FS QA Test No. 308
#
# Test recovery of "lost" CoW blocks:
# - Use the debugger to fake a leftover CoW extent
# - See if mount/umount fixes it
#
-#-----------------------------------------------------------------------
-# Copyright (c) 2016, Oracle and/or its affiliates. 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"
echo "Format"
_scratch_mkfs > $seqres.full 2>&1
_scratch_mount >> $seqres.full
-is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+is_rmap=$($XFS_INFO_PROG $SCRATCH_MNT | grep -c "rmapbt=1")
_scratch_unmount
_get_agf_data() {
field="$1"
shift
- xfs_db -c 'agf 1' "$@" -c "p $field" $SCRATCH_DEV | awk '{print $3}'
+ _scratch_xfs_db -c 'agf 1' "$@" -c "p $field" | awk '{print $3}'
}
_set_agf_data() {
value="$2"
shift; shift
- xfs_db -x -c 'agf 1' "$@" -c "write $field -- $value" $SCRATCH_DEV >> $seqres.full
+ _scratch_xfs_db -x -c 'agf 1' "$@" -c "write $field -- $value" >> $seqres.full
}
_get_sb_data() {
- field="$1"
- shift
-
- xfs_db -c 'sb 0' "$@" -c "p $field" $SCRATCH_DEV | awk '{print $3}'
+ _scratch_xfs_get_sb_field "$@"
}
_set_sb_data() {
- field="$1"
- value="$2"
- shift; shift
-
- xfs_db -x -c 'sb 0' "$@" -c "write $field -- $value" $SCRATCH_DEV >> $seqres.full
+ _scratch_xfs_set_sb_field "$@" >> $seqres.full
}
_filter_leftover() {
_dump_status() {
echo "** " "$@"
- xfs_db -c 'sb 0' -c p $SCRATCH_DEV
+ _scratch_xfs_db -c 'sb 0' -c p
echo "** agf header"
- xfs_db -c 'agf 1' -c p $SCRATCH_DEV
+ _scratch_xfs_db -c 'agf 1' -c p
echo "** refcntbt"
- xfs_db -c 'agf 1' -c 'addr refcntroot' -c p $SCRATCH_DEV
+ _scratch_xfs_db -c 'agf 1' -c 'addr refcntroot' -c p
echo "** rmapbt"
- test $is_rmap -gt 0 && xfs_db -c 'agf 1' -c 'addr rmaproot' -c p $SCRATCH_DEV
+ test $is_rmap -gt 0 && _scratch_xfs_db -c 'agf 1' -c 'addr rmaproot' -c p
echo "** bnobt"
- xfs_db -c 'agf 1' -c 'addr bnoroot' -c p $SCRATCH_DEV
+ _scratch_xfs_db -c 'agf 1' -c 'addr bnoroot' -c p
echo "** cntbt"
- xfs_db -c 'agf 1' -c 'addr cntroot' -c p $SCRATCH_DEV
+ _scratch_xfs_db -c 'agf 1' -c 'addr cntroot' -c p
}
echo "We need AG1 to have a single free extent"
echo "Remove the extent from the freesp btrees"
_set_agf_data "recs[1].blockcount" $((len - debris_len)) -c 'addr bnoroot'
_set_agf_data "recs[1].blockcount" $((len - debris_len)) -c 'addr cntroot'
-_set_agf_data freeblks $((agf_freeblks - debris_len))
_set_agf_data longest $((len - debris_len))
+_set_agf_data freeblks $((agf_freeblks - debris_len))
_set_sb_data fdblocks $((sb_fdblocks - debris_len))
echo "Add the extent to the refcount btree"