mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
common/xfs: refactor commands to select a particular xfs backing device
Refactor all the places where we try to force new file data allocations to a specific xfs backing device so that we don't end up open-coding the same xfs_io command lines over and over. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
committed by
Eryu Guan
parent
82901113bc
commit
8d54e50288
+1
-1
@@ -162,7 +162,7 @@ _scratch_xfs_populate() {
|
||||
# Clear the rtinherit flag on the root directory so that files are
|
||||
# always created on the data volume regardless of MKFS_OPTIONS. We can
|
||||
# set the realtime flag when needed.
|
||||
$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
|
||||
_xfs_force_bdev data $SCRATCH_MNT
|
||||
|
||||
blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
|
||||
dblksz="$($XFS_INFO_PROG "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
|
||||
|
||||
+25
@@ -194,6 +194,31 @@ _xfs_get_file_block_size()
|
||||
$XFS_INFO_PROG "$path" | grep realtime | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g'
|
||||
}
|
||||
|
||||
# Set or clear the realtime status of every supplied path. The first argument
|
||||
# is either 'data' or 'realtime'. All other arguments should be paths to
|
||||
# existing directories or empty regular files.
|
||||
#
|
||||
# For each directory, each file subsequently created will target the given
|
||||
# device for file data allocations. For each empty regular file, each
|
||||
# subsequent file data allocation will be on the given device.
|
||||
_xfs_force_bdev()
|
||||
{
|
||||
local device="$1"
|
||||
shift
|
||||
local chattr_arg=""
|
||||
|
||||
case "$device" in
|
||||
"data") chattr_arg="-t";;
|
||||
"realtime") chattr_arg="+t";;
|
||||
*)
|
||||
echo "${device}: Don't know what device this is?"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
$XFS_IO_PROG -c "chattr $chattr_arg" "$@"
|
||||
}
|
||||
|
||||
_xfs_get_fsxattr()
|
||||
{
|
||||
local field="$1"
|
||||
|
||||
+2
-1
@@ -46,7 +46,8 @@ for SUNIT_K in 8 16 32 64 128; do
|
||||
# This test checks for stripe alignments of space allocations on the
|
||||
# filesystem. Make sure all files get created on the main device,
|
||||
# which for XFS means no rt files.
|
||||
test "$FSTYP" = "xfs" && $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
|
||||
test "$FSTYP" = "xfs" && \
|
||||
_xfs_force_bdev data $SCRATCH_MNT
|
||||
|
||||
for SIZE_MULT in 1 2 8 64 256; do
|
||||
let SIZE=$SIZE_MULT*$SUNIT_BYTES
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ _scratch_mount || _fail "mount failed"
|
||||
# This is a test of xattr behavior when we run out of disk space for xattrs,
|
||||
# so make sure the pwrite goes to the data device and not the rt volume.
|
||||
test "$FSTYP" = "xfs" && \
|
||||
$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
|
||||
_xfs_force_bdev data $SCRATCH_MNT
|
||||
|
||||
TFILE=$SCRATCH_MNT/testfile.$seq
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ _populate_scratch()
|
||||
# This test looks at specific behaviors of the xfs_db freesp command,
|
||||
# which reports on the contents of the free space btrees for the data
|
||||
# device. Don't let anything get created on the realtime volume.
|
||||
$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
|
||||
_xfs_force_bdev data $SCRATCH_MNT
|
||||
dd if=/dev/zero of=$SCRATCH_MNT/foo count=200 bs=4096 >/dev/null 2>&1 &
|
||||
dd if=/dev/zero of=$SCRATCH_MNT/goo count=400 bs=4096 >/dev/null 2>&1 &
|
||||
dd if=/dev/zero of=$SCRATCH_MNT/moo count=800 bs=4096 >/dev/null 2>&1 &
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ _scratch_mkfs -r size=$rtsize >> $seqres.full
|
||||
_scratch_mount >> $seqres.full
|
||||
|
||||
# Make sure the root directory has rtinherit set so our test file will too
|
||||
$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
|
||||
_xfs_force_bdev realtime $SCRATCH_MNT
|
||||
|
||||
# Allocate some stuff at the start, to force the first falloc of the ouch file
|
||||
# to happen somewhere in the middle of the rt volume
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ rextblks=$((rextsize / blksz))
|
||||
echo "blksz $blksz rextsize $rextsize rextblks $rextblks" >> $seqres.full
|
||||
|
||||
# Make sure the root directory has rtinherit set so our test file will too
|
||||
$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
|
||||
_xfs_force_bdev realtime $SCRATCH_MNT
|
||||
|
||||
sz=$((rextsize * 100))
|
||||
range="$((blksz * 3)) $blksz"
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ _scratch_mkfs > "$seqres.full" 2>&1
|
||||
_scratch_mount
|
||||
|
||||
# Make sure everything is on the data device
|
||||
$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
|
||||
_xfs_force_bdev data $SCRATCH_MNT
|
||||
|
||||
_pwrite_byte 0x80 0 737373 $SCRATCH_MNT/urk >> $seqres.full
|
||||
sync
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ _scratch_mount >> $seqres.full
|
||||
|
||||
# This test depends on specific behaviors of the data device, so create all
|
||||
# files on it.
|
||||
$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
|
||||
_xfs_force_bdev data $SCRATCH_MNT
|
||||
|
||||
echo "Create files"
|
||||
touch $SCRATCH_MNT/file1
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ _scratch_mount
|
||||
|
||||
# Set realtime inherit flag on scratch mount, suppress output
|
||||
# as this may simply error out on future kernels
|
||||
$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT &> /dev/null
|
||||
_xfs_force_bdev realtime $SCRATCH_MNT &> /dev/null
|
||||
|
||||
# Check if 't' is actually set, as xfs_io returns 0 even when it fails to set
|
||||
# an attribute. And erroring out here is fine, this would be desired behavior
|
||||
@@ -60,7 +60,7 @@ if $XFS_IO_PROG -c 'lsattr' $SCRATCH_MNT | grep -q 't'; then
|
||||
# Remove the testfile and rt inherit flag after we are done or
|
||||
# xfs_repair will fail.
|
||||
rm -f $SCRATCH_MNT/testfile
|
||||
$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT | tee -a $seqres.full 2>&1
|
||||
_xfs_force_bdev data $SCRATCH_MNT | tee -a $seqres.full 2>&1
|
||||
fi
|
||||
|
||||
# success, all done
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ testdir=$SCRATCH_MNT/test-$seq
|
||||
mkdir $testdir
|
||||
|
||||
echo "Check rt volume stats"
|
||||
$XFS_IO_PROG -c 'chattr +t' $testdir
|
||||
_xfs_force_bdev realtime $testdir
|
||||
$XFS_INFO_PROG $SCRATCH_MNT >> $seqres.full
|
||||
before=$(stat -f -c '%b' $testdir)
|
||||
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ test_ops() {
|
||||
_notrun "Could not mount rextsize=$rextsize with synthetic rt volume"
|
||||
|
||||
# Force all files to be realtime files
|
||||
$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
|
||||
_xfs_force_bdev realtime $SCRATCH_MNT
|
||||
|
||||
log "Test regular write, rextsize=$rextsize"
|
||||
mk_file $SCRATCH_MNT/write $rextsize
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ _scratch_mount >> $seqres.full
|
||||
|
||||
# Disable realtime inherit flag (if any) on root directory so that space on data
|
||||
# device gets fragmented rather than realtime device.
|
||||
$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
|
||||
_xfs_force_bdev data $SCRATCH_MNT
|
||||
|
||||
bsize=$(_get_block_size $SCRATCH_MNT)
|
||||
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ _scratch_mount >> $seqres.full
|
||||
|
||||
# Disable realtime inherit flag (if any) on root directory so that space on data
|
||||
# device gets fragmented rather than realtime device.
|
||||
$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
|
||||
_xfs_force_bdev data $SCRATCH_MNT
|
||||
|
||||
echo "Consume free space"
|
||||
fillerdir=$SCRATCH_MNT/fillerdir
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ _scratch_mount >> $seqres.full
|
||||
|
||||
# Disable realtime inherit flag (if any) on root directory so that space on data
|
||||
# device gets fragmented rather than realtime device.
|
||||
$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
|
||||
_xfs_force_bdev data $SCRATCH_MNT
|
||||
|
||||
bsize=$(_get_file_block_size $SCRATCH_MNT)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user