Linux Audio

Check our new training course

Loading...
v5.9
 1// SPDX-License-Identifier: GPL-2.0+
 2/*
 3 * Copyright (C) 2018 Oracle.  All Rights Reserved.
 4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
 5 */
 6#ifndef __XFS_SCRUB_REPAIR_H__
 7#define __XFS_SCRUB_REPAIR_H__
 8
 9#include "xfs_quota_defs.h"
10
 
 
11static 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
20int xrep_attempt(struct xfs_inode *ip, struct xfs_scrub *sc);
 
21void xrep_failure(struct xfs_mount *mp);
22int xrep_roll_ag_trans(struct xfs_scrub *sc);
 
 
23bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
24		enum xfs_ag_resv_type type);
25xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc);
26int xrep_alloc_ag_block(struct xfs_scrub *sc,
27		const struct xfs_owner_info *oinfo, xfs_fsblock_t *fsbno,
28		enum xfs_ag_resv_type resv);
29int xrep_init_btblock(struct xfs_scrub *sc, xfs_fsblock_t fsb,
30		struct xfs_buf **bpp, xfs_btnum_t btnum,
31		const struct xfs_buf_ops *ops);
 
 
 
 
32
33struct xbitmap;
 
 
34
35int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink);
36int xrep_invalidate_blocks(struct xfs_scrub *sc, struct xbitmap *btlist);
37int xrep_reap_extents(struct xfs_scrub *sc, struct xbitmap *exlist,
38		const struct xfs_owner_info *oinfo, enum xfs_ag_resv_type type);
39
40struct xrep_find_ag_btree {
41	/* in: rmap owner of the btree we're looking for */
42	uint64_t			rmap_owner;
43
44	/* in: buffer ops */
45	const struct xfs_buf_ops	*buf_ops;
46
 
 
 
47	/* out: the highest btree block found and the tree height */
48	xfs_agblock_t			root;
49	unsigned int			height;
50};
51
52int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp,
53		struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp);
 
 
 
 
54void xrep_force_quotacheck(struct xfs_scrub *sc, xfs_dqtype_t type);
55int xrep_ino_dqattach(struct xfs_scrub *sc);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
57/* Metadata repairers */
58
59int xrep_probe(struct xfs_scrub *sc);
60int xrep_superblock(struct xfs_scrub *sc);
61int xrep_agf(struct xfs_scrub *sc);
62int xrep_agfl(struct xfs_scrub *sc);
63int xrep_agi(struct xfs_scrub *sc);
 
 
 
 
 
 
 
 
 
 
64
 
 
65#else
 
 
66
67static inline int xrep_attempt(
68	struct xfs_inode	*ip,
69	struct xfs_scrub	*sc)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70{
71	return -EOPNOTSUPP;
72}
73
74static inline void xrep_failure(struct xfs_mount *mp) {}
75
76static inline xfs_extlen_t
77xrep_calc_ag_resblks(
78	struct xfs_scrub	*sc)
79{
80	return 0;
81}
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83#define xrep_probe			xrep_notsupported
84#define xrep_superblock			xrep_notsupported
85#define xrep_agf			xrep_notsupported
86#define xrep_agfl			xrep_notsupported
87#define xrep_agi			xrep_notsupported
 
 
 
 
 
 
 
 
 
 
 
 
 
88
89#endif /* CONFIG_XFS_ONLINE_REPAIR */
90
91#endif	/* __XFS_SCRUB_REPAIR_H__ */
v6.9.4
  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
 11struct xchk_stats_run;
 12
 13static inline int xrep_notsupported(struct xfs_scrub *sc)
 14{
 15	return -EOPNOTSUPP;
 16}
 17
 18#ifdef CONFIG_XFS_ONLINE_REPAIR
 19
 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
 28/* Repair helpers */
 29
 30int xrep_attempt(struct xfs_scrub *sc, struct xchk_stats_run *run);
 31bool xrep_will_attempt(struct xfs_scrub *sc);
 32void xrep_failure(struct xfs_mount *mp);
 33int xrep_roll_ag_trans(struct xfs_scrub *sc);
 34int xrep_roll_trans(struct xfs_scrub *sc);
 35int xrep_defer_finish(struct xfs_scrub *sc);
 36bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
 37		enum xfs_ag_resv_type type);
 38xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc);
 39
 40static inline int
 41xrep_trans_commit(
 42	struct xfs_scrub	*sc)
 43{
 44	int error = xfs_trans_commit(sc->tp);
 45
 46	sc->tp = NULL;
 47	return error;
 48}
 49
 50struct xbitmap;
 51struct xagb_bitmap;
 52struct xfsb_bitmap;
 53
 54int xrep_fix_freelist(struct xfs_scrub *sc, int alloc_flags);
 
 
 
 55
 56struct xrep_find_ag_btree {
 57	/* in: rmap owner of the btree we're looking for */
 58	uint64_t			rmap_owner;
 59
 60	/* in: buffer ops */
 61	const struct xfs_buf_ops	*buf_ops;
 62
 63	/* in: maximum btree height */
 64	unsigned int			maxlevels;
 65
 66	/* out: the highest btree block found and the tree height */
 67	xfs_agblock_t			root;
 68	unsigned int			height;
 69};
 70
 71int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp,
 72		struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp);
 73
 74#ifdef CONFIG_XFS_QUOTA
 75void xrep_update_qflags(struct xfs_scrub *sc, unsigned int clear_flags,
 76		unsigned int set_flags);
 77void xrep_force_quotacheck(struct xfs_scrub *sc, xfs_dqtype_t type);
 78int xrep_ino_dqattach(struct xfs_scrub *sc);
 79#else
 80# define xrep_force_quotacheck(sc, type)	((void)0)
 81# define xrep_ino_dqattach(sc)			(0)
 82#endif /* CONFIG_XFS_QUOTA */
 83
 84int xrep_setup_xfbtree(struct xfs_scrub *sc, const char *descr);
 85
 86int xrep_ino_ensure_extent_count(struct xfs_scrub *sc, int whichfork,
 87		xfs_extnum_t nextents);
 88int xrep_reset_perag_resv(struct xfs_scrub *sc);
 89int xrep_bmap(struct xfs_scrub *sc, int whichfork, bool allow_unwritten);
 90int xrep_metadata_inode_forks(struct xfs_scrub *sc);
 91int xrep_setup_ag_rmapbt(struct xfs_scrub *sc);
 92int xrep_setup_ag_refcountbt(struct xfs_scrub *sc);
 93
 94/* Repair setup functions */
 95int xrep_setup_ag_allocbt(struct xfs_scrub *sc);
 96
 97struct xfs_imap;
 98int xrep_setup_inode(struct xfs_scrub *sc, const struct xfs_imap *imap);
 99
100void xrep_ag_btcur_init(struct xfs_scrub *sc, struct xchk_ag *sa);
101int xrep_ag_init(struct xfs_scrub *sc, struct xfs_perag *pag,
102		struct xchk_ag *sa);
103
104/* Metadata revalidators */
105
106int xrep_revalidate_allocbt(struct xfs_scrub *sc);
107int xrep_revalidate_iallocbt(struct xfs_scrub *sc);
108
109/* Metadata repairers */
110
111int xrep_probe(struct xfs_scrub *sc);
112int xrep_superblock(struct xfs_scrub *sc);
113int xrep_agf(struct xfs_scrub *sc);
114int xrep_agfl(struct xfs_scrub *sc);
115int xrep_agi(struct xfs_scrub *sc);
116int xrep_allocbt(struct xfs_scrub *sc);
117int xrep_iallocbt(struct xfs_scrub *sc);
118int xrep_rmapbt(struct xfs_scrub *sc);
119int xrep_refcountbt(struct xfs_scrub *sc);
120int xrep_inode(struct xfs_scrub *sc);
121int xrep_bmap_data(struct xfs_scrub *sc);
122int xrep_bmap_attr(struct xfs_scrub *sc);
123int xrep_bmap_cow(struct xfs_scrub *sc);
124int xrep_nlinks(struct xfs_scrub *sc);
125int xrep_fscounters(struct xfs_scrub *sc);
126
127#ifdef CONFIG_XFS_RT
128int xrep_rtbitmap(struct xfs_scrub *sc);
129#else
130# define xrep_rtbitmap			xrep_notsupported
131#endif /* CONFIG_XFS_RT */
132
133#ifdef CONFIG_XFS_QUOTA
134int xrep_quota(struct xfs_scrub *sc);
135int xrep_quotacheck(struct xfs_scrub *sc);
136#else
137# define xrep_quota			xrep_notsupported
138# define xrep_quotacheck		xrep_notsupported
139#endif /* CONFIG_XFS_QUOTA */
140
141int xrep_reinit_pagf(struct xfs_scrub *sc);
142int xrep_reinit_pagi(struct xfs_scrub *sc);
143
144int xrep_trans_alloc_hook_dummy(struct xfs_mount *mp, void **cookiep,
145		struct xfs_trans **tpp);
146void xrep_trans_cancel_hook_dummy(void **cookiep, struct xfs_trans *tp);
147
148#else
149
150#define xrep_ino_dqattach(sc)	(0)
151#define xrep_will_attempt(sc)	(false)
152
153static inline int
154xrep_attempt(
155	struct xfs_scrub	*sc,
156	struct xchk_stats_run	*run)
157{
158	return -EOPNOTSUPP;
159}
160
161static inline void xrep_failure(struct xfs_mount *mp) {}
162
163static inline xfs_extlen_t
164xrep_calc_ag_resblks(
165	struct xfs_scrub	*sc)
166{
167	return 0;
168}
169
170static inline int
171xrep_reset_perag_resv(
172	struct xfs_scrub	*sc)
173{
174	if (!(sc->flags & XREP_RESET_PERAG_RESV))
175		return 0;
176
177	ASSERT(0);
178	return -EOPNOTSUPP;
179}
180
181/* repair setup functions for no-repair */
182static inline int
183xrep_setup_nothing(
184	struct xfs_scrub	*sc)
185{
186	return 0;
187}
188#define xrep_setup_ag_allocbt		xrep_setup_nothing
189#define xrep_setup_ag_rmapbt		xrep_setup_nothing
190#define xrep_setup_ag_refcountbt	xrep_setup_nothing
191
192#define xrep_setup_inode(sc, imap)	((void)0)
193
194#define xrep_revalidate_allocbt		(NULL)
195#define xrep_revalidate_iallocbt	(NULL)
196
197#define xrep_probe			xrep_notsupported
198#define xrep_superblock			xrep_notsupported
199#define xrep_agf			xrep_notsupported
200#define xrep_agfl			xrep_notsupported
201#define xrep_agi			xrep_notsupported
202#define xrep_allocbt			xrep_notsupported
203#define xrep_iallocbt			xrep_notsupported
204#define xrep_rmapbt			xrep_notsupported
205#define xrep_refcountbt			xrep_notsupported
206#define xrep_inode			xrep_notsupported
207#define xrep_bmap_data			xrep_notsupported
208#define xrep_bmap_attr			xrep_notsupported
209#define xrep_bmap_cow			xrep_notsupported
210#define xrep_rtbitmap			xrep_notsupported
211#define xrep_quota			xrep_notsupported
212#define xrep_quotacheck			xrep_notsupported
213#define xrep_nlinks			xrep_notsupported
214#define xrep_fscounters			xrep_notsupported
215
216#endif /* CONFIG_XFS_ONLINE_REPAIR */
217
218#endif	/* __XFS_SCRUB_REPAIR_H__ */