lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230416080237.16005-1-ryasuoka@redhat.com>
Date:   Sun, 16 Apr 2023 17:02:37 +0900
From:   Ryosuke Yasuoka <ryasuoka@...hat.com>
To:     djwong@...nel.org
Cc:     linux-xfs@...r.kernel.org, linux-kernel@...r.kernel.org,
        david@...morbit.com, sandeen@...deen.net,
        Ryosuke Yasuoka <ryasuoka@...hat.com>
Subject: [PATCH v3] xfs: Use for_each_perag() to iterate all available AGs

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@...hat.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ