hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/fs/xfs/libxfs/xfs_log_recover.h
....@@ -7,6 +7,73 @@
77 #define __XFS_LOG_RECOVER_H__
88
99 /*
10
+ * Each log item type (XFS_LI_*) gets its own xlog_recover_item_ops to
11
+ * define how recovery should work for that type of log item.
12
+ */
13
+struct xlog_recover_item;
14
+
15
+/* Sorting hat for log items as they're read in. */
16
+enum xlog_recover_reorder {
17
+ XLOG_REORDER_BUFFER_LIST,
18
+ XLOG_REORDER_ITEM_LIST,
19
+ XLOG_REORDER_INODE_BUFFER_LIST,
20
+ XLOG_REORDER_CANCEL_LIST,
21
+};
22
+
23
+struct xlog_recover_item_ops {
24
+ uint16_t item_type; /* XFS_LI_* type code. */
25
+
26
+ /*
27
+ * Help sort recovered log items into the order required to replay them
28
+ * correctly. Log item types that always use XLOG_REORDER_ITEM_LIST do
29
+ * not have to supply a function here. See the comment preceding
30
+ * xlog_recover_reorder_trans for more details about what the return
31
+ * values mean.
32
+ */
33
+ enum xlog_recover_reorder (*reorder)(struct xlog_recover_item *item);
34
+
35
+ /* Start readahead for pass2, if provided. */
36
+ void (*ra_pass2)(struct xlog *log, struct xlog_recover_item *item);
37
+
38
+ /* Do whatever work we need to do for pass1, if provided. */
39
+ int (*commit_pass1)(struct xlog *log, struct xlog_recover_item *item);
40
+
41
+ /*
42
+ * This function should do whatever work is needed for pass2 of log
43
+ * recovery, if provided.
44
+ *
45
+ * If the recovered item is an intent item, this function should parse
46
+ * the recovered item to construct an in-core log intent item and
47
+ * insert it into the AIL. The in-core log intent item should have 1
48
+ * refcount so that the item is freed either (a) when we commit the
49
+ * recovered log item for the intent-done item; (b) replay the work and
50
+ * log a new intent-done item; or (c) recovery fails and we have to
51
+ * abort.
52
+ *
53
+ * If the recovered item is an intent-done item, this function should
54
+ * parse the recovered item to find the id of the corresponding intent
55
+ * log item. Next, it should find the in-core log intent item in the
56
+ * AIL and release it.
57
+ */
58
+ int (*commit_pass2)(struct xlog *log, struct list_head *buffer_list,
59
+ struct xlog_recover_item *item, xfs_lsn_t lsn);
60
+};
61
+
62
+extern const struct xlog_recover_item_ops xlog_icreate_item_ops;
63
+extern const struct xlog_recover_item_ops xlog_buf_item_ops;
64
+extern const struct xlog_recover_item_ops xlog_inode_item_ops;
65
+extern const struct xlog_recover_item_ops xlog_dquot_item_ops;
66
+extern const struct xlog_recover_item_ops xlog_quotaoff_item_ops;
67
+extern const struct xlog_recover_item_ops xlog_bui_item_ops;
68
+extern const struct xlog_recover_item_ops xlog_bud_item_ops;
69
+extern const struct xlog_recover_item_ops xlog_efi_item_ops;
70
+extern const struct xlog_recover_item_ops xlog_efd_item_ops;
71
+extern const struct xlog_recover_item_ops xlog_rui_item_ops;
72
+extern const struct xlog_recover_item_ops xlog_rud_item_ops;
73
+extern const struct xlog_recover_item_ops xlog_cui_item_ops;
74
+extern const struct xlog_recover_item_ops xlog_cud_item_ops;
75
+
76
+/*
1077 * Macros, structures, prototypes for internal log manager use.
1178 */
1279
....@@ -22,22 +89,22 @@
2289 /*
2390 * item headers are in ri_buf[0]. Additional buffers follow.
2491 */
25
-typedef struct xlog_recover_item {
92
+struct xlog_recover_item {
2693 struct list_head ri_list;
27
- int ri_type;
2894 int ri_cnt; /* count of regions found */
2995 int ri_total; /* total regions */
30
- xfs_log_iovec_t *ri_buf; /* ptr to regions buffer */
31
-} xlog_recover_item_t;
96
+ struct xfs_log_iovec *ri_buf; /* ptr to regions buffer */
97
+ const struct xlog_recover_item_ops *ri_ops;
98
+};
3299
33
-typedef struct xlog_recover {
100
+struct xlog_recover {
34101 struct hlist_node r_list;
35102 xlog_tid_t r_log_tid; /* log's transaction id */
36103 xfs_trans_header_t r_theader; /* trans header for partial */
37104 int r_state; /* not needed */
38105 xfs_lsn_t r_lsn; /* xact lsn */
39106 struct list_head r_itemq; /* q for items */
40
-} xlog_recover_t;
107
+};
41108
42109 #define ITEM_TYPE(i) (*(unsigned short *)(i)->ri_buf[0].i_addr)
43110
....@@ -51,4 +118,11 @@
51118 #define XLOG_RECOVER_PASS1 1
52119 #define XLOG_RECOVER_PASS2 2
53120
121
+void xlog_buf_readahead(struct xlog *log, xfs_daddr_t blkno, uint len,
122
+ const struct xfs_buf_ops *ops);
123
+bool xlog_is_buffer_cancelled(struct xlog *log, xfs_daddr_t blkno, uint len);
124
+
125
+void xlog_recover_release_intent(struct xlog *log, unsigned short intent_type,
126
+ uint64_t intent_id);
127
+
54128 #endif /* __XFS_LOG_RECOVER_H__ */