]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: create rmap update intent log items
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 10 Aug 2016 04:49:16 +0000 (14:49 +1000)
committerDave Chinner <david@fromorbit.com>
Wed, 10 Aug 2016 04:49:16 +0000 (14:49 +1000)
Source kernel commit: 5880f2d78ff17c6ee7c7f6d4071bfd13090c264c

Create rmap 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: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_rmap_item.c [new file with mode: 0644]
fs/xfs/xfs_rmap_item.h [new file with mode: 0644]
libxfs/xfs_log_format.h
libxfs/xfs_rmap.h

diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/fs/xfs/xfs_rmap_item.h b/fs/xfs/xfs_rmap_item.h
new file mode 100644 (file)
index 0000000..e69de29
index e5baba3c24438e5776bc8d87c6bc2519b7f38685..06d00bd51c894d72f243aba5fad777f913c9685f 100644 (file)
@@ -110,7 +110,9 @@ static inline uint xlog_get_cycle(char *ptr)
 #define XLOG_REG_TYPE_COMMIT           18
 #define XLOG_REG_TYPE_TRANSHDR         19
 #define XLOG_REG_TYPE_ICREATE          20
-#define XLOG_REG_TYPE_MAX              20
+#define XLOG_REG_TYPE_RUI_FORMAT       21
+#define XLOG_REG_TYPE_RUD_FORMAT       22
+#define XLOG_REG_TYPE_MAX              22
 
 /*
  * Flags to log operation header
@@ -227,6 +229,8 @@ typedef struct xfs_trans_header {
 #define        XFS_LI_DQUOT            0x123d
 #define        XFS_LI_QUOTAOFF         0x123e
 #define        XFS_LI_ICREATE          0x123f
+#define        XFS_LI_RUI              0x1240  /* rmap update intent */
+#define        XFS_LI_RUD              0x1241
 
 #define XFS_LI_TYPE_DESC \
        { XFS_LI_EFI,           "XFS_LI_EFI" }, \
@@ -236,7 +240,9 @@ typedef struct xfs_trans_header {
        { XFS_LI_BUF,           "XFS_LI_BUF" }, \
        { XFS_LI_DQUOT,         "XFS_LI_DQUOT" }, \
        { XFS_LI_QUOTAOFF,      "XFS_LI_QUOTAOFF" }, \
-       { XFS_LI_ICREATE,       "XFS_LI_ICREATE" }
+       { XFS_LI_ICREATE,       "XFS_LI_ICREATE" }, \
+       { XFS_LI_RUI,           "XFS_LI_RUI" }, \
+       { XFS_LI_RUD,           "XFS_LI_RUD" }
 
 /*
  * Inode Log Item Format definitions.
@@ -603,6 +609,60 @@ typedef struct xfs_efd_log_format_64 {
        xfs_extent_64_t         efd_extents[1]; /* array of extents freed */
 } xfs_efd_log_format_64_t;
 
+/*
+ * RUI/RUD (reverse mapping) log format definitions
+ */
+struct xfs_map_extent {
+       __uint64_t              me_owner;
+       __uint64_t              me_startblock;
+       __uint64_t              me_startoff;
+       __uint32_t              me_len;
+       __uint32_t              me_flags;
+};
+
+/* rmap me_flags: upper bits are flags, lower byte is type code */
+#define XFS_RMAP_EXTENT_MAP            1
+#define XFS_RMAP_EXTENT_UNMAP          3
+#define XFS_RMAP_EXTENT_CONVERT                5
+#define XFS_RMAP_EXTENT_ALLOC          7
+#define XFS_RMAP_EXTENT_FREE           8
+#define XFS_RMAP_EXTENT_TYPE_MASK      0xFF
+
+#define XFS_RMAP_EXTENT_ATTR_FORK      (1U << 31)
+#define XFS_RMAP_EXTENT_BMBT_BLOCK     (1U << 30)
+#define XFS_RMAP_EXTENT_UNWRITTEN      (1U << 29)
+
+#define XFS_RMAP_EXTENT_FLAGS          (XFS_RMAP_EXTENT_TYPE_MASK | \
+                                        XFS_RMAP_EXTENT_ATTR_FORK | \
+                                        XFS_RMAP_EXTENT_BMBT_BLOCK | \
+                                        XFS_RMAP_EXTENT_UNWRITTEN)
+
+/*
+ * This is the structure used to lay out an rui log item in the
+ * log.  The rui_extents field is a variable size array whose
+ * size is given by rui_nextents.
+ */
+struct xfs_rui_log_format {
+       __uint16_t              rui_type;       /* rui log item type */
+       __uint16_t              rui_size;       /* size of this item */
+       __uint32_t              rui_nextents;   /* # extents to free */
+       __uint64_t              rui_id;         /* rui identifier */
+       struct xfs_map_extent   rui_extents[1]; /* array of extents to rmap */
+};
+
+/*
+ * This is the structure used to lay out an rud log item in the
+ * log.  The rud_extents array is a variable size array whose
+ * size is given by rud_nextents;
+ */
+struct xfs_rud_log_format {
+       __uint16_t              rud_type;       /* rud log item type */
+       __uint16_t              rud_size;       /* size of this item */
+       __uint32_t              rud_nextents;   /* # of extents freed */
+       __uint64_t              rud_rui_id;     /* id of corresponding rui */
+       struct xfs_map_extent   rud_extents[1]; /* array of extents rmapped */
+};
+
 /*
  * Dquot Log format definitions.
  *
index 92ac067da7dd144e1ac1f3e7a56ff04277cd2d7c..c4b1133e2ff97c0de7cf7ab97f98ac6e757811ca 100644 (file)
@@ -163,4 +163,23 @@ int xfs_rmap_query_range(struct xfs_btree_cur *cur,
                struct xfs_rmap_irec *low_rec, struct xfs_rmap_irec *high_rec,
                xfs_rmap_query_range_fn fn, void *priv);
 
+enum xfs_rmap_intent_type {
+       XFS_RMAP_MAP,
+       XFS_RMAP_MAP_SHARED,
+       XFS_RMAP_UNMAP,
+       XFS_RMAP_UNMAP_SHARED,
+       XFS_RMAP_CONVERT,
+       XFS_RMAP_CONVERT_SHARED,
+       XFS_RMAP_ALLOC,
+       XFS_RMAP_FREE,
+};
+
+struct xfs_rmap_intent {
+       struct list_head                        ri_list;
+       enum xfs_rmap_intent_type               ri_type;
+       __uint64_t                              ri_owner;
+       int                                     ri_whichfork;
+       struct xfs_bmbt_irec                    ri_bmap;
+};
+
 #endif /* __XFS_RMAP_H__ */