]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
generic: shutdown might leave NULL files with nonzero di_size
authorZorro Lang <zlang@kernel.org>
Wed, 9 Nov 2022 13:07:46 +0000 (21:07 +0800)
committerZorro Lang <zlang@kernel.org>
Wed, 23 Nov 2022 03:55:03 +0000 (11:55 +0800)
An old issue might cause on-disk inode sizes are logged prematurely
via the free eofblocks path on file close. Then fs shutdown might
leave NULL files but their di_size > 0.

Signed-off-by: Zorro Lang <zlang@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/generic/705 [new file with mode: 0755]
tests/generic/705.out [new file with mode: 0644]

diff --git a/tests/generic/705 b/tests/generic/705
new file mode 100755 (executable)
index 0000000..7b6e557
--- /dev/null
@@ -0,0 +1,45 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test No. 705
+#
+# Test an issue in the truncate codepath where on-disk inode sizes are logged
+# prematurely via the free eofblocks path on file close.
+#
+. ./common/preamble
+_begin_fstest auto shutdown
+
+# real QA test starts here
+_supported_fs generic
+_require_scratch
+_require_scratch_shutdown
+_require_command "$FILEFRAG_PROG" filefrag
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount
+
+echo "Create many small files with one extent at least"
+for ((i=0; i<10000; i++));do
+       $XFS_IO_PROG -f -c "pwrite 0 4k" $SCRATCH_MNT/file.$i >/dev/null 2>&1
+done
+
+echo "Shutdown the fs suddently"
+_scratch_shutdown
+
+echo "Cycle mount"
+_scratch_cycle_mount
+
+echo "Check file's (di_size > 0) extents"
+for f in $(find $SCRATCH_MNT -type f -size +0);do
+       # Check if the file has any extent
+       $FILEFRAG_PROG -v $f > $tmp.filefrag
+       if grep -Eq ': 0 extents found' $tmp.filefrag;then
+               echo " - $f get no extents, but its di_size > 0"
+               cat $tmp.filefrag
+               break
+       fi
+done
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/705.out b/tests/generic/705.out
new file mode 100644 (file)
index 0000000..ca2a6d4
--- /dev/null
@@ -0,0 +1,5 @@
+QA output created by 705
+Create many small files with one extent at least
+Shutdown the fs suddently
+Cycle mount
+Check file's (di_size > 0) extents