From: Darrick J. Wong <djwong@xxxxxxxxxx> Test how well we can format a fully populated filesystem with a protofile that was generated with xfs_protofile. Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> --- common/config | 1 tests/xfs/1894 | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1894.out | 4 ++ 3 files changed, 114 insertions(+) create mode 100755 tests/xfs/1894 create mode 100644 tests/xfs/1894.out diff --git a/common/config b/common/config index 193b7af432dc2b..da12399da421c7 100644 --- a/common/config +++ b/common/config @@ -161,6 +161,7 @@ export MKSWAP_PROG="$(type -P mkswap)" MKSWAP_PROG="$MKSWAP_PROG -f" export XFS_LOGPRINT_PROG="$(type -P xfs_logprint)" +export XFS_PROTOFILE_PROG="$(type -P xfs_protofile)" export XFS_REPAIR_PROG="$(type -P xfs_repair)" export XFS_DB_PROG="$(type -P xfs_db)" export XFS_METADUMP_PROG="$(type -P xfs_metadump)" diff --git a/tests/xfs/1894 b/tests/xfs/1894 new file mode 100755 index 00000000000000..2f6beea2c433bf --- /dev/null +++ b/tests/xfs/1894 @@ -0,0 +1,109 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle, Inc. All Rights Reserved. +# +# FS QA Test No. 1894 +# +# Populate a XFS filesystem, use xfs_protofile to recreate the filesystem, and +# compare the contents. +# +. ./common/preamble +_begin_fstest auto scrub + +_cleanup() +{ + command -v _kill_fsstress &>/dev/null && _kill_fsstress + cd / + test -e "$testfiles" && _unmount $testfiles/mount &>/dev/null + test -e "$testfiles" && rm -r -f $testfiles +} + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy + +_require_command "$XFS_PROTOFILE_PROG" xfs_protofile +_require_test +_require_scratch +_require_scrub +_require_populate_commands + +make_md5() +{ + (cd $1 ; find . -type f -print0 | xargs -0 md5sum) > $tmp.md5.$2 +} + +cmp_md5() +{ + (cd $1 ; md5sum --quiet -c $tmp.md5.$2) +} + +make_stat() +{ + # columns: raw mode in hex, + # major rdev for special + # minor rdev for special + # uid of owner + # gid of owner + # file type + # total size + # name + # We can't directly control directory sizes so filter them. + (cd $1 ; find . -print0 | + xargs -0 stat -c '%f %t:%T %u %g %F %s %n' | + sed -e 's/ directory [1-9][0-9]* / directory SIZE /g' | + sort) > $tmp.stat.$2 +} + +cmp_stat() +{ + diff -u $tmp.stat.$1 $tmp.stat.$2 +} + +testfiles=$TEST_DIR/$seq +mkdir -p $testfiles/mount + +echo "Format and populate" +_scratch_populate_cached nofill >> $seqres.full 2>&1 +_scratch_mount + +_run_fsstress -n 1000 -d $SCRATCH_MNT/newfiles + +make_stat $SCRATCH_MNT before +make_md5 $SCRATCH_MNT before + +kb_needed=$(du -k -s $SCRATCH_MNT | awk '{print $1}') +img_size=$((kb_needed * 2)) +test "$img_size" -lt $((300 * 1024)) && img_size=$((300 * 1024)) + +echo "Clone image with protofile" +$XFS_PROTOFILE_PROG $SCRATCH_MNT > $testfiles/protofile + +truncate -s "${img_size}k" $testfiles/image +if ! _try_mkfs_dev -p $testfiles/protofile $testfiles/image &> $tmp.mkfs; then + cat $tmp.mkfs >> $seqres.full + + # mkfs.xfs' protofile parser has some limitations in what it can copy + # in from the prototype files. If a source file has more than 64k + # worth of xattr names then formatting will fail because listxattr + # cannot return that much information. + if grep -q 'Argument list too long' $tmp.mkfs; then + _notrun "source filesystem was too large" + fi + cat $tmp.mkfs +fi + +_mount $testfiles/image $testfiles/mount + +echo "Check file contents" +make_stat $testfiles/mount after +cmp_stat before after +cmp_md5 $testfiles/mount before +_unmount $testfiles/mount + +# success, all done +status=0 +exit diff --git a/tests/xfs/1894.out b/tests/xfs/1894.out new file mode 100644 index 00000000000000..5dd46993549187 --- /dev/null +++ b/tests/xfs/1894.out @@ -0,0 +1,4 @@ +QA output created by 1894 +Format and populate +Clone image with protofile +Check file contents