cache: count vnodes in cache_purgevfs

This commit is contained in:
Mateusz Guzik 2021-09-18 10:30:15 +02:00
parent 5d8e32a66c
commit a2cb65b8fe

View File

@ -237,7 +237,7 @@ SDT_PROBE_DEFINE2(vfs, namecache, removecnp, hit, "struct vnode *",
"struct componentname *"); "struct componentname *");
SDT_PROBE_DEFINE2(vfs, namecache, removecnp, miss, "struct vnode *", SDT_PROBE_DEFINE2(vfs, namecache, removecnp, miss, "struct vnode *",
"struct componentname *"); "struct componentname *");
SDT_PROBE_DEFINE1(vfs, namecache, purge, done, "struct vnode *"); SDT_PROBE_DEFINE3(vfs, namecache, purge, done, "struct vnode *", "size_t", "size_t");
SDT_PROBE_DEFINE1(vfs, namecache, purge, batch, "int"); SDT_PROBE_DEFINE1(vfs, namecache, purge, batch, "int");
SDT_PROBE_DEFINE1(vfs, namecache, purge_negative, done, "struct vnode *"); SDT_PROBE_DEFINE1(vfs, namecache, purge_negative, done, "struct vnode *");
SDT_PROBE_DEFINE1(vfs, namecache, purgevfs, done, "struct mount *"); SDT_PROBE_DEFINE1(vfs, namecache, purgevfs, done, "struct mount *");
@ -3012,13 +3012,15 @@ void
cache_purgevfs(struct mount *mp) cache_purgevfs(struct mount *mp)
{ {
struct vnode *vp, *mvp; struct vnode *vp, *mvp;
size_t visited, purged;
SDT_PROBE1(vfs, namecache, purgevfs, done, mp); visited = purged = 0;
/* /*
* Somewhat wasteful iteration over all vnodes. Would be better to * Somewhat wasteful iteration over all vnodes. Would be better to
* support filtering and avoid the interlock to begin with. * support filtering and avoid the interlock to begin with.
*/ */
MNT_VNODE_FOREACH_ALL(vp, mp, mvp) { MNT_VNODE_FOREACH_ALL(vp, mp, mvp) {
visited++;
if (!cache_has_entries(vp)) { if (!cache_has_entries(vp)) {
VI_UNLOCK(vp); VI_UNLOCK(vp);
continue; continue;
@ -3026,8 +3028,11 @@ cache_purgevfs(struct mount *mp)
vholdl(vp); vholdl(vp);
VI_UNLOCK(vp); VI_UNLOCK(vp);
cache_purge(vp); cache_purge(vp);
purged++;
vdrop(vp); vdrop(vp);
} }
SDT_PROBE3(vfs, namecache, purgevfs, done, mp, visited, purged);
} }
/* /*