Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 3 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
| 4 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __XFS_LOG_RECOVER_H__ |
| 7 | #define __XFS_LOG_RECOVER_H__ |
| 8 | |
| 9 | /* |
Darrick J. Wong | 86ffa47 | 2020-05-01 16:00:45 -0700 | [diff] [blame^] | 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 | |
| 36 | extern const struct xlog_recover_item_ops xlog_icreate_item_ops; |
| 37 | extern const struct xlog_recover_item_ops xlog_buf_item_ops; |
| 38 | extern const struct xlog_recover_item_ops xlog_inode_item_ops; |
| 39 | extern const struct xlog_recover_item_ops xlog_dquot_item_ops; |
| 40 | extern const struct xlog_recover_item_ops xlog_quotaoff_item_ops; |
| 41 | extern const struct xlog_recover_item_ops xlog_bui_item_ops; |
| 42 | extern const struct xlog_recover_item_ops xlog_bud_item_ops; |
| 43 | extern const struct xlog_recover_item_ops xlog_efi_item_ops; |
| 44 | extern const struct xlog_recover_item_ops xlog_efd_item_ops; |
| 45 | extern const struct xlog_recover_item_ops xlog_rui_item_ops; |
| 46 | extern const struct xlog_recover_item_ops xlog_rud_item_ops; |
| 47 | extern const struct xlog_recover_item_ops xlog_cui_item_ops; |
| 48 | extern const struct xlog_recover_item_ops xlog_cud_item_ops; |
| 49 | |
| 50 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | * Macros, structures, prototypes for internal log manager use. |
| 52 | */ |
| 53 | |
| 54 | #define XLOG_RHASH_BITS 4 |
| 55 | #define XLOG_RHASH_SIZE 16 |
| 56 | #define XLOG_RHASH_SHIFT 2 |
| 57 | #define XLOG_RHASH(tid) \ |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 58 | ((((uint32_t)tid)>>XLOG_RHASH_SHIFT) & (XLOG_RHASH_SIZE-1)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
Dave Chinner | c115541 | 2010-05-07 11:05:19 +1000 | [diff] [blame] | 60 | #define XLOG_MAX_REGIONS_IN_ITEM (XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK / 2 + 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
| 62 | |
| 63 | /* |
| 64 | * item headers are in ri_buf[0]. Additional buffers follow. |
| 65 | */ |
Darrick J. Wong | 35f4521 | 2020-04-30 10:45:41 -0700 | [diff] [blame] | 66 | struct xlog_recover_item { |
Dave Chinner | f0a7695 | 2010-01-11 11:49:57 +0000 | [diff] [blame] | 67 | struct list_head ri_list; |
Dave Chinner | f0a7695 | 2010-01-11 11:49:57 +0000 | [diff] [blame] | 68 | int ri_cnt; /* count of regions found */ |
| 69 | int ri_total; /* total regions */ |
Darrick J. Wong | 86ffa47 | 2020-05-01 16:00:45 -0700 | [diff] [blame^] | 70 | struct xfs_log_iovec *ri_buf; /* ptr to regions buffer */ |
| 71 | const struct xlog_recover_item_ops *ri_ops; |
Darrick J. Wong | 35f4521 | 2020-04-30 10:45:41 -0700 | [diff] [blame] | 72 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
Eric Sandeen | 35dab30 | 2019-11-12 17:04:28 -0800 | [diff] [blame] | 74 | struct xlog_recover { |
Dave Chinner | f0a7695 | 2010-01-11 11:49:57 +0000 | [diff] [blame] | 75 | struct hlist_node r_list; |
| 76 | xlog_tid_t r_log_tid; /* log's transaction id */ |
| 77 | xfs_trans_header_t r_theader; /* trans header for partial */ |
| 78 | int r_state; /* not needed */ |
| 79 | xfs_lsn_t r_lsn; /* xact lsn */ |
| 80 | struct list_head r_itemq; /* q for items */ |
Eric Sandeen | 35dab30 | 2019-11-12 17:04:28 -0800 | [diff] [blame] | 81 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
Darrick J. Wong | 755c7bf | 2016-11-08 11:55:48 +1100 | [diff] [blame] | 83 | #define ITEM_TYPE(i) (*(unsigned short *)(i)->ri_buf[0].i_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
| 85 | /* |
| 86 | * This is the number of entries in the l_buf_cancel_table used during |
| 87 | * recovery. |
| 88 | */ |
| 89 | #define XLOG_BC_TABLE_SIZE 64 |
| 90 | |
Brian Foster | 6528250 | 2016-01-04 15:55:10 +1100 | [diff] [blame] | 91 | #define XLOG_RECOVER_CRCPASS 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | #define XLOG_RECOVER_PASS1 1 |
| 93 | #define XLOG_RECOVER_PASS2 2 |
| 94 | |
| 95 | #endif /* __XFS_LOG_RECOVER_H__ */ |