2018-06-06 10:42:14 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2018-05-14 21:34:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Oracle. All Rights Reserved.
|
|
|
|
* Author: Darrick J. Wong <darrick.wong@oracle.com>
|
|
|
|
*/
|
|
|
|
#ifndef __XFS_SCRUB_REPAIR_H__
|
|
|
|
#define __XFS_SCRUB_REPAIR_H__
|
|
|
|
|
2018-07-20 03:29:12 +08:00
|
|
|
static inline int xrep_notsupported(struct xfs_scrub *sc)
|
2018-05-14 21:34:36 +08:00
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_XFS_ONLINE_REPAIR
|
|
|
|
|
|
|
|
/* Repair helpers */
|
|
|
|
|
2018-07-20 03:29:12 +08:00
|
|
|
int xrep_attempt(struct xfs_inode *ip, struct xfs_scrub *sc, bool *fixed);
|
2018-07-20 03:29:11 +08:00
|
|
|
void xrep_failure(struct xfs_mount *mp);
|
2018-07-20 03:29:12 +08:00
|
|
|
int xrep_roll_ag_trans(struct xfs_scrub *sc);
|
2018-07-20 03:29:11 +08:00
|
|
|
bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
|
2018-05-30 13:18:08 +08:00
|
|
|
enum xfs_ag_resv_type type);
|
2018-07-20 03:29:12 +08:00
|
|
|
xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc);
|
2018-07-20 03:29:12 +08:00
|
|
|
int xrep_alloc_ag_block(struct xfs_scrub *sc, struct xfs_owner_info *oinfo,
|
|
|
|
xfs_fsblock_t *fsbno, enum xfs_ag_resv_type resv);
|
2018-07-20 03:29:12 +08:00
|
|
|
int xrep_init_btblock(struct xfs_scrub *sc, xfs_fsblock_t fsb,
|
2018-05-30 13:18:09 +08:00
|
|
|
struct xfs_buf **bpp, xfs_btnum_t btnum,
|
|
|
|
const struct xfs_buf_ops *ops);
|
2018-05-14 21:34:36 +08:00
|
|
|
|
2018-07-20 03:29:11 +08:00
|
|
|
struct xrep_extent {
|
2018-07-20 03:29:12 +08:00
|
|
|
struct list_head list;
|
|
|
|
xfs_fsblock_t fsbno;
|
|
|
|
xfs_extlen_t len;
|
2018-05-30 13:18:09 +08:00
|
|
|
};
|
|
|
|
|
2018-07-20 03:29:11 +08:00
|
|
|
struct xrep_extent_list {
|
2018-07-20 03:29:12 +08:00
|
|
|
struct list_head list;
|
2018-05-30 13:18:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
2018-07-20 03:29:11 +08:00
|
|
|
xrep_init_extent_list(
|
2018-07-20 03:29:12 +08:00
|
|
|
struct xrep_extent_list *exlist)
|
2018-05-30 13:18:09 +08:00
|
|
|
{
|
|
|
|
INIT_LIST_HEAD(&exlist->list);
|
|
|
|
}
|
|
|
|
|
2018-07-20 03:29:11 +08:00
|
|
|
#define for_each_xrep_extent_safe(rbe, n, exlist) \
|
2018-05-30 13:18:09 +08:00
|
|
|
list_for_each_entry_safe((rbe), (n), &(exlist)->list, list)
|
2018-07-20 03:29:12 +08:00
|
|
|
int xrep_collect_btree_extent(struct xfs_scrub *sc,
|
2018-07-20 03:29:11 +08:00
|
|
|
struct xrep_extent_list *btlist, xfs_fsblock_t fsbno,
|
2018-05-30 13:18:09 +08:00
|
|
|
xfs_extlen_t len);
|
2018-07-20 03:29:12 +08:00
|
|
|
void xrep_cancel_btree_extents(struct xfs_scrub *sc,
|
2018-07-20 03:29:11 +08:00
|
|
|
struct xrep_extent_list *btlist);
|
2018-07-20 03:29:12 +08:00
|
|
|
int xrep_subtract_extents(struct xfs_scrub *sc,
|
2018-07-20 03:29:11 +08:00
|
|
|
struct xrep_extent_list *exlist,
|
|
|
|
struct xrep_extent_list *sublist);
|
2018-07-20 03:29:12 +08:00
|
|
|
int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink);
|
|
|
|
int xrep_invalidate_blocks(struct xfs_scrub *sc,
|
2018-07-20 03:29:11 +08:00
|
|
|
struct xrep_extent_list *btlist);
|
2018-07-20 03:29:12 +08:00
|
|
|
int xrep_reap_btree_extents(struct xfs_scrub *sc,
|
2018-07-20 03:29:11 +08:00
|
|
|
struct xrep_extent_list *exlist,
|
2018-05-30 13:18:10 +08:00
|
|
|
struct xfs_owner_info *oinfo, enum xfs_ag_resv_type type);
|
2018-05-30 13:18:09 +08:00
|
|
|
|
2018-07-20 03:29:11 +08:00
|
|
|
struct xrep_find_ag_btree {
|
2018-05-30 13:18:10 +08:00
|
|
|
/* in: rmap owner of the btree we're looking for */
|
|
|
|
uint64_t rmap_owner;
|
|
|
|
|
|
|
|
/* in: buffer ops */
|
|
|
|
const struct xfs_buf_ops *buf_ops;
|
|
|
|
|
|
|
|
/* in: magic number of the btree */
|
|
|
|
uint32_t magic;
|
|
|
|
|
|
|
|
/* out: the highest btree block found and the tree height */
|
|
|
|
xfs_agblock_t root;
|
|
|
|
unsigned int height;
|
|
|
|
};
|
|
|
|
|
2018-07-20 03:29:12 +08:00
|
|
|
int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp,
|
|
|
|
struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp);
|
2018-07-20 03:29:12 +08:00
|
|
|
void xrep_force_quotacheck(struct xfs_scrub *sc, uint dqtype);
|
|
|
|
int xrep_ino_dqattach(struct xfs_scrub *sc);
|
2018-05-30 13:18:10 +08:00
|
|
|
|
2018-05-14 21:34:36 +08:00
|
|
|
/* Metadata repairers */
|
|
|
|
|
2018-07-20 03:29:12 +08:00
|
|
|
int xrep_probe(struct xfs_scrub *sc);
|
|
|
|
int xrep_superblock(struct xfs_scrub *sc);
|
2018-05-14 21:34:36 +08:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2018-07-20 03:29:11 +08:00
|
|
|
static inline int xrep_attempt(
|
2018-07-20 03:29:12 +08:00
|
|
|
struct xfs_inode *ip,
|
2018-07-20 03:29:12 +08:00
|
|
|
struct xfs_scrub *sc,
|
2018-07-20 03:29:12 +08:00
|
|
|
bool *fixed)
|
2018-05-14 21:34:36 +08:00
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2018-07-20 03:29:11 +08:00
|
|
|
static inline void xrep_failure(struct xfs_mount *mp) {}
|
2018-05-14 21:34:36 +08:00
|
|
|
|
2018-05-30 13:18:08 +08:00
|
|
|
static inline xfs_extlen_t
|
2018-07-20 03:29:11 +08:00
|
|
|
xrep_calc_ag_resblks(
|
2018-07-20 03:29:12 +08:00
|
|
|
struct xfs_scrub *sc)
|
2018-05-30 13:18:08 +08:00
|
|
|
{
|
|
|
|
ASSERT(!(sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-07-20 03:29:11 +08:00
|
|
|
#define xrep_probe xrep_notsupported
|
|
|
|
#define xrep_superblock xrep_notsupported
|
2018-05-14 21:34:36 +08:00
|
|
|
|
|
|
|
#endif /* CONFIG_XFS_ONLINE_REPAIR */
|
|
|
|
|
|
|
|
#endif /* __XFS_SCRUB_REPAIR_H__ */
|