blob: 96a1e2a9be3f259b2a6f8fe483318b594e46d240 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
4 */
5#ifndef __XFS_ITABLE_H__
6#define __XFS_ITABLE_H__
7
David Brazdil0f672f62019-12-10 10:32:29 +00008/* In-memory representation of a userspace request for batch inode data. */
9struct xfs_ibulk {
10 struct xfs_mount *mp;
11 void __user *ubuffer; /* user output buffer */
12 xfs_ino_t startino; /* start with this inode */
13 unsigned int icount; /* number of elements in ubuffer */
14 unsigned int ocount; /* number of records returned */
15 unsigned int flags; /* see XFS_IBULK_FLAG_* */
16};
17
18/* Only iterate within the same AG as startino */
19#define XFS_IBULK_SAME_AG (XFS_IWALK_SAME_AG)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000020
21/*
David Brazdil0f672f62019-12-10 10:32:29 +000022 * Advance the user buffer pointer by one record of the given size. If the
23 * buffer is now full, return the appropriate error code.
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000024 */
David Brazdil0f672f62019-12-10 10:32:29 +000025static inline int
26xfs_ibulk_advance(
27 struct xfs_ibulk *breq,
28 size_t bytes)
29{
30 char __user *b = breq->ubuffer;
31
32 breq->ubuffer = b + bytes;
33 breq->ocount++;
34 return breq->ocount == breq->icount ? -ECANCELED : 0;
35}
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000036
37/*
38 * Return stat information in bulk (by-inode) for the filesystem.
39 */
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000040
David Brazdil0f672f62019-12-10 10:32:29 +000041/*
42 * Return codes for the formatter function are 0 to continue iterating, and
43 * non-zero to stop iterating. Any non-zero value will be passed up to the
44 * bulkstat/inumbers caller. The special value -ECANCELED can be used to stop
45 * iteration, as neither bulkstat nor inumbers will ever generate that error
46 * code on their own.
47 */
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000048
David Brazdil0f672f62019-12-10 10:32:29 +000049typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq,
50 const struct xfs_bulkstat *bstat);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000051
David Brazdil0f672f62019-12-10 10:32:29 +000052int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
53int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
54void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1,
55 const struct xfs_bulkstat *bstat);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000056
David Brazdil0f672f62019-12-10 10:32:29 +000057typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq,
58 const struct xfs_inumbers *igrp);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000059
David Brazdil0f672f62019-12-10 10:32:29 +000060int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter);
61void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1,
62 const struct xfs_inumbers *ig);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000063
64#endif /* __XFS_ITABLE_H__ */