]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: remove xfs_da_args.attr_flags
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:22:43 +0000 (16:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:01 +0000 (17:01 -0700)
Source kernel commit: 54275d8496f3e4764302cebc0e9517d950ba6589

This field only ever contains XATTR_{CREATE,REPLACE}, and it only goes
as deep as xfs_attr_set.  Remove the field from the structure and
replace it with an enum specifying exactly what kind of change we want
to make to the xattr structure.  Upsert is the name that we'll give to
the flags==0 operation, because we're either updating an existing value
or inserting it, and the caller doesn't care.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
db/attrset.c
libxfs/xfs_attr.c
libxfs/xfs_attr.h
libxfs/xfs_da_btree.h

index 0d8d70a84292fd8aef04730933d18a3028cd65a8..736482fea05c608e33be4f02b38302a16cc9ac8a 100644 (file)
@@ -69,6 +69,7 @@ attr_set_f(
 {
        struct xfs_da_args      args = { };
        char                    *sp;
+       enum xfs_attr_update    op = XFS_ATTRUPDATE_UPSERTR;
        int                     c;
 
        if (cur_typ == NULL) {
@@ -98,12 +99,10 @@ attr_set_f(
 
                /* modifiers */
                case 'C':
-                       args.attr_flags |= XATTR_CREATE;
-                       args.attr_flags &= ~XATTR_REPLACE;
+                       op = XFS_ATTRUPDATE_CREATE;
                        break;
                case 'R':
-                       args.attr_flags |= XATTR_REPLACE;
-                       args.attr_flags &= ~XATTR_CREATE;
+                       op = XFS_ATTRUPDATE_REPLACE;
                        break;
 
                case 'n':
@@ -162,7 +161,7 @@ attr_set_f(
                goto out;
        }
 
-       if (libxfs_attr_set(&args)) {
+       if (libxfs_attr_set(&args, op)) {
                dbprintf(_("failed to set attr %s on inode %llu\n"),
                        args.name, (unsigned long long)iocur_top->ino);
                goto out;
@@ -248,7 +247,7 @@ attr_remove_f(
                goto out;
        }
 
-       if (libxfs_attr_set(&args)) {
+       if (libxfs_attr_set(&args, XFS_ATTRUPDATE_UPSERTR)) {
                dbprintf(_("failed to remove attr %s from inode %llu\n"),
                        (unsigned char *)args.name,
                        (unsigned long long)iocur_top->ino);
index 958c6d720ab9a89608b16a6a5e161211d6516296..9a6787624fb73953502320200627f205ea7ccc16 100644 (file)
@@ -920,7 +920,8 @@ xfs_attr_defer_add(
  */
 int
 xfs_attr_set(
-       struct xfs_da_args      *args)
+       struct xfs_da_args      *args,
+       enum xfs_attr_update    op)
 {
        struct xfs_inode        *dp = args->dp;
        struct xfs_mount        *mp = dp->i_mount;
@@ -1006,7 +1007,7 @@ xfs_attr_set(
                }
 
                /* Pure create fails if the attr already exists */
-               if (args->attr_flags & XATTR_CREATE)
+               if (op == XFS_ATTRUPDATE_CREATE)
                        goto out_trans_cancel;
                xfs_attr_defer_add(args, XFS_ATTRI_OP_FLAGS_REPLACE);
                break;
@@ -1016,7 +1017,7 @@ xfs_attr_set(
                        goto out_trans_cancel;
 
                /* Pure replace fails if no existing attr to replace. */
-               if (args->attr_flags & XATTR_REPLACE)
+               if (op == XFS_ATTRUPDATE_REPLACE)
                        goto out_trans_cancel;
                xfs_attr_defer_add(args, XFS_ATTRI_OP_FLAGS_SET);
                break;
index 670ab2a613fc671c50a530351a76d59d72488cce..228360f7c85ce7276ef8de9a20a6bad4b9160406 100644 (file)
@@ -544,7 +544,14 @@ int xfs_inode_hasattr(struct xfs_inode *ip);
 bool xfs_attr_is_leaf(struct xfs_inode *ip);
 int xfs_attr_get_ilocked(struct xfs_da_args *args);
 int xfs_attr_get(struct xfs_da_args *args);
-int xfs_attr_set(struct xfs_da_args *args);
+
+enum xfs_attr_update {
+       XFS_ATTRUPDATE_UPSERTR, /* set/remove value, replace any existing attr */
+       XFS_ATTRUPDATE_CREATE,  /* set value, fail if attr already exists */
+       XFS_ATTRUPDATE_REPLACE, /* set value, fail if attr does not exist */
+};
+
+int xfs_attr_set(struct xfs_da_args *args, enum xfs_attr_update op);
 int xfs_attr_set_iter(struct xfs_attr_intent *attr);
 int xfs_attr_remove_iter(struct xfs_attr_intent *attr);
 bool xfs_attr_namecheck(const void *name, size_t length);
index b04a3290ffacce7d7525e0bd291be0c10d509748..706b529a81febe25906c819040bf6a54ce2a0562 100644 (file)
@@ -60,7 +60,6 @@ typedef struct xfs_da_args {
        void            *value;         /* set of bytes (maybe contain NULLs) */
        int             valuelen;       /* length of value */
        unsigned int    attr_filter;    /* XFS_ATTR_{ROOT,SECURE,INCOMPLETE} */
-       unsigned int    attr_flags;     /* XATTR_{CREATE,REPLACE} */
        xfs_dahash_t    hashval;        /* hash value of name */
        xfs_ino_t       inumber;        /* input/output inode number */
        struct xfs_inode *dp;           /* directory inode to manipulate */