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