From: "Darrick J. Wong" <djwong@kernel.org>
To: Long Li <leo.lilong@huawei.com>
Cc: cem@kernel.org, linux-xfs@vger.kernel.org, david@fromorbit.com,
yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com,
lonuxli.64@gmail.com
Subject: Re: [PATCH v2 3/3] xfs: remove redundant validation in xlog_recover_attri_commit_pass2
Date: Thu, 19 Mar 2026 09:54:29 -0700 [thread overview]
Message-ID: <20260319165429.GR1770774@frogsfrogsfrogs> (raw)
In-Reply-To: <20260319010618.722448-4-leo.lilong@huawei.com>
On Thu, Mar 19, 2026 at 09:06:18AM +0800, Long Li wrote:
> Remove the redundant post-parse validation switch. By the time that
> block is reached, xfs_attri_validate() has already guaranteed all name
> lengths are non-zero via xfs_attri_validate_namelen(), and
> xfs_attri_validate_name_iovec() has already returned -EFSCORRUPTED for
> NULL names. For the REMOVE case, attr_value and value_len are
> structurally guaranteed to be NULL/zero because the parsing loop only
> populates them when value_len != 0. All checks in that switch are
> therefore dead code.
>
> Signed-off-by: Long Li <leo.lilong@huawei.com>
Yeah, that was redundant.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_attr_item.c | 46 ------------------------------------------
> 1 file changed, 46 deletions(-)
>
> diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
> index 19eaf6b8cd43..b462e15d2329 100644
> --- a/fs/xfs/xfs_attr_item.c
> +++ b/fs/xfs/xfs_attr_item.c
> @@ -1133,52 +1133,6 @@ xlog_recover_attri_commit_pass2(
> return -EFSCORRUPTED;
> }
>
> - switch (op) {
> - case XFS_ATTRI_OP_FLAGS_REMOVE:
> - /* Regular remove operations operate only on names. */
> - if (attr_value != NULL || value_len != 0) {
> - XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
> - attri_formatp, len);
> - return -EFSCORRUPTED;
> - }
> - fallthrough;
> - case XFS_ATTRI_OP_FLAGS_PPTR_REMOVE:
> - case XFS_ATTRI_OP_FLAGS_PPTR_SET:
> - case XFS_ATTRI_OP_FLAGS_SET:
> - case XFS_ATTRI_OP_FLAGS_REPLACE:
> - /*
> - * Regular xattr set/remove/replace operations require a name
> - * and do not take a newname. Values are optional for set and
> - * replace.
> - *
> - * Name-value set/remove operations must have a name, do not
> - * take a newname, and can take a value.
> - */
> - if (attr_name == NULL || name_len == 0) {
> - XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
> - attri_formatp, len);
> - return -EFSCORRUPTED;
> - }
> - break;
> - case XFS_ATTRI_OP_FLAGS_PPTR_REPLACE:
> - /*
> - * Name-value replace operations require the caller to
> - * specify the old and new names and values explicitly.
> - * Values are optional.
> - */
> - if (attr_name == NULL || name_len == 0) {
> - XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
> - attri_formatp, len);
> - return -EFSCORRUPTED;
> - }
> - if (attr_new_name == NULL || new_name_len == 0) {
> - XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
> - attri_formatp, len);
> - return -EFSCORRUPTED;
> - }
> - break;
> - }
> -
> /*
> * Memory alloc failure will cause replay to abort. We attach the
> * name/value buffer to the recovered incore log item and drop our
> --
> 2.39.2
>
>
prev parent reply other threads:[~2026-03-19 16:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 1:06 [PATCH v2 0/3] xfs: fixes and clean up for attr item Long Li
2026-03-19 1:06 ` [PATCH v2 1/3] xfs: fix possible null pointer dereference in xfs_attri_recover_work Long Li
2026-03-19 16:52 ` Darrick J. Wong
2026-03-20 1:44 ` Long Li
2026-03-19 1:06 ` [PATCH v2 2/3] xfs: fix ri_total validation in xlog_recover_attri_commit_pass2 Long Li
2026-03-19 16:54 ` Darrick J. Wong
2026-03-19 1:06 ` [PATCH v2 3/3] xfs: remove redundant " Long Li
2026-03-19 16:54 ` 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=20260319165429.GR1770774@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=david@fromorbit.com \
--cc=houtao1@huawei.com \
--cc=leo.lilong@huawei.com \
--cc=linux-xfs@vger.kernel.org \
--cc=lonuxli.64@gmail.com \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.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