xfs: Use for_each_perag() to iterate all available AGs
PATCH v3 1/1 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/[email protected]/raw
Signed-off-by Ryosuke Yasuoka <[email protected]>
--- fs/xfs/xfs_filestream.c | 5 ++--- fs/xfs/xfs_filestream.h | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-)
fs/xfs/xfs_filestream.c +2 -3
@@ -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 {
fs/xfs/xfs_filestream.h +16 -0
@@ -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__ */
Signature · 1 line
2.39.2