common.h 3.9 KB
Newer Older
D
Darrick J. Wong 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
/*
 * Copyright (C) 2017 Oracle.  All Rights Reserved.
 *
 * Author: Darrick J. Wong <darrick.wong@oracle.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it would be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write the Free Software Foundation,
 * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
 */
#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
xfs_scrub_should_terminate(
	struct xfs_scrub_context	*sc,
	int				*error)
{
	if (fatal_signal_pending(current)) {
		if (*error == 0)
			*error = -EAGAIN;
		return true;
	}
	return false;
}

/*
 * Grab an empty transaction so that we can re-grab locked buffers if
 * one of our btrees turns out to be cyclic.
 */
static inline int
xfs_scrub_trans_alloc(
	struct xfs_scrub_metadata	*sm,
	struct xfs_mount		*mp,
	struct xfs_trans		**tpp)
{
	return xfs_trans_alloc_empty(mp, tpp);
}

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
bool xfs_scrub_process_error(struct xfs_scrub_context *sc, xfs_agnumber_t agno,
		xfs_agblock_t bno, int *error);
bool xfs_scrub_fblock_process_error(struct xfs_scrub_context *sc, int whichfork,
		xfs_fileoff_t offset, int *error);

void xfs_scrub_block_set_preen(struct xfs_scrub_context *sc,
		struct xfs_buf *bp);
void xfs_scrub_ino_set_preen(struct xfs_scrub_context *sc, struct xfs_buf *bp);

void xfs_scrub_block_set_corrupt(struct xfs_scrub_context *sc,
		struct xfs_buf *bp);
void xfs_scrub_ino_set_corrupt(struct xfs_scrub_context *sc, xfs_ino_t ino,
		struct xfs_buf *bp);
void xfs_scrub_fblock_set_corrupt(struct xfs_scrub_context *sc, int whichfork,
		xfs_fileoff_t offset);

void xfs_scrub_ino_set_warning(struct xfs_scrub_context *sc,
		struct xfs_buf *bp);
void xfs_scrub_fblock_set_warning(struct xfs_scrub_context *sc, int whichfork,
		xfs_fileoff_t offset);

void xfs_scrub_set_incomplete(struct xfs_scrub_context *sc);
D
Darrick J. Wong 已提交
76
int xfs_scrub_checkpoint_log(struct xfs_mount *mp);
77

D
Darrick J. Wong 已提交
78 79
/* Setup functions */
int xfs_scrub_setup_fs(struct xfs_scrub_context *sc, struct xfs_inode *ip);
80 81
int xfs_scrub_setup_ag_header(struct xfs_scrub_context *sc,
			      struct xfs_inode *ip);
D
Darrick J. Wong 已提交
82 83
int xfs_scrub_setup_ag_allocbt(struct xfs_scrub_context *sc,
			       struct xfs_inode *ip);
D
Darrick J. Wong 已提交
84 85
int xfs_scrub_setup_ag_iallocbt(struct xfs_scrub_context *sc,
				struct xfs_inode *ip);
D
Darrick J. Wong 已提交
86 87
int xfs_scrub_setup_ag_rmapbt(struct xfs_scrub_context *sc,
			      struct xfs_inode *ip);
D
Darrick J. Wong 已提交
88 89
int xfs_scrub_setup_ag_refcountbt(struct xfs_scrub_context *sc,
				  struct xfs_inode *ip);
D
Darrick J. Wong 已提交
90

D
Darrick J. Wong 已提交
91

92 93 94 95 96 97 98 99 100
void xfs_scrub_ag_free(struct xfs_scrub_context *sc, struct xfs_scrub_ag *sa);
int xfs_scrub_ag_init(struct xfs_scrub_context *sc, xfs_agnumber_t agno,
		      struct xfs_scrub_ag *sa);
int xfs_scrub_ag_read_headers(struct xfs_scrub_context *sc, xfs_agnumber_t agno,
			      struct xfs_buf **agi, struct xfs_buf **agf,
			      struct xfs_buf **agfl);
void xfs_scrub_ag_btcur_free(struct xfs_scrub_ag *sa);
int xfs_scrub_ag_btcur_init(struct xfs_scrub_context *sc,
			    struct xfs_scrub_ag *sa);
D
Darrick J. Wong 已提交
101 102 103 104
int xfs_scrub_walk_agfl(struct xfs_scrub_context *sc,
			int (*fn)(struct xfs_scrub_context *, xfs_agblock_t bno,
				  void *),
			void *priv);
105

D
Darrick J. Wong 已提交
106 107 108
int xfs_scrub_setup_ag_btree(struct xfs_scrub_context *sc,
			     struct xfs_inode *ip, bool force_log);

D
Darrick J. Wong 已提交
109
#endif	/* __XFS_SCRUB_COMMON_H__ */