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

Function cache_neg_evict

freebsd/kern/vfs_cache.c:1341–1406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1339}
1340
1341static bool
1342cache_neg_evict(void)
1343{
1344 struct namecache *ncp, *ncp2;
1345 struct neglist *nl;
1346 struct vnode *dvp;
1347 struct mtx *dvlp;
1348 struct mtx *blp;
1349 uint32_t hash;
1350 u_char nlen;
1351 bool evicted;
1352
1353 nl = cache_neg_evict_select_list();
1354 if (nl == NULL) {
1355 return (false);
1356 }
1357
1358 mtx_lock(&nl->nl_lock);
1359 ncp = TAILQ_FIRST(&nl->nl_hotlist);
1360 if (ncp != NULL) {
1361 cache_neg_demote_locked(ncp);
1362 }
1363 ncp = cache_neg_evict_select_entry(nl);
1364 if (ncp == NULL) {
1365 counter_u64_add(neg_evict_skipped_empty, 1);
1366 mtx_unlock(&nl->nl_lock);
1367 mtx_unlock(&nl->nl_evict_lock);
1368 return (false);
1369 }
1370 nlen = ncp->nc_nlen;
1371 dvp = ncp->nc_dvp;
1372 hash = cache_get_hash(ncp->nc_name, nlen, dvp);
1373 dvlp = VP2VNODELOCK(dvp);
1374 blp = HASH2BUCKETLOCK(hash);
1375 mtx_unlock(&nl->nl_lock);
1376 mtx_unlock(&nl->nl_evict_lock);
1377 mtx_lock(dvlp);
1378 mtx_lock(blp);
1379 /*
1380 * Note that since all locks were dropped above, the entry may be
1381 * gone or reallocated to be something else.
1382 */
1383 CK_SLIST_FOREACH(ncp2, (NCHHASH(hash)), nc_hash) {
1384 if (ncp2 == ncp && ncp2->nc_dvp == dvp &&
1385 ncp2->nc_nlen == nlen && (ncp2->nc_flag & NCF_NEGATIVE) != 0)
1386 break;
1387 }
1388 if (ncp2 == NULL) {
1389 counter_u64_add(neg_evict_skipped_missed, 1);
1390 ncp = NULL;
1391 evicted = false;
1392 } else {
1393 MPASS(dvlp == VP2VNODELOCK(ncp->nc_dvp));
1394 MPASS(blp == NCP2BUCKETLOCK(ncp));
1395 SDT_PROBE2(vfs, namecache, evict_negative, done, ncp->nc_dvp,
1396 ncp->nc_name);
1397 cache_zap_locked(ncp);
1398 counter_u64_add(neg_evicted, 1);

Callers 1

cache_neg_evict_condFunction · 0.85

Calls 11

cache_neg_demote_lockedFunction · 0.85
cache_get_hashFunction · 0.85
VP2VNODELOCKFunction · 0.85
NCP2BUCKETLOCKFunction · 0.85
cache_zap_lockedFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70
cache_freeFunction · 0.70
counter_u64_addFunction · 0.50

Tested by

no test coverage detected