Darrick J. Wong | dcb660f | 2017-10-17 21:37:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 Oracle. All Rights Reserved. |
| 3 | * |
| 4 | * Author: Darrick J. Wong <darrick.wong@oracle.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version 2 |
| 9 | * of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it would be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write the Free Software Foundation, |
| 18 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | #ifndef __XFS_SCRUB_COMMON_H__ |
| 21 | #define __XFS_SCRUB_COMMON_H__ |
| 22 | |
| 23 | /* |
| 24 | * We /could/ terminate a scrub/repair operation early. If we're not |
| 25 | * in a good place to continue (fatal signal, etc.) then bail out. |
| 26 | * Note that we're careful not to make any judgements about *error. |
| 27 | */ |
| 28 | static inline bool |
| 29 | xfs_scrub_should_terminate( |
| 30 | struct xfs_scrub_context *sc, |
| 31 | int *error) |
| 32 | { |
| 33 | if (fatal_signal_pending(current)) { |
| 34 | if (*error == 0) |
| 35 | *error = -EAGAIN; |
| 36 | return true; |
| 37 | } |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | /* |
| 42 | * Grab an empty transaction so that we can re-grab locked buffers if |
| 43 | * one of our btrees turns out to be cyclic. |
| 44 | */ |
| 45 | static inline int |
| 46 | xfs_scrub_trans_alloc( |
| 47 | struct xfs_scrub_metadata *sm, |
| 48 | struct xfs_mount *mp, |
| 49 | struct xfs_trans **tpp) |
| 50 | { |
| 51 | return xfs_trans_alloc_empty(mp, tpp); |
| 52 | } |
| 53 | |
Darrick J. Wong | 4700d22 | 2017-10-17 21:37:36 -0700 | [diff] [blame] | 54 | bool xfs_scrub_process_error(struct xfs_scrub_context *sc, xfs_agnumber_t agno, |
| 55 | xfs_agblock_t bno, int *error); |
| 56 | bool xfs_scrub_fblock_process_error(struct xfs_scrub_context *sc, int whichfork, |
| 57 | xfs_fileoff_t offset, int *error); |
| 58 | |
| 59 | void xfs_scrub_block_set_preen(struct xfs_scrub_context *sc, |
| 60 | struct xfs_buf *bp); |
| 61 | void xfs_scrub_ino_set_preen(struct xfs_scrub_context *sc, struct xfs_buf *bp); |
| 62 | |
| 63 | void xfs_scrub_block_set_corrupt(struct xfs_scrub_context *sc, |
| 64 | struct xfs_buf *bp); |
| 65 | void xfs_scrub_ino_set_corrupt(struct xfs_scrub_context *sc, xfs_ino_t ino, |
| 66 | struct xfs_buf *bp); |
| 67 | void xfs_scrub_fblock_set_corrupt(struct xfs_scrub_context *sc, int whichfork, |
| 68 | xfs_fileoff_t offset); |
| 69 | |
| 70 | void xfs_scrub_ino_set_warning(struct xfs_scrub_context *sc, |
| 71 | struct xfs_buf *bp); |
| 72 | void xfs_scrub_fblock_set_warning(struct xfs_scrub_context *sc, int whichfork, |
| 73 | xfs_fileoff_t offset); |
| 74 | |
| 75 | void xfs_scrub_set_incomplete(struct xfs_scrub_context *sc); |
Darrick J. Wong | 3daa664 | 2017-10-17 21:37:40 -0700 | [diff] [blame^] | 76 | int xfs_scrub_checkpoint_log(struct xfs_mount *mp); |
Darrick J. Wong | 4700d22 | 2017-10-17 21:37:36 -0700 | [diff] [blame] | 77 | |
Darrick J. Wong | dcb660f | 2017-10-17 21:37:36 -0700 | [diff] [blame] | 78 | /* Setup functions */ |
| 79 | int xfs_scrub_setup_fs(struct xfs_scrub_context *sc, struct xfs_inode *ip); |
Darrick J. Wong | 21fb4cb | 2017-10-17 21:37:38 -0700 | [diff] [blame] | 80 | int xfs_scrub_setup_ag_header(struct xfs_scrub_context *sc, |
| 81 | struct xfs_inode *ip); |
Darrick J. Wong | efa7a99 | 2017-10-17 21:37:40 -0700 | [diff] [blame] | 82 | int xfs_scrub_setup_ag_allocbt(struct xfs_scrub_context *sc, |
| 83 | struct xfs_inode *ip); |
Darrick J. Wong | 3daa664 | 2017-10-17 21:37:40 -0700 | [diff] [blame^] | 84 | int xfs_scrub_setup_ag_iallocbt(struct xfs_scrub_context *sc, |
| 85 | struct xfs_inode *ip); |
Darrick J. Wong | efa7a99 | 2017-10-17 21:37:40 -0700 | [diff] [blame] | 86 | |
Darrick J. Wong | dcb660f | 2017-10-17 21:37:36 -0700 | [diff] [blame] | 87 | |
Darrick J. Wong | b6c1beb | 2017-10-17 21:37:38 -0700 | [diff] [blame] | 88 | void xfs_scrub_ag_free(struct xfs_scrub_context *sc, struct xfs_scrub_ag *sa); |
| 89 | int xfs_scrub_ag_init(struct xfs_scrub_context *sc, xfs_agnumber_t agno, |
| 90 | struct xfs_scrub_ag *sa); |
| 91 | int xfs_scrub_ag_read_headers(struct xfs_scrub_context *sc, xfs_agnumber_t agno, |
| 92 | struct xfs_buf **agi, struct xfs_buf **agf, |
| 93 | struct xfs_buf **agfl); |
| 94 | void xfs_scrub_ag_btcur_free(struct xfs_scrub_ag *sa); |
| 95 | int xfs_scrub_ag_btcur_init(struct xfs_scrub_context *sc, |
| 96 | struct xfs_scrub_ag *sa); |
Darrick J. Wong | ab9d5dc | 2017-10-17 21:37:39 -0700 | [diff] [blame] | 97 | int xfs_scrub_walk_agfl(struct xfs_scrub_context *sc, |
| 98 | int (*fn)(struct xfs_scrub_context *, xfs_agblock_t bno, |
| 99 | void *), |
| 100 | void *priv); |
Darrick J. Wong | b6c1beb | 2017-10-17 21:37:38 -0700 | [diff] [blame] | 101 | |
Darrick J. Wong | efa7a99 | 2017-10-17 21:37:40 -0700 | [diff] [blame] | 102 | int xfs_scrub_setup_ag_btree(struct xfs_scrub_context *sc, |
| 103 | struct xfs_inode *ip, bool force_log); |
| 104 | |
Darrick J. Wong | dcb660f | 2017-10-17 21:37:36 -0700 | [diff] [blame] | 105 | #endif /* __XFS_SCRUB_COMMON_H__ */ |