From: Ryosuke Yasuoka <ryasuoka@redhat.com>
To: djwong@kernel.org
Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
david@fromorbit.com, sandeen@sandeen.net,
Ryosuke Yasuoka <ryasuoka@redhat.com>
Subject: [PATCH v3] xfs: Use for_each_perag() to iterate all available AGs
Date: Sun, 16 Apr 2023 17:02:37 +0900 [thread overview]
Message-ID: <20230416080237.16005-1-ryasuoka@redhat.com> (raw)
xfs_filestream_pick_ag() iterates all 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() instead.
Also, create xfs_perag_get_first_avail(). It encapslate the iteration
since it is common operation.
Chnages since v2 [1]:
Use for_each_perag() to iterate all available AGs.
Encapsulate these operations into xfs_perag_get_first_avail().
Set err to zero in its declaration.
[1] https://lore.kernel.org/linux-xfs/20230410160727.3748239-1-ryasuoka@redhat.com/raw
Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
---
fs/xfs/xfs_filestream.c | 5 ++---
fs/xfs/xfs_filestream.h | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
index 22c13933c8f8..66e0d74fe235 100644
--- a/fs/xfs/xfs_filestream.c
+++ b/fs/xfs/xfs_filestream.c
@@ -67,7 +67,7 @@ xfs_filestream_pick_ag(
xfs_extlen_t free = 0, minfree, maxfree = 0;
xfs_agnumber_t agno;
bool first_pass = true;
- int err;
+ int err = 0;
/* 2% of an AG's blocks must be free for it to be chosen. */
minfree = mp->m_sb.sb_agblocks / 50;
@@ -151,8 +151,7 @@ xfs_filestream_pick_ag(
* grab.
*/
if (!max_pag) {
- for_each_perag_wrap(args->mp, 0, start_agno, args->pag)
- break;
+ args->pag = xfs_perag_get_first_avail(mp);
atomic_inc(&args->pag->pagf_fstrms);
*longest = 0;
} else {
diff --git a/fs/xfs/xfs_filestream.h b/fs/xfs/xfs_filestream.h
index 84149ed0e340..92faf84c287f 100644
--- a/fs/xfs/xfs_filestream.h
+++ b/fs/xfs/xfs_filestream.h
@@ -6,6 +6,8 @@
#ifndef __XFS_FILESTREAM_H__
#define __XFS_FILESTREAM_H__
+#include "xfs_ag.h"
+
struct xfs_mount;
struct xfs_inode;
struct xfs_bmalloca;
@@ -25,4 +27,18 @@ xfs_inode_is_filestream(
(ip->i_diflags & XFS_DIFLAG_FILESTREAM);
}
+static inline struct xfs_perag *
+xfs_perag_get_first_avail(
+ struct xfs_mount *mp)
+{
+ struct xfs_perag *pag;
+ xfs_agnumber_t agno;
+
+ for_each_perag(mp, agno, pag)
+ return pag;
+
+ ASSERT(0);
+ return NULL;
+}
+
#endif /* __XFS_FILESTREAM_H__ */
--
2.39.2
reply other threads:[~2023-04-16 8:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230416080237.16005-1-ryasuoka@redhat.com \
--to=ryasuoka@redhat.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®