From 28ea8c41af7627a10b0b2e5c850927646292da9e Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Fri, 30 Aug 2019 15:45:02 -0700 Subject: xfs: hide most of the incore inode walk interface Hide the incore inode walk interface because callers outside of the icache code don't need to know about iter_flags and radix tags and other implementation details of the incore inode cache. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_icache.c | 34 ++++++++++++++++++++++++---------- fs/xfs/xfs_icache.h | 9 ++++----- fs/xfs/xfs_qm_syscalls.c | 3 +-- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 32d1110585db..29baf6a59815 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -744,7 +744,7 @@ xfs_inode_ag_walk_grab( int flags) { struct inode *inode = VFS_I(ip); - bool newinos = !!(flags & XFS_AGITER_INEW_WAIT); + bool newinos = !!(flags & XFS_ICI_WALK_INEW_WAIT); ASSERT(rcu_read_lock_held()); @@ -788,10 +788,10 @@ out_unlock_noent: * inodes with the given radix tree @tag. */ STATIC int -xfs_inode_ag_walk( +xfs_ici_walk_ag( struct xfs_mount *mp, struct xfs_perag *pag, - int (*execute)(struct xfs_inode *ip, void *args), + xfs_ici_walk_fn execute, void *args, int tag, int iter_flags) @@ -864,7 +864,7 @@ restart: for (i = 0; i < nr_found; i++) { if (!batch[i]) continue; - if ((iter_flags & XFS_AGITER_INEW_WAIT) && + if ((iter_flags & XFS_ICI_WALK_INEW_WAIT) && xfs_iflags_test(batch[i], XFS_INEW)) xfs_inew_wait(batch[i]); error = execute(batch[i], args); @@ -908,11 +908,11 @@ xfs_ici_walk_get_perag( * Call the @execute function on all incore inodes matching the radix tree * @tag. */ -int -xfs_inode_ag_iterator( +STATIC int +xfs_ici_walk( struct xfs_mount *mp, int iter_flags, - int (*execute)(struct xfs_inode *ip, void *args), + xfs_ici_walk_fn execute, void *args, int tag) { @@ -924,7 +924,7 @@ xfs_inode_ag_iterator( ag = 0; while ((pag = xfs_ici_walk_get_perag(mp, ag, tag))) { ag = pag->pag_agno + 1; - error = xfs_inode_ag_walk(mp, pag, execute, args, tag, + error = xfs_ici_walk_ag(mp, pag, execute, args, tag, iter_flags); xfs_perag_put(pag); if (error) { @@ -936,6 +936,20 @@ xfs_inode_ag_iterator( return last_error; } +/* + * Walk all incore inodes in the filesystem. Knowledge of radix tree tags + * is hidden and we always wait for INEW inodes. + */ +int +xfs_ici_walk_all( + struct xfs_mount *mp, + xfs_ici_walk_fn execute, + void *args) +{ + return xfs_ici_walk(mp, XFS_ICI_WALK_INEW_WAIT, execute, args, + XFS_ICI_NO_TAG); +} + /* * Background scanning to trim post-EOF preallocated space. This is queued * based on the 'speculative_prealloc_lifetime' tunable (5m by default). @@ -1506,7 +1520,7 @@ xfs_icache_free_eofblocks( struct xfs_mount *mp, struct xfs_eofblocks *eofb) { - return xfs_inode_ag_iterator(mp, 0, xfs_inode_free_eofblocks, eofb, + return xfs_ici_walk(mp, 0, xfs_inode_free_eofblocks, eofb, XFS_ICI_EOFBLOCKS_TAG); } @@ -1756,7 +1770,7 @@ xfs_icache_free_cowblocks( struct xfs_mount *mp, struct xfs_eofblocks *eofb) { - return xfs_inode_ag_iterator(mp, 0, xfs_inode_free_cowblocks, eofb, + return xfs_ici_walk(mp, 0, xfs_inode_free_cowblocks, eofb, XFS_ICI_COWBLOCKS_TAG); } diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h index e7f86ebd7b22..bd9b74663dc8 100644 --- a/fs/xfs/xfs_icache.h +++ b/fs/xfs/xfs_icache.h @@ -38,9 +38,9 @@ struct xfs_eofblocks { #define XFS_IGET_INCORE 0x8 /* don't read from disk or reinit */ /* - * flags for AG inode iterator + * flags for incore inode iterator */ -#define XFS_AGITER_INEW_WAIT 0x1 /* wait on new inodes */ +#define XFS_ICI_WALK_INEW_WAIT 0x1 /* wait on new inodes */ int xfs_iget(struct xfs_mount *mp, struct xfs_trans *tp, xfs_ino_t ino, uint flags, uint lock_flags, xfs_inode_t **ipp); @@ -71,9 +71,8 @@ int xfs_inode_free_quota_cowblocks(struct xfs_inode *ip); void xfs_cowblocks_worker(struct work_struct *); void xfs_queue_cowblocks(struct xfs_mount *); -int xfs_inode_ag_iterator(struct xfs_mount *mp, int iter_flags, - int (*execute)(struct xfs_inode *ip, void *args), - void *args, int tag); +typedef int (*xfs_ici_walk_fn)(struct xfs_inode *ip, void *args); +int xfs_ici_walk_all(struct xfs_mount *mp, xfs_ici_walk_fn execute, void *args); int xfs_icache_inode_is_allocated(struct xfs_mount *mp, struct xfs_trans *tp, xfs_ino_t ino, bool *inuse); diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c index 438b8104e630..fcdcb029da4f 100644 --- a/fs/xfs/xfs_qm_syscalls.c +++ b/fs/xfs/xfs_qm_syscalls.c @@ -785,6 +785,5 @@ xfs_qm_dqrele_all_inodes( }; ASSERT(mp->m_quotainfo); - xfs_inode_ag_iterator(mp, XFS_AGITER_INEW_WAIT, xfs_dqrele_inode, &dqr, - XFS_ICI_NO_TAG); + xfs_ici_walk_all(mp, xfs_dqrele_inode, &dqr); } -- cgit v1.2.3