diff mbox series

[09/17] xfs: flip nvreplace detection in xfs_attr_complete_op

Message ID 167899414483.15363.18330355264115568396.stgit@frogsfrogsfrogs (mailing list archive)
State New, archived
Headers show
Series xfs: encode parent pointer name in xattr key | expand

Commit Message

Darrick J. Wong March 16, 2023, 7:23 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Gate the NVREPLACE code on the op flags directly, instead of inferring
it through args->new_namelen.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/libxfs/xfs_attr.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index 996ef24482e1..1a047099e9c7 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -426,9 +426,15 @@  xfs_attr_complete_op(
 		return XFS_DAS_DONE;
 
 	args->attr_filter &= ~XFS_ATTR_INCOMPLETE;
-	if (args->new_namelen == 0)
+	if (xfs_attr_intent_op(attr) != XFS_ATTRI_OP_FLAGS_NVREPLACE)
 		return replace_state;
 
+	/*
+	 * NVREPLACE operations require the caller to set the old and new names
+	 * explicitly.
+	 */
+	ASSERT(args->new_namelen > 0);
+
 	args->name = args->new_name;
 	args->namelen = args->new_namelen;
 	args->hashval = xfs_da_hashname(args->name, args->namelen);