diff mbox series

[v2] xfs: Test bulkstat special query for root inode

Message ID 20221221223805.148788-1-shiina.hironori@fujitsu.com (mailing list archive)
State New, archived
Headers show
Series [v2] xfs: Test bulkstat special query for root inode | expand

Commit Message

Hironori Shiina Dec. 21, 2022, 10:38 p.m. UTC
This is a test for the fix:
  bf3cb3944792 xfs: allow single bulkstat of special inodes
This fix added a feature to query the root inode number of a filesystem.
This test creates a file with a lower inode number than the root and run
a query for the root inode.

Signed-off-by: Hironori Shiina <shiina.hironori@fujitsu.com>
---
 tests/xfs/557     | 63 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/557.out |  2 ++
 2 files changed, 65 insertions(+)
 create mode 100644 tests/xfs/557
 create mode 100644 tests/xfs/557.out

Comments

Darrick J. Wong Dec. 22, 2022, 6:10 p.m. UTC | #1
On Wed, Dec 21, 2022 at 05:38:05PM -0500, Hironori Shiina wrote:
> This is a test for the fix:
>   bf3cb3944792 xfs: allow single bulkstat of special inodes
> This fix added a feature to query the root inode number of a filesystem.
> This test creates a file with a lower inode number than the root and run
> a query for the root inode.
> 
> Signed-off-by: Hironori Shiina <shiina.hironori@fujitsu.com>

Looks good to me,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  tests/xfs/557     | 63 +++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/557.out |  2 ++
>  2 files changed, 65 insertions(+)
>  create mode 100644 tests/xfs/557
>  create mode 100644 tests/xfs/557.out
> 
> diff --git a/tests/xfs/557 b/tests/xfs/557
> new file mode 100644
> index 00000000..608ce13c
> --- /dev/null
> +++ b/tests/xfs/557
> @@ -0,0 +1,63 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2022 Fujitsu Limited. All Rights Reserved.
> +#
> +# FS QA Test No. 557
> +#
> +# This is a test for:
> +#   bf3cb3944792 (xfs: allow single bulkstat of special inodes)
> +# Create a filesystem which contains an inode with a lower number
> +# than the root inode. Then verify that XFS_BULK_IREQ_SPECIAL_ROOT gets
> +# the correct root inode number.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick
> +
> +_supported_fs xfs
> +_require_xfs_io_command "falloc"
> +_require_xfs_io_command "bulkstat_single"
> +_require_scratch
> +
> +_fixed_by_kernel_commit XXXXXXXXXXXX \
> +	"xfs: get root inode correctly at bulkstat"
> +
> +# A large stripe unit will put the root inode out quite far
> +# due to alignment, leaving free blocks ahead of it.
> +_scratch_mkfs_xfs -d sunit=1024,swidth=1024 > $seqres.full 2>&1 || _fail "mkfs failed"
> +
> +# Mounting /without/ a stripe should allow inodes to be allocated
> +# in lower free blocks, without the stripe alignment.
> +_scratch_mount -o sunit=0,swidth=0
> +
> +root_inum=$(stat -c %i $SCRATCH_MNT)
> +
> +# Consume space after the root inode so that the blocks before
> +# root look "close" for the next inode chunk allocation
> +$XFS_IO_PROG -f -c "falloc 0 16m" $SCRATCH_MNT/fillfile
> +
> +# And make a bunch of inodes until we (hopefully) get one lower
> +# than root, in a new inode chunk.
> +echo "root_inum: $root_inum" >> $seqres.full
> +for i in $(seq 0 4096) ; do
> +	fname=$SCRATCH_MNT/$(printf "FILE_%03d" $i)
> +	touch $fname
> +	inum=$(stat -c "%i" $fname)
> +	[[ $inum -lt $root_inum ]] && break
> +done
> +
> +echo "created: $inum" >> $seqres.full
> +
> +[[ $inum -lt $root_inum ]] || _notrun "Could not set up test"
> +
> +# Get root ino with XFS_BULK_IREQ_SPECIAL_ROOT
> +bulkstat_root_inum=$($XFS_IO_PROG -c 'bulkstat_single root' $SCRATCH_MNT | grep bs_ino | awk '{print $3;}')
> +echo "bulkstat_root_inum: $bulkstat_root_inum" >> $seqres.full
> +if [ $root_inum -ne $bulkstat_root_inum ]; then
> +	echo "root ino mismatch: expected:${root_inum}, actual:${bulkstat_root_inum}"
> +fi
> +
> +echo "Silence is golden"
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/557.out b/tests/xfs/557.out
> new file mode 100644
> index 00000000..1f1ae1d4
> --- /dev/null
> +++ b/tests/xfs/557.out
> @@ -0,0 +1,2 @@
> +QA output created by 557
> +Silence is golden
> -- 
> 2.38.1
>
diff mbox series

Patch

diff --git a/tests/xfs/557 b/tests/xfs/557
new file mode 100644
index 00000000..608ce13c
--- /dev/null
+++ b/tests/xfs/557
@@ -0,0 +1,63 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022 Fujitsu Limited. All Rights Reserved.
+#
+# FS QA Test No. 557
+#
+# This is a test for:
+#   bf3cb3944792 (xfs: allow single bulkstat of special inodes)
+# Create a filesystem which contains an inode with a lower number
+# than the root inode. Then verify that XFS_BULK_IREQ_SPECIAL_ROOT gets
+# the correct root inode number.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+_supported_fs xfs
+_require_xfs_io_command "falloc"
+_require_xfs_io_command "bulkstat_single"
+_require_scratch
+
+_fixed_by_kernel_commit XXXXXXXXXXXX \
+	"xfs: get root inode correctly at bulkstat"
+
+# A large stripe unit will put the root inode out quite far
+# due to alignment, leaving free blocks ahead of it.
+_scratch_mkfs_xfs -d sunit=1024,swidth=1024 > $seqres.full 2>&1 || _fail "mkfs failed"
+
+# Mounting /without/ a stripe should allow inodes to be allocated
+# in lower free blocks, without the stripe alignment.
+_scratch_mount -o sunit=0,swidth=0
+
+root_inum=$(stat -c %i $SCRATCH_MNT)
+
+# Consume space after the root inode so that the blocks before
+# root look "close" for the next inode chunk allocation
+$XFS_IO_PROG -f -c "falloc 0 16m" $SCRATCH_MNT/fillfile
+
+# And make a bunch of inodes until we (hopefully) get one lower
+# than root, in a new inode chunk.
+echo "root_inum: $root_inum" >> $seqres.full
+for i in $(seq 0 4096) ; do
+	fname=$SCRATCH_MNT/$(printf "FILE_%03d" $i)
+	touch $fname
+	inum=$(stat -c "%i" $fname)
+	[[ $inum -lt $root_inum ]] && break
+done
+
+echo "created: $inum" >> $seqres.full
+
+[[ $inum -lt $root_inum ]] || _notrun "Could not set up test"
+
+# Get root ino with XFS_BULK_IREQ_SPECIAL_ROOT
+bulkstat_root_inum=$($XFS_IO_PROG -c 'bulkstat_single root' $SCRATCH_MNT | grep bs_ino | awk '{print $3;}')
+echo "bulkstat_root_inum: $bulkstat_root_inum" >> $seqres.full
+if [ $root_inum -ne $bulkstat_root_inum ]; then
+	echo "root ino mismatch: expected:${root_inum}, actual:${bulkstat_root_inum}"
+fi
+
+echo "Silence is golden"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/557.out b/tests/xfs/557.out
new file mode 100644
index 00000000..1f1ae1d4
--- /dev/null
+++ b/tests/xfs/557.out
@@ -0,0 +1,2 @@ 
+QA output created by 557
+Silence is golden