drm/atomic-helper: document drm_atomic_helper_check() restrictions
[drm/drm-misc.git] / fs / xfs / scrub / newbt.h
blob3d804d31af24a87296a1cf98a779b2c9a3824250
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2022-2023 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <djwong@kernel.org>
5 */
6 #ifndef __XFS_SCRUB_NEWBT_H__
7 #define __XFS_SCRUB_NEWBT_H__
9 struct xfs_alloc_arg;
11 struct xrep_newbt_resv {
12 /* Link to list of extents that we've reserved. */
13 struct list_head list;
15 struct xfs_perag *pag;
17 /* Auto-freeing this reservation if we don't commit. */
18 struct xfs_alloc_autoreap autoreap;
20 /* AG block of the extent we reserved. */
21 xfs_agblock_t agbno;
23 /* Length of the reservation. */
24 xfs_extlen_t len;
26 /* How much of this reservation has been used. */
27 xfs_extlen_t used;
30 struct xrep_newbt {
31 struct xfs_scrub *sc;
33 /* Custom allocation function, or NULL for xfs_alloc_vextent */
34 int (*alloc_vextent)(struct xfs_scrub *sc,
35 struct xfs_alloc_arg *args,
36 xfs_fsblock_t alloc_hint);
38 /* List of extents that we've reserved. */
39 struct list_head resv_list;
41 /* Fake root for new btree. */
42 union {
43 struct xbtree_afakeroot afake;
44 struct xbtree_ifakeroot ifake;
47 /* rmap owner of these blocks */
48 struct xfs_owner_info oinfo;
50 /* btree geometry for the bulk loader */
51 struct xfs_btree_bload bload;
53 /* Allocation hint */
54 xfs_fsblock_t alloc_hint;
56 /* per-ag reservation type */
57 enum xfs_ag_resv_type resv;
60 void xrep_newbt_init_bare(struct xrep_newbt *xnr, struct xfs_scrub *sc);
61 void xrep_newbt_init_ag(struct xrep_newbt *xnr, struct xfs_scrub *sc,
62 const struct xfs_owner_info *oinfo, xfs_fsblock_t alloc_hint,
63 enum xfs_ag_resv_type resv);
64 int xrep_newbt_init_inode(struct xrep_newbt *xnr, struct xfs_scrub *sc,
65 int whichfork, const struct xfs_owner_info *oinfo);
66 int xrep_newbt_alloc_blocks(struct xrep_newbt *xnr, uint64_t nr_blocks);
67 int xrep_newbt_add_extent(struct xrep_newbt *xnr, struct xfs_perag *pag,
68 xfs_agblock_t agbno, xfs_extlen_t len);
69 void xrep_newbt_cancel(struct xrep_newbt *xnr);
70 int xrep_newbt_commit(struct xrep_newbt *xnr);
71 int xrep_newbt_claim_block(struct xfs_btree_cur *cur, struct xrep_newbt *xnr,
72 union xfs_btree_ptr *ptr);
73 unsigned int xrep_newbt_unused_blocks(struct xrep_newbt *xnr);
75 #endif /* __XFS_SCRUB_NEWBT_H__ */