From: Darrick J. Wong <djwong@xxxxxxxxxx> In preparation for online/offline repair wanting to use xfs_attr_set, move some of the boilerplate out of this function into the callers. Repair can initialize the da_args completely, and the userspace flag handling/twisting goes away once we move it to xfs_attr_change. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- db/attrset.c | 18 ++++++++++++++++-- libxfs/libxfs_api_defs.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/db/attrset.c b/db/attrset.c index d9ab79fa7849..008662571323 100644 --- a/db/attrset.c +++ b/db/attrset.c @@ -111,7 +111,11 @@ attr_set_f( int argc, char **argv) { - struct xfs_da_args args = { }; + struct xfs_da_args args = { + .geo = mp->m_attr_geo, + .whichfork = XFS_ATTR_FORK, + .op_flags = XFS_DA_OP_OKNOENT, + }; char *sp; char *name_from_file = NULL; char *value_from_file = NULL; @@ -253,6 +257,9 @@ attr_set_f( goto out; } + args.owner = iocur_top->ino; + libxfs_attr_sethash(&args); + if (libxfs_attr_set(&args, op, false)) { dbprintf(_("failed to set attr %s on inode %llu\n"), args.name, (unsigned long long)iocur_top->ino); @@ -277,7 +284,11 @@ attr_remove_f( int argc, char **argv) { - struct xfs_da_args args = { }; + struct xfs_da_args args = { + .geo = mp->m_attr_geo, + .whichfork = XFS_ATTR_FORK, + .op_flags = XFS_DA_OP_OKNOENT, + }; char *name_from_file = NULL; int c; @@ -365,6 +376,9 @@ attr_remove_f( goto out; } + args.owner = iocur_top->ino; + libxfs_attr_sethash(&args); + if (libxfs_attr_set(&args, XFS_ATTRUPDATE_REMOVE, false)) { dbprintf(_("failed to remove attr %s from inode %llu\n"), (unsigned char *)args.name, diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index df83aabdc13d..bf1d3c9d37f6 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -47,6 +47,7 @@ #define xfs_attr_leaf_newentsize libxfs_attr_leaf_newentsize #define xfs_attr_namecheck libxfs_attr_namecheck #define xfs_attr_set libxfs_attr_set +#define xfs_attr_sethash libxfs_attr_sethash #define xfs_attr_sf_firstentry libxfs_attr_sf_firstentry #define xfs_attr_shortform_verify libxfs_attr_shortform_verify