MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vnlru_free_impl

Function vnlru_free_impl

freebsd/kern/vfs_subr.c:1218–1268  ·  view source on GitHub ↗

* Attempt to reduce the free list by the requested amount. */

Source from the content-addressed store, hash-verified

1216 * Attempt to reduce the free list by the requested amount.
1217 */
1218static int
1219vnlru_free_impl(int count, struct vfsops *mnt_op, struct vnode *mvp)
1220{
1221 struct vnode *vp;
1222 struct mount *mp;
1223 int ocount;
1224
1225 mtx_assert(&vnode_list_mtx, MA_OWNED);
1226 if (count > max_vnlru_free)
1227 count = max_vnlru_free;
1228 ocount = count;
1229 vp = mvp;
1230 for (;;) {
1231 if (count == 0) {
1232 break;
1233 }
1234 vp = TAILQ_NEXT(vp, v_vnodelist);
1235 if (__predict_false(vp == NULL)) {
1236 TAILQ_REMOVE(&vnode_list, mvp, v_vnodelist);
1237 TAILQ_INSERT_TAIL(&vnode_list, mvp, v_vnodelist);
1238 break;
1239 }
1240 if (__predict_false(vp->v_type == VMARKER))
1241 continue;
1242 if (vp->v_holdcnt > 0)
1243 continue;
1244 /*
1245 * Don't recycle if our vnode is from different type
1246 * of mount point. Note that mp is type-safe, the
1247 * check does not reach unmapped address even if
1248 * vnode is reclaimed.
1249 */
1250 if (mnt_op != NULL && (mp = vp->v_mount) != NULL &&
1251 mp->mnt_op != mnt_op) {
1252 continue;
1253 }
1254 if (__predict_false(vp->v_type == VBAD || vp->v_type == VNON)) {
1255 continue;
1256 }
1257 if (!vhold_recycle_free(vp))
1258 continue;
1259 TAILQ_REMOVE(&vnode_list, mvp, v_vnodelist);
1260 TAILQ_INSERT_AFTER(&vnode_list, vp, mvp, v_vnodelist);
1261 mtx_unlock(&vnode_list_mtx);
1262 if (vtryrecycle(vp) == 0)
1263 count--;
1264 mtx_lock(&vnode_list_mtx);
1265 vp = mvp;
1266 }
1267 return (ocount - count);
1268}
1269
1270static int
1271vnlru_free_locked(int count)

Callers 3

vnlru_free_lockedFunction · 0.85
vnlru_free_vfsopsFunction · 0.85
vnlru_freeFunction · 0.85

Calls 5

mtx_assertFunction · 0.85
vhold_recycle_freeFunction · 0.85
vtryrecycleFunction · 0.85
mtx_unlockFunction · 0.70
mtx_lockFunction · 0.70

Tested by

no test coverage detected