Skip to content

Commit 866cf1d

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
xfs: use xas_for_each_marked in xfs_reclaim_inodes_count
xfs_reclaim_inodes_count iterates over all AGs to sum up the reclaimable inodes counts. There is no point in grabbing a reference to the them or unlock the RCU critical section for each iteration, so switch to the more efficient xas_for_each_marked iterator. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent 32fa405 commit 866cf1d

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

fs/xfs/xfs_icache.c

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -300,32 +300,6 @@ xfs_perag_clear_inode_tag(
300300
trace_xfs_perag_clear_inode_tag(pag, _RET_IP_);
301301
}
302302

303-
/*
304-
* Find the next AG after @pag, or the first AG if @pag is NULL.
305-
*/
306-
static struct xfs_perag *
307-
xfs_perag_get_next_tag(
308-
struct xfs_mount *mp,
309-
struct xfs_perag *pag,
310-
unsigned int tag)
311-
{
312-
unsigned long index = 0;
313-
314-
if (pag) {
315-
index = pag->pag_agno + 1;
316-
xfs_perag_rele(pag);
317-
}
318-
319-
rcu_read_lock();
320-
pag = xa_find(&mp->m_perags, &index, ULONG_MAX, ici_tag_to_mark(tag));
321-
if (pag) {
322-
trace_xfs_perag_get_next_tag(pag, _RET_IP_);
323-
atomic_inc(&pag->pag_ref);
324-
}
325-
rcu_read_unlock();
326-
return pag;
327-
}
328-
329303
/*
330304
* Find the next AG after @pag, or the first AG if @pag is NULL.
331305
*/
@@ -1080,11 +1054,17 @@ long
10801054
xfs_reclaim_inodes_count(
10811055
struct xfs_mount *mp)
10821056
{
1083-
struct xfs_perag *pag = NULL;
1057+
XA_STATE (xas, &mp->m_perags, 0);
10841058
long reclaimable = 0;
1059+
struct xfs_perag *pag;
10851060

1086-
while ((pag = xfs_perag_get_next_tag(mp, pag, XFS_ICI_RECLAIM_TAG)))
1061+
rcu_read_lock();
1062+
xas_for_each_marked(&xas, pag, ULONG_MAX, XFS_PERAG_RECLAIM_MARK) {
1063+
trace_xfs_reclaim_inodes_count(pag, _THIS_IP_);
10871064
reclaimable += pag->pag_ici_reclaimable;
1065+
}
1066+
rcu_read_unlock();
1067+
10881068
return reclaimable;
10891069
}
10901070

fs/xfs/xfs_trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@ DEFINE_EVENT(xfs_perag_class, name, \
210210
TP_PROTO(struct xfs_perag *pag, unsigned long caller_ip), \
211211
TP_ARGS(pag, caller_ip))
212212
DEFINE_PERAG_REF_EVENT(xfs_perag_get);
213-
DEFINE_PERAG_REF_EVENT(xfs_perag_get_next_tag);
214213
DEFINE_PERAG_REF_EVENT(xfs_perag_hold);
215214
DEFINE_PERAG_REF_EVENT(xfs_perag_put);
216215
DEFINE_PERAG_REF_EVENT(xfs_perag_grab);
217216
DEFINE_PERAG_REF_EVENT(xfs_perag_grab_next_tag);
218217
DEFINE_PERAG_REF_EVENT(xfs_perag_rele);
219218
DEFINE_PERAG_REF_EVENT(xfs_perag_set_inode_tag);
220219
DEFINE_PERAG_REF_EVENT(xfs_perag_clear_inode_tag);
220+
DEFINE_PERAG_REF_EVENT(xfs_reclaim_inodes_count);
221221

222222
TRACE_EVENT(xfs_inodegc_worker,
223223
TP_PROTO(struct xfs_mount *mp, unsigned int shrinker_hits),

0 commit comments

Comments
 (0)