xfs: only invalidate blocks if we're going to free them
[platform/kernel/linux-starfive.git] / fs / xfs / scrub / repair.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2018-2023 Oracle.  All Rights Reserved.
4  * Author: Darrick J. Wong <djwong@kernel.org>
5  */
6 #ifndef __XFS_SCRUB_REPAIR_H__
7 #define __XFS_SCRUB_REPAIR_H__
8
9 #include "xfs_quota_defs.h"
10
11 static inline int xrep_notsupported(struct xfs_scrub *sc)
12 {
13         return -EOPNOTSUPP;
14 }
15
16 #ifdef CONFIG_XFS_ONLINE_REPAIR
17
18 /* Repair helpers */
19
20 int xrep_attempt(struct xfs_scrub *sc);
21 void xrep_failure(struct xfs_mount *mp);
22 int xrep_roll_ag_trans(struct xfs_scrub *sc);
23 bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
24                 enum xfs_ag_resv_type type);
25 xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc);
26
27 struct xbitmap;
28 struct xagb_bitmap;
29
30 int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink);
31
32 struct xrep_find_ag_btree {
33         /* in: rmap owner of the btree we're looking for */
34         uint64_t                        rmap_owner;
35
36         /* in: buffer ops */
37         const struct xfs_buf_ops        *buf_ops;
38
39         /* in: maximum btree height */
40         unsigned int                    maxlevels;
41
42         /* out: the highest btree block found and the tree height */
43         xfs_agblock_t                   root;
44         unsigned int                    height;
45 };
46
47 int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp,
48                 struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp);
49 void xrep_force_quotacheck(struct xfs_scrub *sc, xfs_dqtype_t type);
50 int xrep_ino_dqattach(struct xfs_scrub *sc);
51
52 /* Metadata repairers */
53
54 int xrep_probe(struct xfs_scrub *sc);
55 int xrep_superblock(struct xfs_scrub *sc);
56 int xrep_agf(struct xfs_scrub *sc);
57 int xrep_agfl(struct xfs_scrub *sc);
58 int xrep_agi(struct xfs_scrub *sc);
59
60 #else
61
62 static inline int
63 xrep_attempt(
64         struct xfs_scrub        *sc)
65 {
66         return -EOPNOTSUPP;
67 }
68
69 static inline void xrep_failure(struct xfs_mount *mp) {}
70
71 static inline xfs_extlen_t
72 xrep_calc_ag_resblks(
73         struct xfs_scrub        *sc)
74 {
75         return 0;
76 }
77
78 #define xrep_probe                      xrep_notsupported
79 #define xrep_superblock                 xrep_notsupported
80 #define xrep_agf                        xrep_notsupported
81 #define xrep_agfl                       xrep_notsupported
82 #define xrep_agi                        xrep_notsupported
83
84 #endif /* CONFIG_XFS_ONLINE_REPAIR */
85
86 #endif  /* __XFS_SCRUB_REPAIR_H__ */