// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2000,2005 Silicon Graphics, Inc. * All Rights Reserved.
*/ #ifndef __XFS_LOG_RECOVER_H__ #define __XFS_LOG_RECOVER_H__
/* * Each log item type (XFS_LI_*) gets its own xlog_recover_item_ops to * define how recovery should work for that type of log item.
*/ struct xlog_recover_item; struct xfs_defer_op_type;
/* Sorting hat for log items as they're read in. */ enum xlog_recover_reorder {
XLOG_REORDER_BUFFER_LIST,
XLOG_REORDER_ITEM_LIST,
XLOG_REORDER_INODE_BUFFER_LIST,
XLOG_REORDER_CANCEL_LIST,
};
struct xlog_recover_item_ops {
uint16_t item_type; /* XFS_LI_* type code. */
/* * Help sort recovered log items into the order required to replay them * correctly. Log item types that always use XLOG_REORDER_ITEM_LIST do * not have to supply a function here. See the comment preceding * xlog_recover_reorder_trans for more details about what the return * values mean.
*/ enum xlog_recover_reorder (*reorder)(struct xlog_recover_item *item);
/* Start readahead for pass2, if provided. */ void (*ra_pass2)(struct xlog *log, struct xlog_recover_item *item);
/* Do whatever work we need to do for pass1, if provided. */ int (*commit_pass1)(struct xlog *log, struct xlog_recover_item *item);
/* * This function should do whatever work is needed for pass2 of log * recovery, if provided. * * If the recovered item is an intent item, this function should parse * the recovered item to construct an in-core log intent item and * insert it into the AIL. The in-core log intent item should have 1 * refcount so that the item is freed either (a) when we commit the * recovered log item for the intent-done item; (b) replay the work and * log a new intent-done item; or (c) recovery fails and we have to * abort. * * If the recovered item is an intent-done item, this function should * parse the recovered item to find the id of the corresponding intent * log item. Next, it should find the in-core log intent item in the * AIL and release it.
*/ int (*commit_pass2)(struct xlog *log, struct list_head *buffer_list, struct xlog_recover_item *item, xfs_lsn_t lsn);
};
/* * item headers are in ri_buf[0]. Additional buffers follow.
*/ struct xlog_recover_item { struct list_head ri_list; int ri_cnt; /* count of regions found */ int ri_total; /* total regions */ struct kvec *ri_buf; /* ptr to regions buffer */ conststruct xlog_recover_item_ops *ri_ops;
};
struct xlog_recover { struct hlist_node r_list;
xlog_tid_t r_log_tid; /* log's transaction id */
xfs_trans_header_t r_theader; /* trans header for partial */ int r_state; /* not needed */
xfs_lsn_t r_lsn; /* xact lsn */ struct list_head r_itemq; /* q for items */
};
#ifdef DEBUG void xlog_check_buf_cancel_table(struct xlog *log); #else #define xlog_check_buf_cancel_table(log) do { } while (0) #endif
/* * Transform a regular reservation into one suitable for recovery of a log * intent item. * * Intent recovery only runs a single step of the transaction chain and defers * the rest to a separate transaction. Therefore, we reduce logcount to 1 here * to avoid livelocks if the log grant space is nearly exhausted due to the * recovered intent pinning the tail. Keep the same logflags to avoid tripping * asserts elsewhere. Struct copies abound below.
*/ staticinlinestruct xfs_trans_res
xlog_recover_resv(conststruct xfs_trans_res *r)
{ struct xfs_trans_res ret = {
.tr_logres = r->tr_logres,
.tr_logcount = 1,
.tr_logflags = r->tr_logflags,
};