Line data Source code
1 : /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 : /* 3 : * Copyright (C) 2021-2023 Oracle. All Rights Reserved. 4 : * Author: Darrick J. Wong <djwong@kernel.org> 5 : */ 6 : #ifndef __XFS_SCRUB_ISCAN_H__ 7 : #define __XFS_SCRUB_ISCAN_H__ 8 : 9 : struct xchk_iscan { 10 : struct xfs_scrub *sc; 11 : 12 : /* Lock to protect the scan cursor. */ 13 : struct mutex lock; 14 : 15 : /* 16 : * This is the first inode in the inumber address space that we 17 : * examined. When the scan wraps around back to here, the scan is 18 : * finished. 19 : */ 20 : xfs_ino_t scan_start_ino; 21 : 22 : /* This is the inode that will be examined next. */ 23 : xfs_ino_t cursor_ino; 24 : 25 : /* 26 : * This is the last inode that we've successfully scanned, either 27 : * because the caller scanned it, or we moved the cursor past an empty 28 : * part of the inode address space. Scan callers should only use the 29 : * xchk_iscan_visit function to modify this. 30 : */ 31 : xfs_ino_t __visited_ino; 32 : 33 : /* Operational state of the livescan. */ 34 : unsigned long __opstate; 35 : 36 : /* Give up on iterating @cursor_ino if we can't iget it by this time. */ 37 : unsigned long __iget_deadline; 38 : 39 : /* Amount of time (in ms) that we will try to iget an inode. */ 40 : unsigned int iget_timeout; 41 : 42 : /* Wait this many ms to retry an iget. */ 43 : unsigned int iget_retry_delay; 44 : 45 : /* 46 : * The scan grabs batches of inodes and stashes them here before 47 : * handing them out with _iter. Unallocated inodes are set in the 48 : * mask so that all updates to that inode are selected for live 49 : * update propagation. 50 : */ 51 : xfs_ino_t __batch_ino; 52 : xfs_inofree_t __skipped_inomask; 53 : struct xfs_inode *__inodes[XFS_INODES_PER_CHUNK]; 54 : }; 55 : 56 : /* Set if the scan has been aborted due to some event in the fs. */ 57 : #define XCHK_ISCAN_OPSTATE_ABORTED (1) 58 : 59 : static inline bool 60 4716536937 : xchk_iscan_aborted(const struct xchk_iscan *iscan) 61 : { 62 4716536937 : return test_bit(XCHK_ISCAN_OPSTATE_ABORTED, &iscan->__opstate); 63 : } 64 : 65 : static inline void 66 : xchk_iscan_abort(struct xchk_iscan *iscan) 67 : { 68 149571 : set_bit(XCHK_ISCAN_OPSTATE_ABORTED, &iscan->__opstate); 69 121 : } 70 : 71 : void xchk_iscan_start(struct xfs_scrub *sc, unsigned int iget_timeout, 72 : unsigned int iget_retry_delay, struct xchk_iscan *iscan); 73 : void xchk_iscan_finish_early(struct xchk_iscan *iscan); 74 : void xchk_iscan_teardown(struct xchk_iscan *iscan); 75 : 76 : int xchk_iscan_iter(struct xchk_iscan *iscan, struct xfs_inode **ipp); 77 : void xchk_iscan_iter_finish(struct xchk_iscan *iscan); 78 : 79 : void xchk_iscan_mark_visited(struct xchk_iscan *iscan, struct xfs_inode *ip); 80 : bool xchk_iscan_want_live_update(struct xchk_iscan *iscan, xfs_ino_t ino); 81 : 82 : #endif /* __XFS_SCRUB_ISCAN_H__ */