brintos

brintos / linux-shallow public Read only

0
0
Text · 7.1 KiB · 0e0dc2b Raw
250 lines · c
1// SPDX-License-Identifier: GPL-2.0-or-later2/*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_REPAIR19 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 avoid23 * 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 int41xrep_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_QUOTA75void 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#else80# 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);93int xrep_setup_xattr(struct xfs_scrub *sc);94int xrep_setup_directory(struct xfs_scrub *sc);95int xrep_setup_parent(struct xfs_scrub *sc);96int xrep_setup_nlinks(struct xfs_scrub *sc);97int xrep_setup_symlink(struct xfs_scrub *sc, unsigned int *resblks);98int xrep_setup_dirtree(struct xfs_scrub *sc);99 100/* Repair setup functions */101int xrep_setup_ag_allocbt(struct xfs_scrub *sc);102 103struct xfs_imap;104int xrep_setup_inode(struct xfs_scrub *sc, const struct xfs_imap *imap);105 106void xrep_ag_btcur_init(struct xfs_scrub *sc, struct xchk_ag *sa);107int xrep_ag_init(struct xfs_scrub *sc, struct xfs_perag *pag,108		struct xchk_ag *sa);109 110/* Metadata revalidators */111 112int xrep_revalidate_allocbt(struct xfs_scrub *sc);113int xrep_revalidate_iallocbt(struct xfs_scrub *sc);114 115/* Metadata repairers */116 117int xrep_probe(struct xfs_scrub *sc);118int xrep_superblock(struct xfs_scrub *sc);119int xrep_agf(struct xfs_scrub *sc);120int xrep_agfl(struct xfs_scrub *sc);121int xrep_agi(struct xfs_scrub *sc);122int xrep_allocbt(struct xfs_scrub *sc);123int xrep_iallocbt(struct xfs_scrub *sc);124int xrep_rmapbt(struct xfs_scrub *sc);125int xrep_refcountbt(struct xfs_scrub *sc);126int xrep_inode(struct xfs_scrub *sc);127int xrep_bmap_data(struct xfs_scrub *sc);128int xrep_bmap_attr(struct xfs_scrub *sc);129int xrep_bmap_cow(struct xfs_scrub *sc);130int xrep_nlinks(struct xfs_scrub *sc);131int xrep_fscounters(struct xfs_scrub *sc);132int xrep_xattr(struct xfs_scrub *sc);133int xrep_directory(struct xfs_scrub *sc);134int xrep_parent(struct xfs_scrub *sc);135int xrep_symlink(struct xfs_scrub *sc);136int xrep_dirtree(struct xfs_scrub *sc);137 138#ifdef CONFIG_XFS_RT139int xrep_rtbitmap(struct xfs_scrub *sc);140int xrep_rtsummary(struct xfs_scrub *sc);141#else142# define xrep_rtbitmap			xrep_notsupported143# define xrep_rtsummary			xrep_notsupported144#endif /* CONFIG_XFS_RT */145 146#ifdef CONFIG_XFS_QUOTA147int xrep_quota(struct xfs_scrub *sc);148int xrep_quotacheck(struct xfs_scrub *sc);149#else150# define xrep_quota			xrep_notsupported151# define xrep_quotacheck		xrep_notsupported152#endif /* CONFIG_XFS_QUOTA */153 154int xrep_reinit_pagf(struct xfs_scrub *sc);155int xrep_reinit_pagi(struct xfs_scrub *sc);156 157int xrep_trans_alloc_hook_dummy(struct xfs_mount *mp, void **cookiep,158		struct xfs_trans **tpp);159void xrep_trans_cancel_hook_dummy(void **cookiep, struct xfs_trans *tp);160 161bool xrep_buf_verify_struct(struct xfs_buf *bp, const struct xfs_buf_ops *ops);162 163#else164 165#define xrep_ino_dqattach(sc)	(0)166#define xrep_will_attempt(sc)	(false)167 168static inline int169xrep_attempt(170	struct xfs_scrub	*sc,171	struct xchk_stats_run	*run)172{173	return -EOPNOTSUPP;174}175 176static inline void xrep_failure(struct xfs_mount *mp) {}177 178static inline xfs_extlen_t179xrep_calc_ag_resblks(180	struct xfs_scrub	*sc)181{182	return 0;183}184 185static inline int186xrep_reset_perag_resv(187	struct xfs_scrub	*sc)188{189	if (!(sc->flags & XREP_RESET_PERAG_RESV))190		return 0;191 192	ASSERT(0);193	return -EOPNOTSUPP;194}195 196/* repair setup functions for no-repair */197static inline int198xrep_setup_nothing(199	struct xfs_scrub	*sc)200{201	return 0;202}203#define xrep_setup_ag_allocbt		xrep_setup_nothing204#define xrep_setup_ag_rmapbt		xrep_setup_nothing205#define xrep_setup_ag_refcountbt	xrep_setup_nothing206#define xrep_setup_xattr		xrep_setup_nothing207#define xrep_setup_directory		xrep_setup_nothing208#define xrep_setup_parent		xrep_setup_nothing209#define xrep_setup_nlinks		xrep_setup_nothing210#define xrep_setup_dirtree		xrep_setup_nothing211 212#define xrep_setup_inode(sc, imap)	((void)0)213 214static inline int xrep_setup_symlink(struct xfs_scrub *sc, unsigned int *x)215{216	return 0;217}218 219#define xrep_revalidate_allocbt		(NULL)220#define xrep_revalidate_iallocbt	(NULL)221 222#define xrep_probe			xrep_notsupported223#define xrep_superblock			xrep_notsupported224#define xrep_agf			xrep_notsupported225#define xrep_agfl			xrep_notsupported226#define xrep_agi			xrep_notsupported227#define xrep_allocbt			xrep_notsupported228#define xrep_iallocbt			xrep_notsupported229#define xrep_rmapbt			xrep_notsupported230#define xrep_refcountbt			xrep_notsupported231#define xrep_inode			xrep_notsupported232#define xrep_bmap_data			xrep_notsupported233#define xrep_bmap_attr			xrep_notsupported234#define xrep_bmap_cow			xrep_notsupported235#define xrep_rtbitmap			xrep_notsupported236#define xrep_quota			xrep_notsupported237#define xrep_quotacheck			xrep_notsupported238#define xrep_nlinks			xrep_notsupported239#define xrep_fscounters			xrep_notsupported240#define xrep_rtsummary			xrep_notsupported241#define xrep_xattr			xrep_notsupported242#define xrep_directory			xrep_notsupported243#define xrep_parent			xrep_notsupported244#define xrep_symlink			xrep_notsupported245#define xrep_dirtree			xrep_notsupported246 247#endif /* CONFIG_XFS_ONLINE_REPAIR */248 249#endif	/* __XFS_SCRUB_REPAIR_H__ */250