summaryrefslogtreecommitdiff
path: root/fs/xfs/scrub/iscan.h
blob: 947176620bc3d74b879c3654414d9786023d3f77 (plain)
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
54
55
56
57
58
59
60
61
62
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2022 Oracle.  All Rights Reserved.
 * Author: Darrick J. Wong <djwong@kernel.org>
 */
#ifndef __XFS_SCRUB_ISCAN_H__
#define __XFS_SCRUB_ISCAN_H__

struct xchk_iscan {
	/* Lock to protect the scan cursor. */
	struct mutex		lock;

	/* This is the inode that will be examined next. */
	xfs_ino_t		cursor_ino;

	/*
	 * This is the last inode that we've successfully scanned, either
	 * because the caller scanned it, or we moved the cursor past an empty
	 * part of the inode address space.  Scan callers should only use the
	 * xchk_iscan_visit function to modify this.
	 */
	xfs_ino_t		__visited_ino;

	/* Operational state of the livescan. */
	unsigned long		__opstate;

	/* Give up on iterating @cursor_ino if we can't iget it by this time. */
	unsigned long		__iget_deadline;

	/* Amount of time (in ms) that we will try to iget an inode. */
	unsigned int		iget_timeout;

	/* Wait this many ms to retry an iget. */
	unsigned int		iget_retry_delay;
};

/* Set if the scan has been aborted due to some event in the fs. */
#define XCHK_ISCAN_OPSTATE_ABORTED	(1)

static inline bool
xchk_iscan_aborted(const struct xchk_iscan *iscan)
{
	return test_bit(XCHK_ISCAN_OPSTATE_ABORTED, &iscan->__opstate);
}

static inline void
xchk_iscan_abort(struct xchk_iscan *iscan)
{
	set_bit(XCHK_ISCAN_OPSTATE_ABORTED, &iscan->__opstate);
}

void xchk_iscan_start(struct xchk_iscan *iscan, unsigned int iget_timeout,
		unsigned int iget_retry_delay);
void xchk_iscan_finish(struct xchk_iscan *iscan);

int xchk_iscan_iter(struct xfs_scrub *sc, struct xchk_iscan *iscan,
		struct xfs_inode **ipp);

void xchk_iscan_mark_visited(struct xchk_iscan *iscan, struct xfs_inode *ip);
bool xchk_iscan_want_live_update(struct xchk_iscan *iscan, xfs_ino_t ino);

#endif /* __XFS_SCRUB_ISCAN_H__ */