^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #ifndef __XFS_ITABLE_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define __XFS_ITABLE_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) /* In-memory representation of a userspace request for batch inode data. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) struct xfs_ibulk {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) struct xfs_mount *mp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) void __user *ubuffer; /* user output buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) xfs_ino_t startino; /* start with this inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) unsigned int icount; /* number of elements in ubuffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) unsigned int ocount; /* number of records returned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) unsigned int flags; /* see XFS_IBULK_FLAG_* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /* Only iterate within the same AG as startino */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define XFS_IBULK_SAME_AG (XFS_IWALK_SAME_AG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * Advance the user buffer pointer by one record of the given size. If the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * buffer is now full, return the appropriate error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) xfs_ibulk_advance(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct xfs_ibulk *breq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) size_t bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) char __user *b = breq->ubuffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) breq->ubuffer = b + bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) breq->ocount++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) return breq->ocount == breq->icount ? -ECANCELED : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * Return stat information in bulk (by-inode) for the filesystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * Return codes for the formatter function are 0 to continue iterating, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * non-zero to stop iterating. Any non-zero value will be passed up to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * bulkstat/inumbers caller. The special value -ECANCELED can be used to stop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * iteration, as neither bulkstat nor inumbers will ever generate that error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * code on their own.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) const struct xfs_bulkstat *bstat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) const struct xfs_bulkstat *bstat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) const struct xfs_inumbers *igrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) const struct xfs_inumbers *ig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #endif /* __XFS_ITABLE_H__ */