2018-06-06 09:42:14 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-10-18 11:37:36 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Oracle. All Rights Reserved.
|
|
|
|
* Author: Darrick J. Wong <darrick.wong@oracle.com>
|
|
|
|
*/
|
|
|
|
#ifndef __XFS_SCRUB_COMMON_H__
|
|
|
|
#define __XFS_SCRUB_COMMON_H__
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We /could/ terminate a scrub/repair operation early. If we're not
|
|
|
|
* in a good place to continue (fatal signal, etc.) then bail out.
|
|
|
|
* Note that we're careful not to make any judgements about *error.
|
|
|
|
*/
|
|
|
|
static inline bool
|
2018-07-20 02:29:11 +07:00
|
|
|
xchk_should_terminate(
|
2018-07-20 02:29:12 +07:00
|
|
|
struct xfs_scrub *sc,
|
2019-11-06 06:33:57 +07:00
|
|
|
int *error)
|
2017-10-18 11:37:36 +07:00
|
|
|
{
|
2019-11-06 06:33:57 +07:00
|
|
|
/*
|
|
|
|
* If preemption is disabled, we need to yield to the scheduler every
|
|
|
|
* few seconds so that we don't run afoul of the soft lockup watchdog
|
|
|
|
* or RCU stall detector.
|
|
|
|
*/
|
|
|
|
cond_resched();
|
|
|
|
|
2017-10-18 11:37:36 +07:00
|
|
|
if (fatal_signal_pending(current)) {
|
|
|
|
if (*error == 0)
|
|
|
|
*error = -EAGAIN;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_trans_alloc(struct xfs_scrub *sc, uint resblks);
|
|
|
|
bool xchk_process_error(struct xfs_scrub *sc, xfs_agnumber_t agno,
|
2017-10-18 11:37:36 +07:00
|
|
|
xfs_agblock_t bno, int *error);
|
2018-07-20 02:29:12 +07:00
|
|
|
bool xchk_fblock_process_error(struct xfs_scrub *sc, int whichfork,
|
2017-10-18 11:37:36 +07:00
|
|
|
xfs_fileoff_t offset, int *error);
|
|
|
|
|
2018-07-20 02:29:12 +07:00
|
|
|
bool xchk_xref_process_error(struct xfs_scrub *sc,
|
2018-01-17 09:52:14 +07:00
|
|
|
xfs_agnumber_t agno, xfs_agblock_t bno, int *error);
|
2018-07-20 02:29:12 +07:00
|
|
|
bool xchk_fblock_xref_process_error(struct xfs_scrub *sc,
|
2018-01-17 09:52:14 +07:00
|
|
|
int whichfork, xfs_fileoff_t offset, int *error);
|
|
|
|
|
2018-07-20 02:29:12 +07:00
|
|
|
void xchk_block_set_preen(struct xfs_scrub *sc,
|
2017-10-18 11:37:36 +07:00
|
|
|
struct xfs_buf *bp);
|
2018-07-20 02:29:12 +07:00
|
|
|
void xchk_ino_set_preen(struct xfs_scrub *sc, xfs_ino_t ino);
|
2017-10-18 11:37:36 +07:00
|
|
|
|
2019-04-26 08:26:24 +07:00
|
|
|
void xchk_set_corrupt(struct xfs_scrub *sc);
|
2018-07-20 02:29:12 +07:00
|
|
|
void xchk_block_set_corrupt(struct xfs_scrub *sc,
|
2017-10-18 11:37:36 +07:00
|
|
|
struct xfs_buf *bp);
|
2018-07-20 02:29:12 +07:00
|
|
|
void xchk_ino_set_corrupt(struct xfs_scrub *sc, xfs_ino_t ino);
|
|
|
|
void xchk_fblock_set_corrupt(struct xfs_scrub *sc, int whichfork,
|
2017-10-18 11:37:36 +07:00
|
|
|
xfs_fileoff_t offset);
|
|
|
|
|
2018-07-20 02:29:12 +07:00
|
|
|
void xchk_block_xref_set_corrupt(struct xfs_scrub *sc,
|
2018-01-17 09:52:14 +07:00
|
|
|
struct xfs_buf *bp);
|
2018-07-20 02:29:12 +07:00
|
|
|
void xchk_ino_xref_set_corrupt(struct xfs_scrub *sc,
|
2018-03-24 00:06:54 +07:00
|
|
|
xfs_ino_t ino);
|
2018-07-20 02:29:12 +07:00
|
|
|
void xchk_fblock_xref_set_corrupt(struct xfs_scrub *sc,
|
2018-01-17 09:52:14 +07:00
|
|
|
int whichfork, xfs_fileoff_t offset);
|
|
|
|
|
2018-07-20 02:29:12 +07:00
|
|
|
void xchk_ino_set_warning(struct xfs_scrub *sc, xfs_ino_t ino);
|
|
|
|
void xchk_fblock_set_warning(struct xfs_scrub *sc, int whichfork,
|
2017-10-18 11:37:36 +07:00
|
|
|
xfs_fileoff_t offset);
|
|
|
|
|
2018-07-20 02:29:12 +07:00
|
|
|
void xchk_set_incomplete(struct xfs_scrub *sc);
|
2018-07-20 02:29:11 +07:00
|
|
|
int xchk_checkpoint_log(struct xfs_mount *mp);
|
2017-10-18 11:37:36 +07:00
|
|
|
|
2018-01-17 09:52:14 +07:00
|
|
|
/* Are we set up for a cross-referencing check? */
|
2018-07-20 02:29:12 +07:00
|
|
|
bool xchk_should_check_xref(struct xfs_scrub *sc, int *error,
|
2018-01-17 09:52:14 +07:00
|
|
|
struct xfs_btree_cur **curpp);
|
|
|
|
|
2017-10-18 11:37:36 +07:00
|
|
|
/* Setup functions */
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_fs(struct xfs_scrub *sc, struct xfs_inode *ip);
|
|
|
|
int xchk_setup_ag_allocbt(struct xfs_scrub *sc,
|
2017-10-18 11:37:40 +07:00
|
|
|
struct xfs_inode *ip);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_ag_iallocbt(struct xfs_scrub *sc,
|
2017-10-18 11:37:40 +07:00
|
|
|
struct xfs_inode *ip);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_ag_rmapbt(struct xfs_scrub *sc,
|
2017-10-18 11:37:41 +07:00
|
|
|
struct xfs_inode *ip);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_ag_refcountbt(struct xfs_scrub *sc,
|
2017-10-18 11:37:41 +07:00
|
|
|
struct xfs_inode *ip);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_inode(struct xfs_scrub *sc,
|
2017-10-18 11:37:42 +07:00
|
|
|
struct xfs_inode *ip);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_inode_bmap(struct xfs_scrub *sc,
|
2017-10-18 11:37:43 +07:00
|
|
|
struct xfs_inode *ip);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_inode_bmap_data(struct xfs_scrub *sc,
|
2017-10-18 11:37:43 +07:00
|
|
|
struct xfs_inode *ip);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_directory(struct xfs_scrub *sc,
|
2017-10-18 11:37:44 +07:00
|
|
|
struct xfs_inode *ip);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_xattr(struct xfs_scrub *sc,
|
2017-10-18 11:37:45 +07:00
|
|
|
struct xfs_inode *ip);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_symlink(struct xfs_scrub *sc,
|
2017-10-18 11:37:45 +07:00
|
|
|
struct xfs_inode *ip);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_parent(struct xfs_scrub *sc,
|
2017-10-18 11:37:46 +07:00
|
|
|
struct xfs_inode *ip);
|
2017-10-18 11:37:46 +07:00
|
|
|
#ifdef CONFIG_XFS_RT
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_rt(struct xfs_scrub *sc, struct xfs_inode *ip);
|
2017-10-18 11:37:46 +07:00
|
|
|
#else
|
|
|
|
static inline int
|
2018-07-20 02:29:12 +07:00
|
|
|
xchk_setup_rt(struct xfs_scrub *sc, struct xfs_inode *ip)
|
2017-10-18 11:37:47 +07:00
|
|
|
{
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_XFS_QUOTA
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_quota(struct xfs_scrub *sc, struct xfs_inode *ip);
|
2017-10-18 11:37:47 +07:00
|
|
|
#else
|
|
|
|
static inline int
|
2018-07-20 02:29:12 +07:00
|
|
|
xchk_setup_quota(struct xfs_scrub *sc, struct xfs_inode *ip)
|
2017-10-18 11:37:46 +07:00
|
|
|
{
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
#endif
|
2019-04-26 08:26:24 +07:00
|
|
|
int xchk_setup_fscounters(struct xfs_scrub *sc, struct xfs_inode *ip);
|
2017-10-18 11:37:36 +07:00
|
|
|
|
2018-07-20 02:29:12 +07:00
|
|
|
void xchk_ag_free(struct xfs_scrub *sc, struct xchk_ag *sa);
|
|
|
|
int xchk_ag_init(struct xfs_scrub *sc, xfs_agnumber_t agno,
|
2018-07-20 02:29:12 +07:00
|
|
|
struct xchk_ag *sa);
|
2018-07-20 02:29:11 +07:00
|
|
|
void xchk_perag_get(struct xfs_mount *mp, struct xchk_ag *sa);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_ag_read_headers(struct xfs_scrub *sc, xfs_agnumber_t agno,
|
2018-07-20 02:29:12 +07:00
|
|
|
struct xfs_buf **agi, struct xfs_buf **agf,
|
|
|
|
struct xfs_buf **agfl);
|
2018-07-20 02:29:11 +07:00
|
|
|
void xchk_ag_btcur_free(struct xchk_ag *sa);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_ag_btcur_init(struct xfs_scrub *sc, struct xchk_ag *sa);
|
|
|
|
int xchk_count_rmap_ownedby_ag(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
|
2018-12-12 23:46:23 +07:00
|
|
|
const struct xfs_owner_info *oinfo, xfs_filblks_t *blocks);
|
2017-10-18 11:37:38 +07:00
|
|
|
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_ag_btree(struct xfs_scrub *sc, struct xfs_inode *ip,
|
|
|
|
bool force_log);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_get_inode(struct xfs_scrub *sc, struct xfs_inode *ip_in);
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_setup_inode_contents(struct xfs_scrub *sc, struct xfs_inode *ip,
|
|
|
|
unsigned int resblks);
|
2018-07-20 02:29:12 +07:00
|
|
|
void xchk_buffer_recheck(struct xfs_scrub *sc, struct xfs_buf *bp);
|
2017-10-18 11:37:40 +07:00
|
|
|
|
2018-05-14 20:34:31 +07:00
|
|
|
/*
|
|
|
|
* Don't bother cross-referencing if we already found corruption or cross
|
|
|
|
* referencing discrepancies.
|
|
|
|
*/
|
2018-07-20 02:29:11 +07:00
|
|
|
static inline bool xchk_skip_xref(struct xfs_scrub_metadata *sm)
|
2018-05-14 20:34:31 +07:00
|
|
|
{
|
|
|
|
return sm->sm_flags & (XFS_SCRUB_OFLAG_CORRUPT |
|
|
|
|
XFS_SCRUB_OFLAG_XCORRUPT);
|
|
|
|
}
|
|
|
|
|
2018-07-20 02:29:12 +07:00
|
|
|
int xchk_metadata_inode_forks(struct xfs_scrub *sc);
|
2018-07-20 02:29:11 +07:00
|
|
|
int xchk_ilock_inverted(struct xfs_inode *ip, uint lock_mode);
|
2019-04-26 08:26:23 +07:00
|
|
|
void xchk_stop_reaping(struct xfs_scrub *sc);
|
|
|
|
void xchk_start_reaping(struct xfs_scrub *sc);
|
2018-05-14 20:34:33 +07:00
|
|
|
|
2017-10-18 11:37:36 +07:00
|
|
|
#endif /* __XFS_SCRUB_COMMON_H__ */
|