]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: create refcount update intent log items
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 25 Oct 2016 01:20:28 +0000 (12:20 +1100)
committerDave Chinner <david@fromorbit.com>
Tue, 25 Oct 2016 01:20:28 +0000 (12:20 +1100)
Source kernel commit: baf4bcacb715cebd412b2f4bb69989ef24496523

Create refcount update intent/done log items to record redo
information in the log.  Because we need to roll transactions between
updating the bmbt mapping and updating the reverse mapping, we also
have to track the status of the metadata updates that will be recorded
in the post-roll transactions, just in case we crash before committing
the final transaction.  This mechanism enables log recovery to finish
what was already started.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_log_format.h

index 770f16aee6fe0dbf62644038c6a9a647c1c95fab..554b02c2b46e09ee055de8a8f0368fd9416d95ce 100644 (file)
@@ -112,7 +112,9 @@ static inline uint xlog_get_cycle(char *ptr)
 #define XLOG_REG_TYPE_ICREATE          20
 #define XLOG_REG_TYPE_RUI_FORMAT       21
 #define XLOG_REG_TYPE_RUD_FORMAT       22
-#define XLOG_REG_TYPE_MAX              22
+#define XLOG_REG_TYPE_CUI_FORMAT       23
+#define XLOG_REG_TYPE_CUD_FORMAT       24
+#define XLOG_REG_TYPE_MAX              24
 
 /*
  * Flags to log operation header
@@ -231,6 +233,8 @@ typedef struct xfs_trans_header {
 #define        XFS_LI_ICREATE          0x123f
 #define        XFS_LI_RUI              0x1240  /* rmap update intent */
 #define        XFS_LI_RUD              0x1241
+#define        XFS_LI_CUI              0x1242  /* refcount update intent */
+#define        XFS_LI_CUD              0x1243
 
 #define XFS_LI_TYPE_DESC \
        { XFS_LI_EFI,           "XFS_LI_EFI" }, \
@@ -242,7 +246,9 @@ typedef struct xfs_trans_header {
        { XFS_LI_QUOTAOFF,      "XFS_LI_QUOTAOFF" }, \
        { XFS_LI_ICREATE,       "XFS_LI_ICREATE" }, \
        { XFS_LI_RUI,           "XFS_LI_RUI" }, \
-       { XFS_LI_RUD,           "XFS_LI_RUD" }
+       { XFS_LI_RUD,           "XFS_LI_RUD" }, \
+       { XFS_LI_CUI,           "XFS_LI_CUI" }, \
+       { XFS_LI_CUD,           "XFS_LI_CUD" }
 
 /*
  * Inode Log Item Format definitions.
@@ -670,6 +676,54 @@ struct xfs_rud_log_format {
        __uint64_t              rud_rui_id;     /* id of corresponding rui */
 };
 
+/*
+ * CUI/CUD (refcount update) log format definitions
+ */
+struct xfs_phys_extent {
+       __uint64_t              pe_startblock;
+       __uint32_t              pe_len;
+       __uint32_t              pe_flags;
+};
+
+/* refcount pe_flags: upper bits are flags, lower byte is type code */
+/* Type codes are taken directly from enum xfs_refcount_intent_type. */
+#define XFS_REFCOUNT_EXTENT_TYPE_MASK  0xFF
+
+#define XFS_REFCOUNT_EXTENT_FLAGS      (XFS_REFCOUNT_EXTENT_TYPE_MASK)
+
+/*
+ * This is the structure used to lay out a cui log item in the
+ * log.  The cui_extents field is a variable size array whose
+ * size is given by cui_nextents.
+ */
+struct xfs_cui_log_format {
+       __uint16_t              cui_type;       /* cui log item type */
+       __uint16_t              cui_size;       /* size of this item */
+       __uint32_t              cui_nextents;   /* # extents to free */
+       __uint64_t              cui_id;         /* cui identifier */
+       struct xfs_phys_extent  cui_extents[];  /* array of extents */
+};
+
+static inline size_t
+xfs_cui_log_format_sizeof(
+       unsigned int            nr)
+{
+       return sizeof(struct xfs_cui_log_format) +
+                       nr * sizeof(struct xfs_phys_extent);
+}
+
+/*
+ * This is the structure used to lay out a cud log item in the
+ * log.  The cud_extents array is a variable size array whose
+ * size is given by cud_nextents;
+ */
+struct xfs_cud_log_format {
+       __uint16_t              cud_type;       /* cud log item type */
+       __uint16_t              cud_size;       /* size of this item */
+       __uint32_t              __pad;
+       __uint64_t              cud_cui_id;     /* id of corresponding cui */
+};
+
 /*
  * Dquot Log format definitions.
  *