xfs: refactor log recovery item dispatch for pass2 readhead functions
[linux-block.git] / fs / xfs / xfs_buf_item_recover.c
CommitLineData
86ffa471
DW
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6#include "xfs.h"
7#include "xfs_fs.h"
8#include "xfs_shared.h"
9#include "xfs_format.h"
10#include "xfs_log_format.h"
11#include "xfs_trans_resv.h"
12#include "xfs_bit.h"
13#include "xfs_mount.h"
14#include "xfs_trans.h"
15#include "xfs_buf_item.h"
16#include "xfs_trans_priv.h"
17#include "xfs_trace.h"
18#include "xfs_log.h"
19#include "xfs_log_priv.h"
20#include "xfs_log_recover.h"
21
22/*
23 * Sort buffer items for log recovery. Most buffer items should end up on the
24 * buffer list and are recovered first, with the following exceptions:
25 *
26 * 1. XFS_BLF_CANCEL buffers must be processed last because some log items
27 * might depend on the incor ecancellation record, and replaying a cancelled
28 * buffer item can remove the incore record.
29 *
30 * 2. XFS_BLF_INODE_BUF buffers are handled after most regular items so that
31 * we replay di_next_unlinked only after flushing the inode 'free' state
32 * to the inode buffer.
33 *
34 * See xlog_recover_reorder_trans for more details.
35 */
36STATIC enum xlog_recover_reorder
37xlog_recover_buf_reorder(
38 struct xlog_recover_item *item)
39{
40 struct xfs_buf_log_format *buf_f = item->ri_buf[0].i_addr;
41
42 if (buf_f->blf_flags & XFS_BLF_CANCEL)
43 return XLOG_REORDER_CANCEL_LIST;
44 if (buf_f->blf_flags & XFS_BLF_INODE_BUF)
45 return XLOG_REORDER_INODE_BUFFER_LIST;
46 return XLOG_REORDER_BUFFER_LIST;
47}
48
8ea5682d
DW
49STATIC void
50xlog_recover_buf_ra_pass2(
51 struct xlog *log,
52 struct xlog_recover_item *item)
53{
54 struct xfs_buf_log_format *buf_f = item->ri_buf[0].i_addr;
55
56 xlog_buf_readahead(log, buf_f->blf_blkno, buf_f->blf_len, NULL);
57}
58
86ffa471
DW
59const struct xlog_recover_item_ops xlog_buf_item_ops = {
60 .item_type = XFS_LI_BUF,
61 .reorder = xlog_recover_buf_reorder,
8ea5682d 62 .ra_pass2 = xlog_recover_buf_ra_pass2,
86ffa471 63};