public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] xfs: Use for_each_perag_from() to iterate all available AGs
@ 2023-04-10 16:07 Ryosuke Yasuoka
  2023-04-10 16:30 ` Darrick J. Wong
  0 siblings, 1 reply; 4+ messages in thread
From: Ryosuke Yasuoka @ 2023-04-10 16:07 UTC (permalink / raw)
  To: djwong; +Cc: linux-xfs, linux-kernel, sandeen, david, Ryosuke Yasuoka

xfs_filestream_pick_ag() iterates all the available AGs when no
unassociated AGs are available by using for_each_perag_wrap().
To iterate all the available AGs, just use for_each_perag_from() instead.


This patch cleans up a code where xfs_filestream_pick_ag() iterates 
all the available AGs when no unassociated AGs are available.
Current implementation is using a for_each_perag_wrap() macro which
iterates all AGs from start_agno through wrap_agno, wraps to
restart_agno, and then iterates again toward to (start_agno - 1).
In this case, xfs_filestream_pick_ag() start to iterate from 0 and
does't need to wrap. Although passing 0 as start_agno to
for_each_perag_wrap() 
is not problematic, we have already a for_each_perag() macro family
which just iterates all AGs from 0 and doesn't wrap. Hense, I propose
to use for_each_perag() family simply.


Changes since v1 [1]:
Use for_each_perag_from() instead of for_each_perag() to clarify
where we are iterating from.

[1]:
https://lore.kernel.org/linux-xfs/CAHpthZrvhqh8O1HO7U_jVnaq9R9Ur=Yq2eWzjWfNx3ryDbnGPA@mail.gmail.com/T/#m5704d0409bec1ce5273be0d3860e8ad60e9886fd

Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
---
 fs/xfs/xfs_filestream.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
index 22c13933c8f8..29acd9f7d422 100644
--- a/fs/xfs/xfs_filestream.c
+++ b/fs/xfs/xfs_filestream.c
@@ -151,7 +151,8 @@ xfs_filestream_pick_ag(
 		 * grab.
 		 */
 		if (!max_pag) {
-			for_each_perag_wrap(args->mp, 0, start_agno, args->pag)
+			start_agno = 0;
+			for_each_perag_from(args->mp, start_agno, args->pag)
 				break;
 			atomic_inc(&args->pag->pagf_fstrms);
 			*longest = 0;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-12  5:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-10 16:07 [PATCH v2] xfs: Use for_each_perag_from() to iterate all available AGs Ryosuke Yasuoka
2023-04-10 16:30 ` Darrick J. Wong
2023-04-10 17:59   ` Darrick J. Wong
2023-04-12  5:20     ` Ryosuke Yasuoka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox