diff mbox series

[9/9] xfs: turn the XFS_DA_OP_REPLACE checks in xfs_attr_shortform_addname into asserts

Message ID 20231220063503.1005804-10-hch@lst.de (mailing list archive)
State Superseded
Headers show
Series [1/9] xfs: make if_data a void pointer | expand

Commit Message

Christoph Hellwig Dec. 20, 2023, 6:35 a.m. UTC
Since commit deed9512872d ("xfs: Check for -ENOATTR or -EEXIST"), the
high-level attr code does a lookup for any attr we're trying to set,
and does the checks to handle the create vs replace cases, which thus
never hit the low-level attr code.

Turn the checks in xfs_attr_shortform_addname as they must never trip.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_attr.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Darrick J. Wong Dec. 20, 2023, 7:09 a.m. UTC | #1
On Wed, Dec 20, 2023 at 07:35:03AM +0100, Christoph Hellwig wrote:
> Since commit deed9512872d ("xfs: Check for -ENOATTR or -EEXIST"), the
> high-level attr code does a lookup for any attr we're trying to set,
> and does the checks to handle the create vs replace cases, which thus
> never hit the low-level attr code.
> 
> Turn the checks in xfs_attr_shortform_addname as they must never trip.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks ok,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/libxfs/xfs_attr.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index ec4061db7ffccd..9976a00a73f99c 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -1072,8 +1072,7 @@ xfs_attr_shortform_addname(
>  	if (xfs_attr_sf_findname(args)) {
>  		int		error;
>  
> -		if (!(args->op_flags & XFS_DA_OP_REPLACE))
> -			return -EEXIST;
> +		ASSERT(args->op_flags & XFS_DA_OP_REPLACE);
>  
>  		error = xfs_attr_sf_removename(args);
>  		if (error)
> @@ -1087,8 +1086,7 @@ xfs_attr_shortform_addname(
>  		 */
>  		args->op_flags &= ~XFS_DA_OP_REPLACE;
>  	} else {
> -		if (args->op_flags & XFS_DA_OP_REPLACE)
> -			return -ENOATTR;
> +		ASSERT(!(args->op_flags & XFS_DA_OP_REPLACE));
>  	}
>  
>  	if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX ||
> -- 
> 2.39.2
> 
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index ec4061db7ffccd..9976a00a73f99c 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -1072,8 +1072,7 @@  xfs_attr_shortform_addname(
 	if (xfs_attr_sf_findname(args)) {
 		int		error;
 
-		if (!(args->op_flags & XFS_DA_OP_REPLACE))
-			return -EEXIST;
+		ASSERT(args->op_flags & XFS_DA_OP_REPLACE);
 
 		error = xfs_attr_sf_removename(args);
 		if (error)
@@ -1087,8 +1086,7 @@  xfs_attr_shortform_addname(
 		 */
 		args->op_flags &= ~XFS_DA_OP_REPLACE;
 	} else {
-		if (args->op_flags & XFS_DA_OP_REPLACE)
-			return -ENOATTR;
+		ASSERT(!(args->op_flags & XFS_DA_OP_REPLACE));
 	}
 
 	if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX ||