From: Darrick J. Wong Date: Thu, 20 Feb 2025 21:47:05 +0000 (-0800) Subject: xfs: test filesystem creation with xfs_protofile X-Git-Tag: v2025.03.09~46 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6d39dc34e61e11e3241e3578aec921e4e4e12f64;p=xfstests-dev.git xfs: test filesystem creation with xfs_protofile 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" Reviewed-by: Christoph Hellwig Signed-off-by: Zorro Lang --- diff --git a/common/config b/common/config index 0b01b205..2afbda14 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/818 b/tests/xfs/818 new file mode 100755 index 00000000..aeb46235 --- /dev/null +++ b/tests/xfs/818 @@ -0,0 +1,115 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle, Inc. All Rights Reserved. +# +# FS QA Test No. 818 +# +# 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 + + # The protofile parser does not preserve cloned reflinked space, so + # the new filesystem can run out of space. + if grep -q 'No space left on device' $tmp.mkfs; then + _notrun "not enough space in filesystem" + 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/818.out b/tests/xfs/818.out new file mode 100644 index 00000000..7bee3a14 --- /dev/null +++ b/tests/xfs/818.out @@ -0,0 +1,4 @@ +QA output created by 818 +Format and populate +Clone image with protofile +Check file contents