mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-28 16:56:26 +00:00
xfs: factor out a xfs_iwalk_args helper
Add a helper to share more code between xfs_iwalk and xfs_inobt_walk, and at the same time do away with the extra flags indirect so that everyone use the same names for the same flags when using the common iwalk code. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
This commit is contained in:
parent
d66496578b
commit
0a4d79741d
@ -534,6 +534,35 @@ xfs_iwalk_prefetch(
|
||||
return max(inobt_records, 2U);
|
||||
}
|
||||
|
||||
static int
|
||||
xfs_iwalk_args(
|
||||
struct xfs_iwalk_ag *iwag,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct xfs_mount *mp = iwag->mp;
|
||||
xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, iwag->startino);
|
||||
int error;
|
||||
|
||||
ASSERT(agno < mp->m_sb.sb_agcount);
|
||||
ASSERT(!(flags & ~XFS_IWALK_FLAGS_ALL));
|
||||
|
||||
error = xfs_iwalk_alloc(iwag);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
for_each_perag_from(mp, agno, iwag->pag) {
|
||||
error = xfs_iwalk_ag(iwag);
|
||||
if (error || (flags & XFS_IWALK_SAME_AG)) {
|
||||
xfs_perag_rele(iwag->pag);
|
||||
break;
|
||||
}
|
||||
iwag->startino = XFS_AGINO_TO_INO(mp, agno + 1, 0);
|
||||
}
|
||||
|
||||
xfs_iwalk_free(iwag);
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Walk all inodes in the filesystem starting from @startino. The @iwalk_fn
|
||||
* will be called for each allocated inode, being passed the inode's number and
|
||||
@ -562,32 +591,8 @@ xfs_iwalk(
|
||||
.pwork = XFS_PWORK_SINGLE_THREADED,
|
||||
.lastino = NULLFSINO,
|
||||
};
|
||||
struct xfs_perag *pag;
|
||||
xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, startino);
|
||||
int error;
|
||||
|
||||
ASSERT(agno < mp->m_sb.sb_agcount);
|
||||
ASSERT(!(flags & ~XFS_IWALK_FLAGS_ALL));
|
||||
|
||||
error = xfs_iwalk_alloc(&iwag);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
for_each_perag_from(mp, agno, pag) {
|
||||
iwag.pag = pag;
|
||||
error = xfs_iwalk_ag(&iwag);
|
||||
if (error)
|
||||
break;
|
||||
iwag.startino = XFS_AGINO_TO_INO(mp, agno + 1, 0);
|
||||
if (flags & XFS_INOBT_WALK_SAME_AG)
|
||||
break;
|
||||
iwag.pag = NULL;
|
||||
}
|
||||
|
||||
if (iwag.pag)
|
||||
xfs_perag_rele(pag);
|
||||
xfs_iwalk_free(&iwag);
|
||||
return error;
|
||||
return xfs_iwalk_args(&iwag, flags);
|
||||
}
|
||||
|
||||
/* Run per-thread iwalk work. */
|
||||
@ -673,7 +678,7 @@ xfs_iwalk_threaded(
|
||||
iwag->lastino = NULLFSINO;
|
||||
xfs_pwork_queue(&pctl, &iwag->pwork);
|
||||
startino = XFS_AGINO_TO_INO(mp, pag->pag_agno + 1, 0);
|
||||
if (flags & XFS_INOBT_WALK_SAME_AG)
|
||||
if (flags & XFS_IWALK_SAME_AG)
|
||||
break;
|
||||
}
|
||||
if (pag)
|
||||
@ -747,30 +752,6 @@ xfs_inobt_walk(
|
||||
.pwork = XFS_PWORK_SINGLE_THREADED,
|
||||
.lastino = NULLFSINO,
|
||||
};
|
||||
struct xfs_perag *pag;
|
||||
xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, startino);
|
||||
int error;
|
||||
|
||||
ASSERT(agno < mp->m_sb.sb_agcount);
|
||||
ASSERT(!(flags & ~XFS_INOBT_WALK_FLAGS_ALL));
|
||||
|
||||
error = xfs_iwalk_alloc(&iwag);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
for_each_perag_from(mp, agno, pag) {
|
||||
iwag.pag = pag;
|
||||
error = xfs_iwalk_ag(&iwag);
|
||||
if (error)
|
||||
break;
|
||||
iwag.startino = XFS_AGINO_TO_INO(mp, pag->pag_agno + 1, 0);
|
||||
if (flags & XFS_INOBT_WALK_SAME_AG)
|
||||
break;
|
||||
iwag.pag = NULL;
|
||||
}
|
||||
|
||||
if (iwag.pag)
|
||||
xfs_perag_rele(pag);
|
||||
xfs_iwalk_free(&iwag);
|
||||
return error;
|
||||
return xfs_iwalk_args(&iwag, flags);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ int xfs_iwalk_threaded(struct xfs_mount *mp, xfs_ino_t startino,
|
||||
unsigned int flags, xfs_iwalk_fn iwalk_fn,
|
||||
unsigned int inode_records, bool poll, void *data);
|
||||
|
||||
/* Only iterate inodes within the same AG as @startino. */
|
||||
/* Only iterate within the same AG as @startino. */
|
||||
#define XFS_IWALK_SAME_AG (1U << 0)
|
||||
|
||||
#define XFS_IWALK_FLAGS_ALL (XFS_IWALK_SAME_AG)
|
||||
@ -41,9 +41,4 @@ int xfs_inobt_walk(struct xfs_mount *mp, struct xfs_trans *tp,
|
||||
xfs_inobt_walk_fn inobt_walk_fn, unsigned int inobt_records,
|
||||
void *data);
|
||||
|
||||
/* Only iterate inobt records within the same AG as @startino. */
|
||||
#define XFS_INOBT_WALK_SAME_AG (XFS_IWALK_SAME_AG)
|
||||
|
||||
#define XFS_INOBT_WALK_FLAGS_ALL (XFS_INOBT_WALK_SAME_AG)
|
||||
|
||||
#endif /* __XFS_IWALK_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user