^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2018 Oracle. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Author: Darrick J. Wong <darrick.wong@oracle.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef __XFS_SCRUB_REPAIR_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define __XFS_SCRUB_REPAIR_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "xfs_quota_defs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) static inline int xrep_notsupported(struct xfs_scrub *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #ifdef CONFIG_XFS_ONLINE_REPAIR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /* Repair helpers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) int xrep_attempt(struct xfs_inode *ip, struct xfs_scrub *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) void xrep_failure(struct xfs_mount *mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) int xrep_roll_ag_trans(struct xfs_scrub *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) enum xfs_ag_resv_type type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) int xrep_alloc_ag_block(struct xfs_scrub *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) const struct xfs_owner_info *oinfo, xfs_fsblock_t *fsbno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) enum xfs_ag_resv_type resv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int xrep_init_btblock(struct xfs_scrub *sc, xfs_fsblock_t fsb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct xfs_buf **bpp, xfs_btnum_t btnum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) const struct xfs_buf_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct xbitmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int xrep_invalidate_blocks(struct xfs_scrub *sc, struct xbitmap *btlist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int xrep_reap_extents(struct xfs_scrub *sc, struct xbitmap *exlist,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) const struct xfs_owner_info *oinfo, enum xfs_ag_resv_type type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct xrep_find_ag_btree {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /* in: rmap owner of the btree we're looking for */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) uint64_t rmap_owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /* in: buffer ops */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) const struct xfs_buf_ops *buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* out: the highest btree block found and the tree height */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) xfs_agblock_t root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) unsigned int height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) void xrep_force_quotacheck(struct xfs_scrub *sc, xfs_dqtype_t type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) int xrep_ino_dqattach(struct xfs_scrub *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* Metadata repairers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int xrep_probe(struct xfs_scrub *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) int xrep_superblock(struct xfs_scrub *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int xrep_agf(struct xfs_scrub *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int xrep_agfl(struct xfs_scrub *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int xrep_agi(struct xfs_scrub *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static inline int xrep_attempt(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct xfs_scrub *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) static inline void xrep_failure(struct xfs_mount *mp) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static inline xfs_extlen_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) xrep_calc_ag_resblks(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct xfs_scrub *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define xrep_probe xrep_notsupported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define xrep_superblock xrep_notsupported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define xrep_agf xrep_notsupported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define xrep_agfl xrep_notsupported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define xrep_agi xrep_notsupported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #endif /* CONFIG_XFS_ONLINE_REPAIR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #endif /* __XFS_SCRUB_REPAIR_H__ */