1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _XFS_ZONE_ALLOC_H
3 #define _XFS_ZONE_ALLOC_H
4
5 struct iomap_ioend;
6 struct xfs_open_zone;
7
8 struct xfs_zone_alloc_ctx {
9 struct xfs_open_zone *open_zone;
10 xfs_filblks_t reserved_blocks;
11 };
12
13 /*
14 * Grab any available space, even if it is less than what the caller asked for.
15 */
16 #define XFS_ZR_GREEDY (1U << 0)
17 /*
18 * Only grab instantly available space, don't wait or GC.
19 */
20 #define XFS_ZR_NOWAIT (1U << 1)
21 /*
22 * Dip into the reserved pool.
23 */
24 #define XFS_ZR_RESERVED (1U << 2)
25
26 int xfs_zoned_space_reserve(struct xfs_inode *ip, xfs_filblks_t count_fsb,
27 unsigned int flags, struct xfs_zone_alloc_ctx *ac);
28 void xfs_zoned_space_unreserve(struct xfs_inode *ip,
29 struct xfs_zone_alloc_ctx *ac);
30 void xfs_zoned_add_available(struct xfs_mount *mp, xfs_filblks_t count_fsb);
31
32 void xfs_zone_alloc_and_submit(struct iomap_ioend *ioend,
33 struct xfs_open_zone **oz);
34 int xfs_zone_free_blocks(struct xfs_trans *tp, struct xfs_rtgroup *rtg,
35 xfs_fsblock_t fsbno, xfs_filblks_t len);
36 int xfs_zoned_end_io(struct xfs_inode *ip, xfs_off_t offset, xfs_off_t count,
37 xfs_daddr_t daddr, struct xfs_open_zone *oz,
38 xfs_fsblock_t old_startblock);
39 void xfs_open_zone_put(struct xfs_open_zone *oz);
40
41 void xfs_zoned_wake_all(struct xfs_mount *mp);
42 bool xfs_zone_rgbno_is_valid(struct xfs_rtgroup *rtg, xfs_rgnumber_t rgbno);
43 void xfs_mark_rtg_boundary(struct iomap_ioend *ioend);
44
45 uint64_t xfs_zoned_default_resblks(struct xfs_mount *mp,
46 enum xfs_free_counter ctr);
47 void xfs_zoned_show_stats(struct seq_file *m, struct xfs_mount *mp);
48
49 #ifdef CONFIG_XFS_RT
50 int xfs_mount_zones(struct xfs_mount *mp);
51 void xfs_unmount_zones(struct xfs_mount *mp);
52 void xfs_zone_gc_start(struct xfs_mount *mp);
53 void xfs_zone_gc_stop(struct xfs_mount *mp);
54 #else
xfs_mount_zones(struct xfs_mount * mp)55 static inline int xfs_mount_zones(struct xfs_mount *mp)
56 {
57 return -EIO;
58 }
xfs_unmount_zones(struct xfs_mount * mp)59 static inline void xfs_unmount_zones(struct xfs_mount *mp)
60 {
61 }
xfs_zone_gc_start(struct xfs_mount * mp)62 static inline void xfs_zone_gc_start(struct xfs_mount *mp)
63 {
64 }
xfs_zone_gc_stop(struct xfs_mount * mp)65 static inline void xfs_zone_gc_stop(struct xfs_mount *mp)
66 {
67 }
68 #endif /* CONFIG_XFS_RT */
69
70 #endif /* _XFS_ZONE_ALLOC_H */
71