]> Git Repo - linux.git/blame - fs/xfs/scrub/repair.h
xfs: repair free space btrees
[linux.git] / fs / xfs / scrub / repair.h
CommitLineData
739a2fe0 1// SPDX-License-Identifier: GPL-2.0-or-later
84d42ea6 2/*
ecc73f8a 3 * Copyright (C) 2018-2023 Oracle. All Rights Reserved.
739a2fe0 4 * Author: Darrick J. Wong <[email protected]>
84d42ea6
DW
5 */
6#ifndef __XFS_SCRUB_REPAIR_H__
7#define __XFS_SCRUB_REPAIR_H__
8
1a7ed271
DW
9#include "xfs_quota_defs.h"
10
d7a74cad
DW
11struct xchk_stats_run;
12
1d8a748a 13static inline int xrep_notsupported(struct xfs_scrub *sc)
84d42ea6
DW
14{
15 return -EOPNOTSUPP;
16}
17
18#ifdef CONFIG_XFS_ONLINE_REPAIR
19
1c7ce115
DW
20/*
21 * This is the maximum number of deferred extent freeing item extents (EFIs)
22 * that we'll attach to a transaction without rolling the transaction to avoid
23 * overrunning a tr_itruncate reservation.
24 */
25#define XREP_MAX_ITRUNCATE_EFIS (128)
26
27
84d42ea6
DW
28/* Repair helpers */
29
d7a74cad 30int xrep_attempt(struct xfs_scrub *sc, struct xchk_stats_run *run);
b5e2196e 31void xrep_failure(struct xfs_mount *mp);
1d8a748a 32int xrep_roll_ag_trans(struct xfs_scrub *sc);
1c7ce115 33int xrep_defer_finish(struct xfs_scrub *sc);
b5e2196e 34bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
0a9633fa 35 enum xfs_ag_resv_type type);
1d8a748a 36xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc);
84d42ea6 37
00b10d48 38struct xbitmap;
a47bd1e0 39struct xagb_bitmap;
64a39d87 40
1d8a748a 41int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink);
64a39d87 42
b5e2196e 43struct xrep_find_ag_btree {
04a2b7b2
DW
44 /* in: rmap owner of the btree we're looking for */
45 uint64_t rmap_owner;
46
47 /* in: buffer ops */
48 const struct xfs_buf_ops *buf_ops;
49
1ba6fd34
DW
50 /* in: maximum btree height */
51 unsigned int maxlevels;
52
04a2b7b2
DW
53 /* out: the highest btree block found and the tree height */
54 xfs_agblock_t root;
55 unsigned int height;
56};
57
032d91f9
DW
58int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp,
59 struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp);
1a7ed271 60void xrep_force_quotacheck(struct xfs_scrub *sc, xfs_dqtype_t type);
1d8a748a 61int xrep_ino_dqattach(struct xfs_scrub *sc);
04a2b7b2 62
4bdfd7d1
DW
63/* Repair setup functions */
64int xrep_setup_ag_allocbt(struct xfs_scrub *sc);
65
66void xrep_ag_btcur_init(struct xfs_scrub *sc, struct xchk_ag *sa);
67
68/* Metadata revalidators */
69
70int xrep_revalidate_allocbt(struct xfs_scrub *sc);
71
84d42ea6
DW
72/* Metadata repairers */
73
1d8a748a
DW
74int xrep_probe(struct xfs_scrub *sc);
75int xrep_superblock(struct xfs_scrub *sc);
f9ed6deb 76int xrep_agf(struct xfs_scrub *sc);
0e93d3f4 77int xrep_agfl(struct xfs_scrub *sc);
13942aa9 78int xrep_agi(struct xfs_scrub *sc);
4bdfd7d1
DW
79int xrep_allocbt(struct xfs_scrub *sc);
80
81int xrep_reinit_pagf(struct xfs_scrub *sc);
84d42ea6
DW
82
83#else
84
026f57eb
DW
85static inline int
86xrep_attempt(
d7a74cad
DW
87 struct xfs_scrub *sc,
88 struct xchk_stats_run *run)
84d42ea6
DW
89{
90 return -EOPNOTSUPP;
91}
92
b5e2196e 93static inline void xrep_failure(struct xfs_mount *mp) {}
84d42ea6 94
0a9633fa 95static inline xfs_extlen_t
b5e2196e 96xrep_calc_ag_resblks(
1d8a748a 97 struct xfs_scrub *sc)
0a9633fa 98{
0a9633fa
DW
99 return 0;
100}
101
4bdfd7d1
DW
102/* repair setup functions for no-repair */
103static inline int
104xrep_setup_nothing(
105 struct xfs_scrub *sc)
106{
107 return 0;
108}
109#define xrep_setup_ag_allocbt xrep_setup_nothing
110
111#define xrep_revalidate_allocbt (NULL)
112
b5e2196e
DW
113#define xrep_probe xrep_notsupported
114#define xrep_superblock xrep_notsupported
f9ed6deb 115#define xrep_agf xrep_notsupported
0e93d3f4 116#define xrep_agfl xrep_notsupported
13942aa9 117#define xrep_agi xrep_notsupported
4bdfd7d1 118#define xrep_allocbt xrep_notsupported
84d42ea6
DW
119
120#endif /* CONFIG_XFS_ONLINE_REPAIR */
121
122#endif /* __XFS_SCRUB_REPAIR_H__ */
This page took 0.402639 seconds and 4 git commands to generate.