diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2018-03-23 09:54:47 -0700 |
---|---|---|
committer | Eryu Guan <guaneryu@gmail.com> | 2018-03-29 21:07:20 +0800 |
commit | d75c76f63d430792bed5fa21bdc7f90693c239b7 (patch) | |
tree | 09380093401ff364ce0262ad2ecb964509958f86 | |
parent | e873eb9857885a84fc7a1cb9bd590241df036ecc (diff) | |
download | xfstests-dev-d75c76f63d430792bed5fa21bdc7f90693c239b7.tar.gz |
xfs/278: find sfdir inode field prefix
Use the xfs set/get metadata field helpers to detect the correct sfdir
field name prefix on v4-v5 filesystems. This enables us to test inode
link count corrections on a (deliberately) disconnected directory.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rwxr-xr-x | tests/xfs/278 | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/tests/xfs/278 b/tests/xfs/278 index b94ee9c68e..47012a36ef 100755 --- a/tests/xfs/278 +++ b/tests/xfs/278 @@ -61,17 +61,39 @@ _scratch_unmount echo "Silence is goodness..." +get_sfdir_prefix() { + local dir_ino="$1" + + for prefix in "u.sfdir3" "u.sfdir2" "u3.sfdir3"; do + if [ -n "$(_scratch_xfs_get_metadata_field \ + "${prefix}.hdr.parent.i4" \ + "inode ${dir_ino}")" ]; then + echo "${prefix}" + return 0 + fi + done + _scratch_xfs_db -c "inode ${dir_ino}" -c 'p' >> $seqres.full + return 1 +} +set_ifield() { + _scratch_xfs_set_metadata_field "$1" 0 "inode $2" >> $seqres.full +} + +sfdir_prefix="$(get_sfdir_prefix "$DIR_INO" || \ + _fail "Cannot determine sfdir prefix")" + # Corrupt DIR -_scratch_xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].inumber.i4 0" >> $seqres.full -_scratch_xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].name 0" >> $seqres.full -_scratch_xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].offset 0" >> $seqres.full -_scratch_xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.list[0].namelen 0" >> $seqres.full -_scratch_xfs_db -x -c "inode $DIR_INO" -c "write u.sfdir2.hdr.parent.i4 0" >> $seqres.full -_scratch_xfs_db -x -c "inode $DIR_INO" -c "write core.nlinkv2 0" >> $seqres.full + +set_ifield "${sfdir_prefix}.list[0].inumber.i4" "$DIR_INO" +set_ifield "${sfdir_prefix}.list[0].name" "$DIR_INO" +set_ifield "${sfdir_prefix}.list[0].offset" "$DIR_INO" +set_ifield "${sfdir_prefix}.list[0].namelen" "$DIR_INO" +set_ifield "${sfdir_prefix}.hdr.parent.i4" "$DIR_INO" +set_ifield "core.nlinkv2" "$DIR_INO" # Corrupt SUBDIR -_scratch_xfs_db -x -c "inode $SUBDIR_INO" -c "write u.sfdir2.hdr.parent.i4 0" >> $seqres.full -_scratch_xfs_db -x -c "inode $SUBDIR_INO" -c "write core.nlinkv2 0" >> $seqres.full +set_ifield "${sfdir_prefix}.hdr.parent.i4" "$SUBDIR_INO" +set_ifield "core.nlinkv2" "$SUBDIR_INO" echo "===== BEGIN of xfs_repair =====" >> $seqres.full echo "" >>$seqres.full |