xref: /openbmc/linux/fs/xfs/xfs_itable.h (revision e67fe633)
10b61f8a4SDave Chinner // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
41da177e4SLinus Torvalds  */
51da177e4SLinus Torvalds #ifndef __XFS_ITABLE_H__
61da177e4SLinus Torvalds #define	__XFS_ITABLE_H__
71da177e4SLinus Torvalds 
82810bd68SDarrick J. Wong /* In-memory representation of a userspace request for batch inode data. */
92810bd68SDarrick J. Wong struct xfs_ibulk {
102810bd68SDarrick J. Wong 	struct xfs_mount	*mp;
11*e67fe633SChristian Brauner 	struct mnt_idmap	*idmap;
122810bd68SDarrick J. Wong 	void __user		*ubuffer; /* user output buffer */
132810bd68SDarrick J. Wong 	xfs_ino_t		startino; /* start with this inode */
142810bd68SDarrick J. Wong 	unsigned int		icount;   /* number of elements in ubuffer */
152810bd68SDarrick J. Wong 	unsigned int		ocount;   /* number of records returned */
1613d59a2aSDarrick J. Wong 	unsigned int		flags;    /* see XFS_IBULK_FLAG_* */
172810bd68SDarrick J. Wong };
182810bd68SDarrick J. Wong 
1913d59a2aSDarrick J. Wong /* Only iterate within the same AG as startino */
205b35d922SChandan Babu R #define XFS_IBULK_SAME_AG	(1U << 0)
2113d59a2aSDarrick J. Wong 
22c3c4ecb5SChandan Babu R /* Fill out the bs_extents64 field if set. */
23c3c4ecb5SChandan Babu R #define XFS_IBULK_NREXT64	(1U << 1)
24c3c4ecb5SChandan Babu R 
251da177e4SLinus Torvalds /*
262810bd68SDarrick J. Wong  * Advance the user buffer pointer by one record of the given size.  If the
272810bd68SDarrick J. Wong  * buffer is now full, return the appropriate error code.
281da177e4SLinus Torvalds  */
292810bd68SDarrick J. Wong static inline int
xfs_ibulk_advance(struct xfs_ibulk * breq,size_t bytes)302810bd68SDarrick J. Wong xfs_ibulk_advance(
312810bd68SDarrick J. Wong 	struct xfs_ibulk	*breq,
322810bd68SDarrick J. Wong 	size_t			bytes)
332810bd68SDarrick J. Wong {
342810bd68SDarrick J. Wong 	char __user		*b = breq->ubuffer;
352810bd68SDarrick J. Wong 
362810bd68SDarrick J. Wong 	breq->ubuffer = b + bytes;
372810bd68SDarrick J. Wong 	breq->ocount++;
38e7ee96dfSDarrick J. Wong 	return breq->ocount == breq->icount ? -ECANCELED : 0;
392810bd68SDarrick J. Wong }
401da177e4SLinus Torvalds 
411da177e4SLinus Torvalds /*
421da177e4SLinus Torvalds  * Return stat information in bulk (by-inode) for the filesystem.
431da177e4SLinus Torvalds  */
441da177e4SLinus Torvalds 
45e7ee96dfSDarrick J. Wong /*
46e7ee96dfSDarrick J. Wong  * Return codes for the formatter function are 0 to continue iterating, and
47e7ee96dfSDarrick J. Wong  * non-zero to stop iterating.  Any non-zero value will be passed up to the
48e7ee96dfSDarrick J. Wong  * bulkstat/inumbers caller.  The special value -ECANCELED can be used to stop
49e7ee96dfSDarrick J. Wong  * iteration, as neither bulkstat nor inumbers will ever generate that error
50e7ee96dfSDarrick J. Wong  * code on their own.
51e7ee96dfSDarrick J. Wong  */
52e7ee96dfSDarrick J. Wong 
532810bd68SDarrick J. Wong typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq,
547035f972SDarrick J. Wong 		const struct xfs_bulkstat *bstat);
55faa63e95SMichal Marek 
562810bd68SDarrick J. Wong int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
572810bd68SDarrick J. Wong int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
587035f972SDarrick J. Wong void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1,
597035f972SDarrick J. Wong 		const struct xfs_bulkstat *bstat);
601da177e4SLinus Torvalds 
61677717fbSDarrick J. Wong typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq,
625f19c7fcSDarrick J. Wong 		const struct xfs_inumbers *igrp);
63faa63e95SMichal Marek 
64677717fbSDarrick J. Wong int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter);
655f19c7fcSDarrick J. Wong void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1,
665f19c7fcSDarrick J. Wong 		const struct xfs_inumbers *ig);
671da177e4SLinus Torvalds 
681da177e4SLinus Torvalds #endif	/* __XFS_ITABLE_H__ */
69