diff mbox series

[1/5] xfs: add two wrappers for iterating ags in a AF

Message ID 20241104014439.3786609-2-zhangshida@kylinos.cn (mailing list archive)
State New
Headers show
Series *** Introduce new space allocation algorithm *** | expand

Commit Message

Stephen Zhang Nov. 4, 2024, 1:44 a.m. UTC
From: Shida Zhang <zhangshida@kylinos.cn>

As indicated by the diagram:

|<--------+ af 0 +--------->|
|----------------------------
| ag 0 | ag 1 | ag 2 | ag 3 |
+--------------------------------
   |----------2-->|----1--->|     |
curr_af          start  next_af-1 next_af

1.First iterate over [start, next_af).
2.Then [restart, start).

Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
---
 fs/xfs/libxfs/xfs_ag.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h
index 9edfe0e96439..0c6b7fe5194f 100644
--- a/fs/xfs/libxfs/xfs_ag.h
+++ b/fs/xfs/libxfs/xfs_ag.h
@@ -311,6 +311,23 @@  xfs_perag_next_wrap(
 	for_each_perag_wrap_at((mp), (start_agno), (mp)->m_sb.sb_agcount, \
 				(agno), (pag))
 
+/*
+ * Iterate all AGs from start_agno through wrap_agno, then curr_af through
+ * (start_agno - 1).
+ */
+#define for_each_perag_af_wrap_at(mp, start_agno, wrap_agno, agno, pag, curr_af) \
+	for_each_perag_wrap_range((mp), (start_agno), (curr_af), (wrap_agno), (agno), \
+				  (pag))
+
+/*
+ * Iterate all AGs from start_agno through to the end of the AF, then curr_af
+ * through (start_agno - 1).
+ */
+#define for_each_perag_af_wrap(mp, start_agno, agno, pag, curr_af, next_af) \
+	for_each_perag_af_wrap_at((mp), (start_agno), (next_af), (agno), (pag), \
+				  (curr_af))
+
+
 
 struct aghdr_init_data {
 	/* per ag data */