xref: /OK3568_Linux_fs/kernel/fs/xfs/xfs_iwalk.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (C) 2019 Oracle.  All Rights Reserved.
4*4882a593Smuzhiyun  * Author: Darrick J. Wong <darrick.wong@oracle.com>
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun #ifndef __XFS_IWALK_H__
7*4882a593Smuzhiyun #define __XFS_IWALK_H__
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun /*
10*4882a593Smuzhiyun  * Return codes for the inode/inobt walk function are 0 to continue iterating,
11*4882a593Smuzhiyun  * and non-zero to stop iterating.  Any non-zero value will be passed up to the
12*4882a593Smuzhiyun  * iwalk or inobt_walk caller.  The special value -ECANCELED can be used to
13*4882a593Smuzhiyun  * stop iteration, as neither iwalk nor inobt_walk will ever generate that
14*4882a593Smuzhiyun  * error code on their own.
15*4882a593Smuzhiyun  */
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun /* Walk all inodes in the filesystem starting from @startino. */
18*4882a593Smuzhiyun typedef int (*xfs_iwalk_fn)(struct xfs_mount *mp, struct xfs_trans *tp,
19*4882a593Smuzhiyun 			    xfs_ino_t ino, void *data);
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun int xfs_iwalk(struct xfs_mount *mp, struct xfs_trans *tp, xfs_ino_t startino,
22*4882a593Smuzhiyun 		unsigned int flags, xfs_iwalk_fn iwalk_fn,
23*4882a593Smuzhiyun 		unsigned int inode_records, void *data);
24*4882a593Smuzhiyun int xfs_iwalk_threaded(struct xfs_mount *mp, xfs_ino_t startino,
25*4882a593Smuzhiyun 		unsigned int flags, xfs_iwalk_fn iwalk_fn,
26*4882a593Smuzhiyun 		unsigned int inode_records, bool poll, void *data);
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun /* Only iterate inodes within the same AG as @startino. */
29*4882a593Smuzhiyun #define XFS_IWALK_SAME_AG	(0x1)
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun #define XFS_IWALK_FLAGS_ALL	(XFS_IWALK_SAME_AG)
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun /* Walk all inode btree records in the filesystem starting from @startino. */
34*4882a593Smuzhiyun typedef int (*xfs_inobt_walk_fn)(struct xfs_mount *mp, struct xfs_trans *tp,
35*4882a593Smuzhiyun 				 xfs_agnumber_t agno,
36*4882a593Smuzhiyun 				 const struct xfs_inobt_rec_incore *irec,
37*4882a593Smuzhiyun 				 void *data);
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun int xfs_inobt_walk(struct xfs_mount *mp, struct xfs_trans *tp,
40*4882a593Smuzhiyun 		xfs_ino_t startino, unsigned int flags,
41*4882a593Smuzhiyun 		xfs_inobt_walk_fn inobt_walk_fn, unsigned int inobt_records,
42*4882a593Smuzhiyun 		void *data);
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun /* Only iterate inobt records within the same AG as @startino. */
45*4882a593Smuzhiyun #define XFS_INOBT_WALK_SAME_AG	(XFS_IWALK_SAME_AG)
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun #define XFS_INOBT_WALK_FLAGS_ALL (XFS_INOBT_WALK_SAME_AG)
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun #endif /* __XFS_IWALK_H__ */
50