xref: /linux/fs/xfs/scrub/findparent.h (revision 9e6b93b7272c56ee02afa7d64b4eb9cec1bb960c)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (c) 2020-2024 Oracle.  All Rights Reserved.
4  * Author: Darrick J. Wong <djwong@kernel.org>
5  */
6 #ifndef __XFS_SCRUB_FINDPARENT_H__
7 #define __XFS_SCRUB_FINDPARENT_H__
8 
9 struct xrep_parent_scan_info {
10 	struct xfs_scrub	*sc;
11 
12 	/* Inode scan cursor. */
13 	struct xchk_iscan	iscan;
14 
15 	/* Hook to capture directory entry updates. */
16 	struct xfs_dir_hook	dhook;
17 
18 	/* Lock protecting parent_ino. */
19 	struct mutex		lock;
20 
21 	/* Parent inode that we've found. */
22 	xfs_ino_t		parent_ino;
23 
24 	bool			lookup_parent;
25 };
26 
27 int xrep_findparent_scan_start(struct xfs_scrub *sc,
28 		struct xrep_parent_scan_info *pscan);
29 int xrep_findparent_scan(struct xrep_parent_scan_info *pscan);
30 void xrep_findparent_scan_teardown(struct xrep_parent_scan_info *pscan);
31 
32 static inline void
33 xrep_findparent_scan_found(
34 	struct xrep_parent_scan_info	*pscan,
35 	xfs_ino_t			ino)
36 {
37 	mutex_lock(&pscan->lock);
38 	pscan->parent_ino = ino;
39 	mutex_unlock(&pscan->lock);
40 }
41 
42 void xrep_findparent_scan_finish_early(struct xrep_parent_scan_info *pscan,
43 		xfs_ino_t ino);
44 
45 int xrep_findparent_confirm(struct xfs_scrub *sc, xfs_ino_t *parent_ino);
46 
47 xfs_ino_t xrep_findparent_self_reference(struct xfs_scrub *sc);
48 xfs_ino_t xrep_findparent_from_dcache(struct xfs_scrub *sc);
49 
50 #endif /* __XFS_SCRUB_FINDPARENT_H__ */
51