Debian Codegraph @

fs/xfs/xfs_zone_priv.h

raw
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _XFS_ZONE_PRIV_H
3 #define _XFS_ZONE_PRIV_H
4
5 struct xfs_open_zone {
6 /*
7 * Entry in the open zone list and refcount. Protected by
8 * zi_open_zones_lock in struct xfs_zone_info.
9 */
10 struct list_head oz_entry;
11 atomic_t oz_ref;
12
13 /*
14 * oz_allocated is the amount of space already allocated out of the zone
15 * and is protected by oz_alloc_lock.
16 *
17 * For conventional zones it also is the offset of the next write.
18 */
19 spinlock_t oz_alloc_lock;
20 xfs_rgblock_t oz_allocated;
21
22 /*
23 * oz_written is the number of blocks for which we've received a write
24 * completion. oz_written must always be <= oz_allocated and is
25 * protected by the ILOCK of the rmap inode.
26 */
27 xfs_rgblock_t oz_written;
28
29 /*
30 * Write hint (data temperature) assigned to this zone, or
31 * WRITE_LIFE_NOT_SET if none was set.
32 */
33 enum rw_hint oz_write_hint;
34
35 /*
36 * Is this open zone used for garbage collection? There can only be a
37 * single open GC zone, which is pointed to by zi_open_gc_zone in
38 * struct xfs_zone_info. Constant over the life time of an open zone.
39 */
40 bool oz_is_gc;
41
42 /*
43 * Pointer to the RT groups structure for this open zone. Constant over
44 * the life time of an open zone.
45 */
46 struct xfs_rtgroup *oz_rtg;
47
48 struct rcu_head oz_rcu;
49 };
50
51 /*
52 * Number of bitmap buckets to track reclaimable zones. There are 10 buckets
53 * so that each 10% of the usable capacity get their own bucket and GC can
54 * only has to walk the bitmaps of the lesser used zones if there are any.
55 */
56 #define XFS_ZONE_USED_BUCKETS 10u
57
58 struct xfs_zone_info {
59 /*
60 * List of pending space reservations:
61 */
62 spinlock_t zi_reservation_lock;
63 struct list_head zi_reclaim_reservations;
64
65 /*
66 * List and number of open zones:
67 */
68 spinlock_t zi_open_zones_lock;
69 struct list_head zi_open_zones;
70 unsigned int zi_nr_open_zones;
71
72 /*
73 * Free zone search cursor and number of free zones:
74 */
75 atomic_t zi_nr_free_zones;
76
77 /*
78 * Wait queue to wait for free zones or open zone resources to become
79 * available:
80 */
81 wait_queue_head_t zi_zone_wait;
82
83 /*
84 * Pointer to the GC thread, and the current open zone used by GC
85 * (if any).
86 *
87 * zi_open_gc_zone is mostly private to the GC thread, but can be read
88 * for debugging from other threads, in which case zi_open_zones_lock
89 * must be taken to access it.
90 */
91 struct task_struct *zi_gc_thread;
92 struct xfs_open_zone *zi_open_gc_zone;
93
94 /*
95 * List of zones that need a reset:
96 */
97 spinlock_t zi_reset_list_lock;
98 struct xfs_group *zi_reset_list;
99
100 /*
101 * A set of bitmaps to bucket-sort reclaimable zones by used blocks to help
102 * garbage collection to quickly find the best candidate for reclaim.
103 */
104 spinlock_t zi_used_buckets_lock;
105 unsigned int zi_used_bucket_entries[XFS_ZONE_USED_BUCKETS];
106 unsigned long *zi_used_bucket_bitmap[XFS_ZONE_USED_BUCKETS];
107
108 };
109
110 struct xfs_open_zone *xfs_open_zone(struct xfs_mount *mp,
111 enum rw_hint write_hint, bool is_gc);
112
113 int xfs_zone_gc_reset_sync(struct xfs_rtgroup *rtg);
114 bool xfs_zoned_need_gc(struct xfs_mount *mp);
115 bool xfs_zoned_have_reclaimable(struct xfs_zone_info *zi);
116 int xfs_zone_gc_mount(struct xfs_mount *mp);
117 void xfs_zone_gc_unmount(struct xfs_mount *mp);
118
119 void xfs_zoned_resv_wake_all(struct xfs_mount *mp);
120
121 #endif /* _XFS_ZONE_PRIV_H */