public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Long Li <leo.lilong@huawei.com>
Cc: zlang@redhat.com, linux-xfs@vger.kernel.org,
	fstests@vger.kernel.org, yi.zhang@huawei.com, houtao1@huawei.com,
	yangerkun@huawei.com
Subject: Re: [PATCH] xfs/018: test log attr replay with zero-length attr value
Date: Wed, 1 Apr 2026 07:35:32 -0700	[thread overview]
Message-ID: <20260401143532.GK6212@frogsfrogsfrogs> (raw)
In-Reply-To: <20260401060632.2085015-1-leo.lilong@huawei.com>

On Wed, Apr 01, 2026 at 02:06:32PM +0800, Long Li wrote:
> Kernel commit d72f2084e309 ("xfs: fix ri_total validation in
> xlog_recover_attri_commit_pass2") fixed a bug where setting a
> zero-length attribute value would cause incorrect ri_total
> validation during log recovery.
> 
> Add test cases to xfs/018 to cover this scenario across attr
> fork formats: extent and remote.
> 
> Using echo -n "" | attr -s is unreliable for empty values since
> attr may treat stdin EOF as no value provided. Instead, handle

Gross. :)

> zero-length values explicitly in test_attr_replay() by using
> attr -s -V "" when the value is empty.
> 
> Signed-off-by: Long Li <leo.lilong@huawei.com>

Thanks for catching adding the empty attr case; I hadn't realized that
was actually possible.

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  tests/xfs/018     | 26 ++++++++++++++++++++++----
>  tests/xfs/018.out | 20 ++++++++++++++++++++
>  2 files changed, 42 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/xfs/018 b/tests/xfs/018
> index 9b69c9cb..3a40a85a 100755
> --- a/tests/xfs/018
> +++ b/tests/xfs/018
> @@ -33,10 +33,18 @@ test_attr_replay()
>  	# Inject error
>  	_scratch_inject_error $error_tag
>  
> -	# Set attribute, being careful not to include the trailing newline
> -	# in the attr value.
> -	echo -n "$attr_value" | ${ATTR_PROG} -$flag "$attr_name" $testfile 2>&1 | \
> -			    _filter_scratch
> +	# Set attribute. For zero-length values, use -V "" explicitly to
> +	# avoid relying on stdin EOF behavior which is undefined for empty
> +	# values. Otherwise, being careful not to include the trailing
> +	# newline in the attr value.
> +	if [ "$flag" = "s" ] && [ -z "$attr_value" ]; then
> +		${ATTR_PROG} -s "$attr_name" -V "" $testfile 2>&1 | \
> +			_filter_scratch
> +	else
> +		echo -n "$attr_value" | ${ATTR_PROG} -$flag "$attr_name" \
> +			$testfile 2>&1 | _filter_scratch
> +	fi
> +
>  
>  	# FS should be shut down, touch will fail
>  	touch $testfile 2>&1 | _filter_scratch
> @@ -147,6 +155,11 @@ create_test_file inline_file3 1 $attr16
>  test_attr_replay inline_file3 "attr_name2" $attr64k "s" "larp"
>  test_attr_replay inline_file3 "attr_name2" $attr64k "r" "larp"
>  
> +# extent, zero-length value
> +create_test_file extent_file0 1 $attr1k
> +test_attr_replay extent_file0 "attr_name2" "" "s" "larp"
> +test_attr_replay extent_file0 "attr_name2" "" "r" "larp"
> +
>  # extent, internal
>  create_test_file extent_file1 1 $attr1k
>  test_attr_replay extent_file1 "attr_name2" $attr1k "s" "larp"
> @@ -165,6 +178,11 @@ create_test_file extent_file4 1 $attr1k
>  test_attr_replay extent_file4 "attr_name2" $attr64k "s" "larp"
>  test_attr_replay extent_file4 "attr_name2" $attr64k "r" "larp"
>  
> +# remote, zero-length value
> +create_test_file remote_file0 1 $attr64k
> +test_attr_replay remote_file0 "attr_name2" "" "s" "larp"
> +test_attr_replay remote_file0 "attr_name2" "" "r" "larp"
> +
>  # remote, internal
>  create_test_file remote_file1 1 $attr64k
>  test_attr_replay remote_file1 "attr_name2" $attr1k "s" "larp"
> diff --git a/tests/xfs/018.out b/tests/xfs/018.out
> index be1d6422..11b1c034 100644
> --- a/tests/xfs/018.out
> +++ b/tests/xfs/018.out
> @@ -41,6 +41,16 @@ Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file3
>  touch: cannot touch 'SCRATCH_MNT/testdir/inline_file3': Input/output error
>  attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
>  
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/extent_file0
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file0': Input/output error
> +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/extent_file0
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file0': Input/output error
> +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> +
>  attr_set: Input/output error
>  Could not set "attr_name2" for SCRATCH_MNT/testdir/extent_file1
>  touch: cannot touch 'SCRATCH_MNT/testdir/extent_file1': Input/output error
> @@ -71,6 +81,16 @@ Could not remove "attr_name2" for SCRATCH_MNT/testdir/extent_file4
>  touch: cannot touch 'SCRATCH_MNT/testdir/extent_file4': Input/output error
>  attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
>  
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/remote_file0
> +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file0': Input/output error
> +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/remote_file0
> +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file0': Input/output error
> +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> +
>  attr_set: Input/output error
>  Could not set "attr_name2" for SCRATCH_MNT/testdir/remote_file1
>  touch: cannot touch 'SCRATCH_MNT/testdir/remote_file1': Input/output error
> -- 
> 2.39.2
> 
> 

      reply	other threads:[~2026-04-01 14:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01  6:06 [PATCH] xfs/018: test log attr replay with zero-length attr value Long Li
2026-04-01 14:35 ` 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=20260401143532.GK6212@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=houtao1@huawei.com \
    --cc=leo.lilong@huawei.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=zlang@redhat.com \
    /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