xfs: use helpers to extract xattr op from opflags
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 16:47:29 +0000 (09:47 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 23 Apr 2024 14:46:53 +0000 (07:46 -0700)
Create helper functions to extract the xattr op from the ondisk xattri
log item and the incore attr intent item.  These will get more use in
the patches that follow.

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

index c8005f52102adc530efbd7308bba9524cb76cb1e..79b457adb7bda0acae237ddaf30f17735825bdbb 100644 (file)
@@ -529,6 +529,11 @@ struct xfs_attr_intent {
        struct xfs_bmbt_irec            xattri_map;
 };
 
+static inline unsigned int
+xfs_attr_intent_op(const struct xfs_attr_intent *attr)
+{
+       return attr->xattri_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK;
+}
 
 /*========================================================================
  * Function prototypes for the kernel.
index d3559e6b24b7db687ee6793269a358c2add0c1ff..b4c2dcb4581bc3df218f8da1f0654b8d02b23f1e 100644 (file)
@@ -308,6 +308,12 @@ xfs_attrd_item_intent(
        return &ATTRD_ITEM(lip)->attrd_attrip->attri_item;
 }
 
+static inline unsigned int
+xfs_attr_log_item_op(const struct xfs_attri_log_format *attrp)
+{
+       return attrp->alfi_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK;
+}
+
 /* Log an attr to the intent item. */
 STATIC void
 xfs_attr_log_item(
@@ -466,8 +472,7 @@ xfs_attri_validate(
        struct xfs_mount                *mp,
        struct xfs_attri_log_format     *attrp)
 {
-       unsigned int                    op = attrp->alfi_op_flags &
-                                            XFS_ATTRI_OP_FLAGS_TYPE_MASK;
+       unsigned int                    op = xfs_attr_log_item_op(attrp);
 
        if (!xfs_is_using_logged_xattrs(mp))
                return false;
@@ -551,8 +556,7 @@ xfs_attri_recover_work(
        args = (struct xfs_da_args *)(attr + 1);
 
        attr->xattri_da_args = args;
-       attr->xattri_op_flags = attrp->alfi_op_flags &
-                                               XFS_ATTRI_OP_FLAGS_TYPE_MASK;
+       attr->xattri_op_flags = xfs_attr_log_item_op(attrp);
 
        /*
         * We're reconstructing the deferred work state structure from the
@@ -573,7 +577,7 @@ xfs_attri_recover_work(
                         XFS_DA_OP_LOGGED;
        args->owner = args->dp->i_ino;
 
-       switch (attr->xattri_op_flags) {
+       switch (xfs_attr_intent_op(attr)) {
        case XFS_ATTRI_OP_FLAGS_SET:
        case XFS_ATTRI_OP_FLAGS_REPLACE:
                args->value = nv->value.i_addr;
@@ -757,7 +761,7 @@ xlog_recover_attri_commit_pass2(
        }
 
        /* Check the number of log iovecs makes sense for the op code. */
-       op = attri_formatp->alfi_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK;
+       op = xfs_attr_log_item_op(attri_formatp);
        switch (op) {
        case XFS_ATTRI_OP_FLAGS_SET:
        case XFS_ATTRI_OP_FLAGS_REPLACE: