Skip to content

Commit 5662d38

Browse files
committed
xfs: move xfs_inode_ag_iterator to be closer to the perag walking code
Move the xfs_inode_ag_iterator function to be nearer xfs_inode_ag_walk so that we don't have to scroll back and forth to figure out how the incore inode walking function works. No functional changes. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Brian Foster <[email protected]>
1 parent 7e88d31 commit 5662d38

File tree

1 file changed

+48
-40
lines changed

1 file changed

+48
-40
lines changed

fs/xfs/xfs_icache.c

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,10 @@ xfs_inode_ag_walk_grab(
811811
return false;
812812
}
813813

814+
/*
815+
* For a given per-AG structure @pag, grab, @execute, and rele all incore
816+
* inodes with the given radix tree @tag.
817+
*/
814818
STATIC int
815819
xfs_inode_ag_walk(
816820
struct xfs_mount *mp,
@@ -916,6 +920,50 @@ xfs_inode_ag_walk(
916920
return last_error;
917921
}
918922

923+
/* Fetch the next (possibly tagged) per-AG structure. */
924+
static inline struct xfs_perag *
925+
xfs_inode_walk_get_perag(
926+
struct xfs_mount *mp,
927+
xfs_agnumber_t agno,
928+
int tag)
929+
{
930+
if (tag == XFS_ICI_NO_TAG)
931+
return xfs_perag_get(mp, agno);
932+
return xfs_perag_get_tag(mp, agno, tag);
933+
}
934+
935+
/*
936+
* Call the @execute function on all incore inodes matching the radix tree
937+
* @tag.
938+
*/
939+
int
940+
xfs_inode_ag_iterator(
941+
struct xfs_mount *mp,
942+
int iter_flags,
943+
int (*execute)(struct xfs_inode *ip, void *args),
944+
void *args,
945+
int tag)
946+
{
947+
struct xfs_perag *pag;
948+
int error = 0;
949+
int last_error = 0;
950+
xfs_agnumber_t ag;
951+
952+
ag = 0;
953+
while ((pag = xfs_inode_walk_get_perag(mp, ag, tag))) {
954+
ag = pag->pag_agno + 1;
955+
error = xfs_inode_ag_walk(mp, pag, execute, args, tag,
956+
iter_flags);
957+
xfs_perag_put(pag);
958+
if (error) {
959+
last_error = error;
960+
if (error == -EFSCORRUPTED)
961+
break;
962+
}
963+
}
964+
return last_error;
965+
}
966+
919967
/*
920968
* Background scanning to trim post-EOF preallocated space. This is queued
921969
* based on the 'speculative_prealloc_lifetime' tunable (5m by default).
@@ -979,46 +1027,6 @@ xfs_cowblocks_worker(
9791027
xfs_queue_cowblocks(mp);
9801028
}
9811029

982-
/* Fetch the next (possibly tagged) per-AG structure. */
983-
static inline struct xfs_perag *
984-
xfs_inode_walk_get_perag(
985-
struct xfs_mount *mp,
986-
xfs_agnumber_t agno,
987-
int tag)
988-
{
989-
if (tag == XFS_ICI_NO_TAG)
990-
return xfs_perag_get(mp, agno);
991-
return xfs_perag_get_tag(mp, agno, tag);
992-
}
993-
994-
int
995-
xfs_inode_ag_iterator(
996-
struct xfs_mount *mp,
997-
int iter_flags,
998-
int (*execute)(struct xfs_inode *ip, void *args),
999-
void *args,
1000-
int tag)
1001-
{
1002-
struct xfs_perag *pag;
1003-
int error = 0;
1004-
int last_error = 0;
1005-
xfs_agnumber_t ag;
1006-
1007-
ag = 0;
1008-
while ((pag = xfs_inode_walk_get_perag(mp, ag, tag))) {
1009-
ag = pag->pag_agno + 1;
1010-
error = xfs_inode_ag_walk(mp, pag, execute, args, tag,
1011-
iter_flags);
1012-
xfs_perag_put(pag);
1013-
if (error) {
1014-
last_error = error;
1015-
if (error == -EFSCORRUPTED)
1016-
break;
1017-
}
1018-
}
1019-
return last_error;
1020-
}
1021-
10221030
/*
10231031
* Grab the inode for reclaim exclusively.
10241032
* Return 0 if we grabbed it, non-zero otherwise.

0 commit comments

Comments
 (0)