xref: /linux/fs/xfs/xfs_iwalk.h (revision e7ee96dfb8c2687a29d2c5c3b06c967fa54b839c)
1a211432cSDarrick J. Wong /* SPDX-License-Identifier: GPL-2.0-or-later */
2a211432cSDarrick J. Wong /*
3a211432cSDarrick J. Wong  * Copyright (C) 2019 Oracle.  All Rights Reserved.
4a211432cSDarrick J. Wong  * Author: Darrick J. Wong <darrick.wong@oracle.com>
5a211432cSDarrick J. Wong  */
6a211432cSDarrick J. Wong #ifndef __XFS_IWALK_H__
7a211432cSDarrick J. Wong #define __XFS_IWALK_H__
8a211432cSDarrick J. Wong 
9*e7ee96dfSDarrick J. Wong /*
10*e7ee96dfSDarrick J. Wong  * Return codes for the inode/inobt walk function are 0 to continue iterating,
11*e7ee96dfSDarrick J. Wong  * and non-zero to stop iterating.  Any non-zero value will be passed up to the
12*e7ee96dfSDarrick J. Wong  * iwalk or inobt_walk caller.  The special value -ECANCELED can be used to
13*e7ee96dfSDarrick J. Wong  * stop iteration, as neither iwalk nor inobt_walk will ever generate that
14*e7ee96dfSDarrick J. Wong  * error code on their own.
15*e7ee96dfSDarrick J. Wong  */
16*e7ee96dfSDarrick J. Wong 
17a211432cSDarrick J. Wong /* Walk all inodes in the filesystem starting from @startino. */
18a211432cSDarrick J. Wong typedef int (*xfs_iwalk_fn)(struct xfs_mount *mp, struct xfs_trans *tp,
19a211432cSDarrick J. Wong 			    xfs_ino_t ino, void *data);
20a211432cSDarrick J. Wong /* Return values for xfs_iwalk_fn. */
21a211432cSDarrick J. Wong #define XFS_IWALK_CONTINUE	(XFS_ITER_CONTINUE)
22a211432cSDarrick J. Wong 
23a211432cSDarrick J. Wong int xfs_iwalk(struct xfs_mount *mp, struct xfs_trans *tp, xfs_ino_t startino,
2413d59a2aSDarrick J. Wong 		unsigned int flags, xfs_iwalk_fn iwalk_fn,
2513d59a2aSDarrick J. Wong 		unsigned int inode_records, void *data);
2640786717SDarrick J. Wong int xfs_iwalk_threaded(struct xfs_mount *mp, xfs_ino_t startino,
2713d59a2aSDarrick J. Wong 		unsigned int flags, xfs_iwalk_fn iwalk_fn,
2813d59a2aSDarrick J. Wong 		unsigned int inode_records, bool poll, void *data);
2913d59a2aSDarrick J. Wong 
3013d59a2aSDarrick J. Wong /* Only iterate inodes within the same AG as @startino. */
3113d59a2aSDarrick J. Wong #define XFS_IWALK_SAME_AG	(0x1)
3213d59a2aSDarrick J. Wong 
3313d59a2aSDarrick J. Wong #define XFS_IWALK_FLAGS_ALL	(XFS_IWALK_SAME_AG)
34a211432cSDarrick J. Wong 
3504b8fba2SDarrick J. Wong /* Walk all inode btree records in the filesystem starting from @startino. */
3604b8fba2SDarrick J. Wong typedef int (*xfs_inobt_walk_fn)(struct xfs_mount *mp, struct xfs_trans *tp,
3704b8fba2SDarrick J. Wong 				 xfs_agnumber_t agno,
3804b8fba2SDarrick J. Wong 				 const struct xfs_inobt_rec_incore *irec,
3904b8fba2SDarrick J. Wong 				 void *data);
4004b8fba2SDarrick J. Wong 
4104b8fba2SDarrick J. Wong int xfs_inobt_walk(struct xfs_mount *mp, struct xfs_trans *tp,
4213d59a2aSDarrick J. Wong 		xfs_ino_t startino, unsigned int flags,
4313d59a2aSDarrick J. Wong 		xfs_inobt_walk_fn inobt_walk_fn, unsigned int inobt_records,
4413d59a2aSDarrick J. Wong 		void *data);
4513d59a2aSDarrick J. Wong 
4613d59a2aSDarrick J. Wong /* Only iterate inobt records within the same AG as @startino. */
4713d59a2aSDarrick J. Wong #define XFS_INOBT_WALK_SAME_AG	(XFS_IWALK_SAME_AG)
4813d59a2aSDarrick J. Wong 
4913d59a2aSDarrick J. Wong #define XFS_INOBT_WALK_FLAGS_ALL (XFS_INOBT_WALK_SAME_AG)
5004b8fba2SDarrick J. Wong 
51a211432cSDarrick J. Wong #endif /* __XFS_IWALK_H__ */
52