]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs_db: remove some boilerplate from xfs_attr_set
authorDarrick J. Wong <djwong@kernel.org>
Wed, 3 Jul 2024 21:21:25 +0000 (14:21 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 9 Jul 2024 22:37:02 +0000 (15:37 -0700)
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@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
db/attrset.c
libxfs/libxfs_api_defs.h

index d9ab79fa7849c64d328429d428425675de242162..0086625713236e78bde565c9e996e56fc9542b79 100644 (file)
@@ -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,
index df83aabdc13d3b455675d2005c3b3a2f9a508500..bf1d3c9d37f691ece90f60045f569770e7b12629 100644 (file)
@@ -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