blob: 96a1e2a9be3f259b2a6f8fe483318b594e46d240 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 */
5#ifndef __XFS_ITABLE_H__
6#define __XFS_ITABLE_H__
7
Darrick J. Wong2810bd62019-07-02 09:39:40 -07008/* 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 */
Darrick J. Wong13d59a22019-07-03 20:36:28 -070015 unsigned int flags; /* see XFS_IBULK_FLAG_* */
Darrick J. Wong2810bd62019-07-02 09:39:40 -070016};
17
Darrick J. Wong13d59a22019-07-03 20:36:28 -070018/* Only iterate within the same AG as startino */
19#define XFS_IBULK_SAME_AG (XFS_IWALK_SAME_AG)
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021/*
Darrick J. Wong2810bd62019-07-02 09:39:40 -070022 * Advance the user buffer pointer by one record of the given size. If the
23 * buffer is now full, return the appropriate error code.
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 */
Darrick J. Wong2810bd62019-07-02 09:39:40 -070025static 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++;
Darrick J. Wonge7ee96d2019-08-28 14:37:57 -070034 return breq->ocount == breq->icount ? -ECANCELED : 0;
Darrick J. Wong2810bd62019-07-02 09:39:40 -070035}
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 * Return stat information in bulk (by-inode) for the filesystem.
39 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Darrick J. Wonge7ee96d2019-08-28 14:37:57 -070041/*
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 */
48
Darrick J. Wong2810bd62019-07-02 09:39:40 -070049typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq,
Darrick J. Wong7035f972019-07-03 20:36:26 -070050 const struct xfs_bulkstat *bstat);
Michal Marekfaa63e92007-07-11 11:10:19 +100051
Darrick J. Wong2810bd62019-07-02 09:39:40 -070052int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
53int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
Darrick J. Wong7035f972019-07-03 20:36:26 -070054void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1,
55 const struct xfs_bulkstat *bstat);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Darrick J. Wong677717f2019-07-02 09:39:43 -070057typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq,
Darrick J. Wong5f19c7f2019-07-03 20:36:27 -070058 const struct xfs_inumbers *igrp);
Michal Marekfaa63e92007-07-11 11:10:19 +100059
Darrick J. Wong677717f2019-07-02 09:39:43 -070060int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter);
Darrick J. Wong5f19c7f2019-07-03 20:36:27 -070061void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1,
62 const struct xfs_inumbers *ig);
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#endif /* __XFS_ITABLE_H__ */