]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: create attr log item opcodes and formats for parent pointers
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:22:46 +0000 (16:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:02 +0000 (17:01 -0700)
Source kernel commit: 5773f7f82be5aa98e4883566072d33342814cebe

Make the necessary alterations to the extended attribute log intent item
ondisk format so that we can log parent pointer operations.  This
requires the creation of new opcodes specific to parent pointers, and a
new four-argument replace operation to handle renames.  At this point
this part of the patchset has changed so much from what Allison original
wrote that I no longer think her SoB applies.

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

index 91e7961c2fad79c8358ae2c8554a716578379fba..c67cdc77a74ba8ba846acd8f80ebb01098bac51d 100644 (file)
@@ -438,6 +438,23 @@ xfs_attr_hashval(
        return xfs_attr_hashname(name, namelen);
 }
 
+/*
+ * PPTR_REPLACE operations require the caller to set the old and new names and
+ * values explicitly.  Update the canonical fields to the new name and value
+ * here now that the removal phase has finished.
+ */
+static void
+xfs_attr_update_pptr_replace_args(
+       struct xfs_da_args      *args)
+{
+       ASSERT(args->new_namelen > 0);
+       args->name = args->new_name;
+       args->namelen = args->new_namelen;
+       args->value = args->new_value;
+       args->valuelen = args->new_valuelen;
+       xfs_attr_sethash(args);
+}
+
 /*
  * Handle the state change on completion of a multi-state attr operation.
  *
@@ -458,6 +475,8 @@ xfs_attr_complete_op(
 
        if (!(args->op_flags & XFS_DA_OP_REPLACE))
                replace_state = XFS_DAS_DONE;
+       else if (xfs_attr_intent_op(attr) == XFS_ATTRI_OP_FLAGS_PPTR_REPLACE)
+               xfs_attr_update_pptr_replace_args(args);
 
        args->op_flags &= ~XFS_DA_OP_REPLACE;
        args->attr_filter &= ~XFS_ATTR_INCOMPLETE;
index c63b1d610e53bc0319ea88b6d50749b105cbbbf7..d0ed7ea58ab0f14be997dda3882e94112691150f 100644 (file)
@@ -510,8 +510,8 @@ struct xfs_attr_intent {
        struct xfs_da_args              *xattri_da_args;
 
        /*
-        * Shared buffer containing the attr name and value so that the logging
-        * code can share large memory buffers between log items.
+        * Shared buffer containing the attr name, new name, and value so that
+        * the logging code can share large memory buffers between log items.
         */
        struct xfs_attri_log_nameval    *xattri_nameval;
 
index 17cef594b5bbbd89ea2db736a2882321d2b682b3..354d5d65043e432af0261297f16f198c82fd636d 100644 (file)
@@ -55,7 +55,9 @@ enum xfs_dacmp {
 typedef struct xfs_da_args {
        struct xfs_da_geometry *geo;    /* da block geometry */
        const uint8_t   *name;          /* string (maybe not NULL terminated) */
+       const uint8_t   *new_name;      /* new attr name */
        void            *value;         /* set of bytes (maybe contain NULLs) */
+       void            *new_value;     /* new xattr value (may contain NULLs) */
        struct xfs_inode *dp;           /* directory inode to manipulate */
        struct xfs_trans *trans;        /* current trans (changes over time) */
 
@@ -63,10 +65,12 @@ typedef struct xfs_da_args {
        xfs_ino_t       owner;          /* inode that owns the dir/attr data */
 
        int             valuelen;       /* length of value */
+       int             new_valuelen;   /* length of new_value */
        uint8_t         filetype;       /* filetype of inode for directories */
        uint8_t         op_flags;       /* operation flags */
        uint8_t         attr_filter;    /* XFS_ATTR_{ROOT,SECURE,INCOMPLETE} */
        short           namelen;        /* length of string (maybe no NULL) */
+       short           new_namelen;    /* length of new attr name */
        xfs_dahash_t    hashval;        /* hash value of name */
        xfs_extlen_t    total;          /* total blocks needed, for 1st bmap */
        int             whichfork;      /* data or attribute fork */
index 020aebd101432d96ccedf9d86b4360aaa7d1dcf6..632dd97324557a04d69042d452be230d41a49c82 100644 (file)
@@ -115,11 +115,13 @@ struct xfs_unmount_log_format {
 #define XLOG_REG_TYPE_BUD_FORMAT       26
 #define XLOG_REG_TYPE_ATTRI_FORMAT     27
 #define XLOG_REG_TYPE_ATTRD_FORMAT     28
-#define XLOG_REG_TYPE_ATTR_NAME        29
+#define XLOG_REG_TYPE_ATTR_NAME                29
 #define XLOG_REG_TYPE_ATTR_VALUE       30
 #define XLOG_REG_TYPE_XMI_FORMAT       31
 #define XLOG_REG_TYPE_XMD_FORMAT       32
-#define XLOG_REG_TYPE_MAX              32
+#define XLOG_REG_TYPE_ATTR_NEWNAME     33
+#define XLOG_REG_TYPE_ATTR_NEWVALUE    34
+#define XLOG_REG_TYPE_MAX              34
 
 /*
  * Flags to log operation header
@@ -1026,6 +1028,9 @@ struct xfs_icreate_log {
 #define XFS_ATTRI_OP_FLAGS_SET         1       /* Set the attribute */
 #define XFS_ATTRI_OP_FLAGS_REMOVE      2       /* Remove the attribute */
 #define XFS_ATTRI_OP_FLAGS_REPLACE     3       /* Replace the attribute */
+#define XFS_ATTRI_OP_FLAGS_PPTR_SET    4       /* Set parent pointer */
+#define XFS_ATTRI_OP_FLAGS_PPTR_REMOVE 5       /* Remove parent pointer */
+#define XFS_ATTRI_OP_FLAGS_PPTR_REPLACE        6       /* Replace parent pointer */
 #define XFS_ATTRI_OP_FLAGS_TYPE_MASK   0xFF    /* Flags type mask */
 
 /*
@@ -1048,7 +1053,18 @@ struct xfs_attri_log_format {
        uint64_t        alfi_id;        /* attri identifier */
        uint64_t        alfi_ino;       /* the inode for this attr operation */
        uint32_t        alfi_op_flags;  /* marks the op as a set or remove */
-       uint32_t        alfi_name_len;  /* attr name length */
+       union {
+               uint32_t        alfi_name_len;  /* attr name length */
+               struct {
+                       /*
+                        * For PPTR_REPLACE, these are the lengths of the old
+                        * and new attr names.  The new and old values must
+                        * have the same length.
+                        */
+                       uint16_t        alfi_old_name_len;
+                       uint16_t        alfi_new_name_len;
+               };
+       };
        uint32_t        alfi_value_len; /* attr value length */
        uint32_t        alfi_attr_filter;/* attr filter flags */
 };