xref: /linux/fs/xfs/libxfs/xfs_zones.h (revision c148bc7535650fbfa95a1f571b9ffa2ab478ea33)
1*720c2d58SChristoph Hellwig /* SPDX-License-Identifier: GPL-2.0 */
2*720c2d58SChristoph Hellwig #ifndef _LIBXFS_ZONES_H
3*720c2d58SChristoph Hellwig #define _LIBXFS_ZONES_H
4*720c2d58SChristoph Hellwig 
5*720c2d58SChristoph Hellwig struct xfs_rtgroup;
6*720c2d58SChristoph Hellwig 
7*720c2d58SChristoph Hellwig /*
8*720c2d58SChristoph Hellwig  * In order to guarantee forward progress for GC we need to reserve at least
9*720c2d58SChristoph Hellwig  * two zones:  one that will be used for moving data into and one spare zone
10*720c2d58SChristoph Hellwig  * making sure that we have enough space to relocate a nearly-full zone.
11*720c2d58SChristoph Hellwig  * To allow for slightly sloppy accounting for when we need to reserve the
12*720c2d58SChristoph Hellwig  * second zone, we actually reserve three as that is easier than doing fully
13*720c2d58SChristoph Hellwig  * accurate bookkeeping.
14*720c2d58SChristoph Hellwig  */
15*720c2d58SChristoph Hellwig #define XFS_GC_ZONES		3U
16*720c2d58SChristoph Hellwig 
17*720c2d58SChristoph Hellwig /*
18*720c2d58SChristoph Hellwig  * In addition we need two zones for user writes, one open zone for writing
19*720c2d58SChristoph Hellwig  * and one to still have available blocks without resetting the open zone
20*720c2d58SChristoph Hellwig  * when data in the open zone has been freed.
21*720c2d58SChristoph Hellwig  */
22*720c2d58SChristoph Hellwig #define XFS_RESERVED_ZONES	(XFS_GC_ZONES + 1)
23*720c2d58SChristoph Hellwig #define XFS_MIN_ZONES		(XFS_RESERVED_ZONES + 1)
24*720c2d58SChristoph Hellwig 
25*720c2d58SChristoph Hellwig /*
26*720c2d58SChristoph Hellwig  * Always keep one zone out of the general open zone pool to allow for GC to
27*720c2d58SChristoph Hellwig  * happen while other writers are waiting for free space.
28*720c2d58SChristoph Hellwig  */
29*720c2d58SChristoph Hellwig #define XFS_OPEN_GC_ZONES	1U
30*720c2d58SChristoph Hellwig #define XFS_MIN_OPEN_ZONES	(XFS_OPEN_GC_ZONES + 1U)
31*720c2d58SChristoph Hellwig 
32*720c2d58SChristoph Hellwig bool xfs_zone_validate(struct blk_zone *zone, struct xfs_rtgroup *rtg,
33*720c2d58SChristoph Hellwig 	xfs_rgblock_t *write_pointer);
34*720c2d58SChristoph Hellwig 
35*720c2d58SChristoph Hellwig #endif /* _LIBXFS_ZONES_H */
36