Loading...
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6#ifndef __XFS_LOG_RECOVER_H__
7#define __XFS_LOG_RECOVER_H__
8
9/*
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 */
13struct xlog_recover_item;
14
15/* Sorting hat for log items as they're read in. */
16enum 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
23struct 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
62extern const struct xlog_recover_item_ops xlog_icreate_item_ops;
63extern const struct xlog_recover_item_ops xlog_buf_item_ops;
64extern const struct xlog_recover_item_ops xlog_inode_item_ops;
65extern const struct xlog_recover_item_ops xlog_dquot_item_ops;
66extern const struct xlog_recover_item_ops xlog_quotaoff_item_ops;
67extern const struct xlog_recover_item_ops xlog_bui_item_ops;
68extern const struct xlog_recover_item_ops xlog_bud_item_ops;
69extern const struct xlog_recover_item_ops xlog_efi_item_ops;
70extern const struct xlog_recover_item_ops xlog_efd_item_ops;
71extern const struct xlog_recover_item_ops xlog_rui_item_ops;
72extern const struct xlog_recover_item_ops xlog_rud_item_ops;
73extern const struct xlog_recover_item_ops xlog_cui_item_ops;
74extern const struct xlog_recover_item_ops xlog_cud_item_ops;
75extern const struct xlog_recover_item_ops xlog_attri_item_ops;
76extern const struct xlog_recover_item_ops xlog_attrd_item_ops;
77
78/*
79 * Macros, structures, prototypes for internal log manager use.
80 */
81
82#define XLOG_RHASH_BITS 4
83#define XLOG_RHASH_SIZE 16
84#define XLOG_RHASH_SHIFT 2
85#define XLOG_RHASH(tid) \
86 ((((uint32_t)tid)>>XLOG_RHASH_SHIFT) & (XLOG_RHASH_SIZE-1))
87
88#define XLOG_MAX_REGIONS_IN_ITEM (XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK / 2 + 1)
89
90
91/*
92 * item headers are in ri_buf[0]. Additional buffers follow.
93 */
94struct xlog_recover_item {
95 struct list_head ri_list;
96 int ri_cnt; /* count of regions found */
97 int ri_total; /* total regions */
98 struct xfs_log_iovec *ri_buf; /* ptr to regions buffer */
99 const struct xlog_recover_item_ops *ri_ops;
100};
101
102struct xlog_recover {
103 struct hlist_node r_list;
104 xlog_tid_t r_log_tid; /* log's transaction id */
105 xfs_trans_header_t r_theader; /* trans header for partial */
106 int r_state; /* not needed */
107 xfs_lsn_t r_lsn; /* xact lsn */
108 struct list_head r_itemq; /* q for items */
109};
110
111#define ITEM_TYPE(i) (*(unsigned short *)(i)->ri_buf[0].i_addr)
112
113#define XLOG_RECOVER_CRCPASS 0
114#define XLOG_RECOVER_PASS1 1
115#define XLOG_RECOVER_PASS2 2
116
117void xlog_buf_readahead(struct xlog *log, xfs_daddr_t blkno, uint len,
118 const struct xfs_buf_ops *ops);
119bool xlog_is_buffer_cancelled(struct xlog *log, xfs_daddr_t blkno, uint len);
120
121int xlog_recover_iget(struct xfs_mount *mp, xfs_ino_t ino,
122 struct xfs_inode **ipp);
123void xlog_recover_release_intent(struct xlog *log, unsigned short intent_type,
124 uint64_t intent_id);
125int xlog_alloc_buf_cancel_table(struct xlog *log);
126void xlog_free_buf_cancel_table(struct xlog *log);
127
128#ifdef DEBUG
129void xlog_check_buf_cancel_table(struct xlog *log);
130#else
131#define xlog_check_buf_cancel_table(log) do { } while (0)
132#endif
133
134#endif /* __XFS_LOG_RECOVER_H__ */
1/*
2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18#ifndef __XFS_LOG_RECOVER_H__
19#define __XFS_LOG_RECOVER_H__
20
21/*
22 * Macros, structures, prototypes for internal log manager use.
23 */
24
25#define XLOG_RHASH_BITS 4
26#define XLOG_RHASH_SIZE 16
27#define XLOG_RHASH_SHIFT 2
28#define XLOG_RHASH(tid) \
29 ((((__uint32_t)tid)>>XLOG_RHASH_SHIFT) & (XLOG_RHASH_SIZE-1))
30
31#define XLOG_MAX_REGIONS_IN_ITEM (XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK / 2 + 1)
32
33
34/*
35 * item headers are in ri_buf[0]. Additional buffers follow.
36 */
37typedef struct xlog_recover_item {
38 struct list_head ri_list;
39 int ri_type;
40 int ri_cnt; /* count of regions found */
41 int ri_total; /* total regions */
42 xfs_log_iovec_t *ri_buf; /* ptr to regions buffer */
43} xlog_recover_item_t;
44
45struct xlog_tid;
46typedef struct xlog_recover {
47 struct hlist_node r_list;
48 xlog_tid_t r_log_tid; /* log's transaction id */
49 xfs_trans_header_t r_theader; /* trans header for partial */
50 int r_state; /* not needed */
51 xfs_lsn_t r_lsn; /* xact lsn */
52 struct list_head r_itemq; /* q for items */
53} xlog_recover_t;
54
55#define ITEM_TYPE(i) (*(ushort *)(i)->ri_buf[0].i_addr)
56
57/*
58 * This is the number of entries in the l_buf_cancel_table used during
59 * recovery.
60 */
61#define XLOG_BC_TABLE_SIZE 64
62
63#define XLOG_RECOVER_CRCPASS 0
64#define XLOG_RECOVER_PASS1 1
65#define XLOG_RECOVER_PASS2 2
66
67#endif /* __XFS_LOG_RECOVER_H__ */