]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
xfs: test that truncate does not spuriously return ENOSPC
authorChristoph Hellwig <hch@lst.de>
Fri, 29 Nov 2024 05:20:33 +0000 (06:20 +0100)
committerChristoph Hellwig <hch@lst.de>
Tue, 4 Feb 2025 13:43:04 +0000 (14:43 +0100)
For zoned file systems, truncate to an offset not aligned to the block
size need to allocate a new block for zeroing the remainder.

Test that this allocation can dip into the reserved pool even when other
threads are waiting for space freed by GC.

Signed-off-by: Christoph Hellwig <hch@lst.de>
tests/xfs/4213 [new file with mode: 0755]
tests/xfs/4213.out [new file with mode: 0644]

diff --git a/tests/xfs/4213 b/tests/xfs/4213
new file mode 100755 (executable)
index 0000000..1509307
--- /dev/null
@@ -0,0 +1,45 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 4213
+#
+# Ensure that a truncate that needs to zero the EOFblock doesn't get ENOSPC
+# when another thread is waiting for space to become available through GC.
+#
+. ./common/preamble
+_begin_fstest auto rw zone
+
+_cleanup()
+{
+       cd /
+       _scratch_unmount >/dev/null 2>&1
+}
+
+# Import common functions.
+. ./common/filter
+. ./common/zoned
+
+_require_scratch
+
+_scratch_mkfs_sized $((256 * 1024 * 1024))  >>$seqres.full 2>&1
+_scratch_mount
+_require_xfs_scratch_zoned
+
+for i in `seq 1 20`; do
+       # fill up all user capacity
+       PUNCH_FILE=$SCRATCH_MNT/punch.$i
+       TEST_FILE=$SCRATCH_MNT/file.$i
+
+       dd if=/dev/zero of=$PUNCH_FILE bs=1M count=128 conv=fdatasync \
+               >> $seqres.full 2>&1
+
+       dd if=/dev/zero of=$TEST_FILE bs=4k >> $seqres.full 2>&1 &
+       # truncate to a value not rounded to the block size
+       $XFS_IO_PROG -c "truncate 3275" $PUNCH_FILE
+       sync $SCRATCH_MNT
+       rm -f $TEST_FILE
+done
+
+status=0
+exit
diff --git a/tests/xfs/4213.out b/tests/xfs/4213.out
new file mode 100644 (file)
index 0000000..acf8716
--- /dev/null
@@ -0,0 +1 @@
+QA output created by 4213