From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@kernel.org>
Cc: fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH v3] generic: shutdown might leave NULL files with nonzero di_size
Date: Wed, 9 Nov 2022 08:51:45 -0800 [thread overview]
Message-ID: <Y2vaoY486TpfKXM3@magnolia> (raw)
In-Reply-To: <20221109130746.3669020-1-zlang@kernel.org>
On Wed, Nov 09, 2022 at 09:07:46PM +0800, Zorro Lang wrote:
> 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>
> ---
>
> Hi,
>
> V2 replace xfs_io fiemap command with stat command.
> V3 replace the stat with the filefrag command, and change the supported_fs
> from xfs to generic.
>
> Thanks,
> Zorro
>
> tests/generic/999 | 46 +++++++++++++++++++++++++++++++++++++++++++
> tests/generic/999.out | 5 +++++
> 2 files changed, 51 insertions(+)
> create mode 100755 tests/generic/999
> create mode 100644 tests/generic/999.out
>
> diff --git a/tests/generic/999 b/tests/generic/999
> new file mode 100755
> index 00000000..ca666de7
> --- /dev/null
> +++ b/tests/generic/999
> @@ -0,0 +1,46 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2022 Red Hat, Inc. All Rights Reserved.
> +#
> +# FS QA Test No. 999
> +#
> +# 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
> + grep -Eq ': 0 extents found' $tmp.filefrag
> + if [ $? -eq 0 ];then
Bash nit: You could compress these two lines to:
if grep -E -q ': 0 extents found' $tmp.filefrag; then
But otherwise this looks good.
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> + 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/999.out b/tests/generic/999.out
> new file mode 100644
> index 00000000..50008783
> --- /dev/null
> +++ b/tests/generic/999.out
> @@ -0,0 +1,5 @@
> +QA output created by 999
> +Create many small files with one extent at least
> +Shutdown the fs suddently
> +Cycle mount
> +Check file's (di_size > 0) extents
> --
> 2.31.1
>
prev parent reply other threads:[~2022-11-09 16:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 13:07 [PATCH v3] generic: shutdown might leave NULL files with nonzero di_size Zorro Lang
2022-11-09 16:51 ` Darrick J. Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y2vaoY486TpfKXM3@magnolia \
--to=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=zlang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox