[PATCH 03/17] xfs: use xfs_attr_defer_parent for calling xfs_attr_set on pptrs

Darrick J. Wong
2024-04-16T01:36:44Z

Adapt the xfs_attr_set function so that repair code can use it to fix
broken parent pointers.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/libxfs/xfs_attr.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index c98145596f029..b18f6c258a174 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -1027,14 +1027,21 @@ xfs_attr_set(
case -EEXIST:
if (op == XFS_ATTRUPDATE_REMOVE) {
/* if no value, we are performing a remove operation */
- xfs_attr_defer_add(args, XFS_ATTR_DEFER_REMOVE);
+ if (args->attr_filter & XFS_ATTR_PARENT)
+ xfs_attr_defer_parent(args,
+ XFS_ATTR_DEFER_REMOVE);
+ else
+ xfs_attr_defer_add(args, XFS_ATTR_DEFER_REMOVE);
break;
}

/* Pure create fails if the attr already exists */
if (op == XFS_ATTRUPDATE_CREATE)
goto out_trans_cancel;
- xfs_attr_defer_add(args, XFS_ATTR_DEFER_REPLACE);
+ if (args->attr_filter & XFS_ATTR_PARENT)
+ xfs_attr_defer_parent(args, XFS_ATTR_DEFER_REPLACE);
+ else
+ xfs_attr_defer_add(args, XFS_ATTR_DEFER_REPLACE);
break;
case -ENOATTR:
/* Can't remove what isn't there. */
@@ -1044,7 +1051,10 @@ xfs_attr_set(
/* Pure replace fails if no existing attr to replace. */
if (op == XFS_ATTRUPDATE_REPLACE)
goto out_trans_cancel;
- xfs_attr_defer_add(args, XFS_ATTR_DEFER_SET);
+ if (args->attr_filter & XFS_ATTR_PARENT)
+ xfs_attr_defer_parent(args, XFS_ATTR_DEFER_SET);
+ else
+ xfs_attr_defer_add(args, XFS_ATTR_DEFER_SET);
break;
default:
goto out_trans_cancel;