Skip to content

Commit bf3b8e9

Browse files
yhrcmaiolino
authored andcommitted
xfs: remove xarray mark for reclaimable zones
We can easily check if there are any reclaimble zones by just looking at the used counters in the reclaim buckets, so do that to free up the xarray mark we currently use for this purpose. Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 6731f85 commit bf3b8e9

5 files changed

Lines changed: 25 additions & 12 deletions

File tree

fs/xfs/libxfs/xfs_rtgroup.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ struct xfs_rtgroup {
6464
*/
6565
#define XFS_RTG_FREE XA_MARK_0
6666

67-
/*
68-
* For zoned RT devices this is set on groups that are fully written and that
69-
* have unused blocks. Used by the garbage collection to pick targets.
70-
*/
71-
#define XFS_RTG_RECLAIMABLE XA_MARK_1
72-
7367
static inline struct xfs_rtgroup *to_rtg(struct xfs_group *xg)
7468
{
7569
return container_of(xg, struct xfs_rtgroup, rtg_group);

fs/xfs/xfs_zone_alloc.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ xfs_zone_account_reclaimable(
103103
*/
104104
trace_xfs_zone_emptied(rtg);
105105

106-
if (!was_full)
107-
xfs_group_clear_mark(xg, XFS_RTG_RECLAIMABLE);
108-
109106
spin_lock(&zi->zi_used_buckets_lock);
110107
if (!was_full)
111108
xfs_zone_remove_from_bucket(zi, rgno, from_bucket);
@@ -127,7 +124,6 @@ xfs_zone_account_reclaimable(
127124
xfs_zone_add_to_bucket(zi, rgno, to_bucket);
128125
spin_unlock(&zi->zi_used_buckets_lock);
129126

130-
xfs_group_set_mark(xg, XFS_RTG_RECLAIMABLE);
131127
if (zi->zi_gc_thread && xfs_zoned_need_gc(mp))
132128
wake_up_process(zi->zi_gc_thread);
133129
} else if (to_bucket != from_bucket) {
@@ -142,6 +138,28 @@ xfs_zone_account_reclaimable(
142138
}
143139
}
144140

141+
/*
142+
* Check if we have any zones that can be reclaimed by looking at the entry
143+
* counters for the zone buckets.
144+
*/
145+
bool
146+
xfs_zoned_have_reclaimable(
147+
struct xfs_zone_info *zi)
148+
{
149+
int i;
150+
151+
spin_lock(&zi->zi_used_buckets_lock);
152+
for (i = 0; i < XFS_ZONE_USED_BUCKETS; i++) {
153+
if (zi->zi_used_bucket_entries[i]) {
154+
spin_unlock(&zi->zi_used_buckets_lock);
155+
return true;
156+
}
157+
}
158+
spin_unlock(&zi->zi_used_buckets_lock);
159+
160+
return false;
161+
}
162+
145163
static void
146164
xfs_open_zone_mark_full(
147165
struct xfs_open_zone *oz)

fs/xfs/xfs_zone_gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ xfs_zoned_need_gc(
175175
s64 available, free, threshold;
176176
s32 remainder;
177177

178-
if (!xfs_group_marked(mp, XG_TYPE_RTG, XFS_RTG_RECLAIMABLE))
178+
if (!xfs_zoned_have_reclaimable(mp->m_zone_info))
179179
return false;
180180

181181
available = xfs_estimate_freecounter(mp, XC_FREE_RTAVAILABLE);

fs/xfs/xfs_zone_priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct xfs_open_zone *xfs_open_zone(struct xfs_mount *mp,
113113

114114
int xfs_zone_gc_reset_sync(struct xfs_rtgroup *rtg);
115115
bool xfs_zoned_need_gc(struct xfs_mount *mp);
116+
bool xfs_zoned_have_reclaimable(struct xfs_zone_info *zi);
116117
int xfs_zone_gc_mount(struct xfs_mount *mp);
117118
void xfs_zone_gc_unmount(struct xfs_mount *mp);
118119

fs/xfs/xfs_zone_space_resv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ xfs_zoned_reserve_available(
172172
* processing a pending GC request give up as we're fully out
173173
* of space.
174174
*/
175-
if (!xfs_group_marked(mp, XG_TYPE_RTG, XFS_RTG_RECLAIMABLE) &&
175+
if (!xfs_zoned_have_reclaimable(mp->m_zone_info) &&
176176
!xfs_is_zonegc_running(mp))
177177
break;
178178

0 commit comments

Comments
 (0)