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

Function cache_enter_time

freebsd/kern/vfs_cache.c:2280–2479  ·  view source on GitHub ↗

* Add an entry to the cache. */

Source from the content-addressed store, hash-verified

2278 * Add an entry to the cache.
2279 */
2280void
2281cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp,
2282 struct timespec *tsp, struct timespec *dtsp)
2283{
2284 struct celockstate cel;
2285 struct namecache *ncp, *n2, *ndd;
2286 struct namecache_ts *ncp_ts;
2287 struct nchashhead *ncpp;
2288 uint32_t hash;
2289 int flag;
2290 int len;
2291
2292 KASSERT(cnp->cn_namelen <= NAME_MAX,
2293 ("%s: passed len %ld exceeds NAME_MAX (%d)", __func__, cnp->cn_namelen,
2294 NAME_MAX));
2295 VNPASS(dvp != vp, dvp);
2296 VNPASS(!VN_IS_DOOMED(dvp), dvp);
2297 VNPASS(dvp->v_type != VNON, dvp);
2298 if (vp != NULL) {
2299 VNPASS(!VN_IS_DOOMED(vp), vp);
2300 VNPASS(vp->v_type != VNON, vp);
2301 }
2302
2303#ifdef DEBUG_CACHE
2304 if (__predict_false(!doingcache))
2305 return;
2306#endif
2307
2308 flag = 0;
2309 if (__predict_false(cnp->cn_nameptr[0] == '.')) {
2310 if (cnp->cn_namelen == 1)
2311 return;
2312 if (cnp->cn_namelen == 2 && cnp->cn_nameptr[1] == '.') {
2313 cache_enter_dotdot_prep(dvp, vp, cnp);
2314 flag = NCF_ISDOTDOT;
2315 }
2316 }
2317
2318 ncp = cache_alloc(cnp->cn_namelen, tsp != NULL);
2319 if (ncp == NULL)
2320 return;
2321
2322 cache_celockstate_init(&cel);
2323 ndd = NULL;
2324 ncp_ts = NULL;
2325
2326 /*
2327 * Calculate the hash key and setup as much of the new
2328 * namecache entry as possible before acquiring the lock.
2329 */
2330 ncp->nc_flag = flag | NCF_WIP;
2331 ncp->nc_vp = vp;
2332 if (vp == NULL)
2333 cache_neg_init(ncp);
2334 ncp->nc_dvp = dvp;
2335 if (tsp != NULL) {
2336 ncp_ts = __containerof(ncp, struct namecache_ts, nc_nc);
2337 ncp_ts->nc_time = *tsp;

Callers

nothing calls this directly

Calls 13

cache_enter_dotdot_prepFunction · 0.85
cache_celockstate_initFunction · 0.85
cache_neg_initFunction · 0.85
cache_get_hashFunction · 0.85
cache_enter_lockFunction · 0.85
cache_zap_lockedFunction · 0.85
cache_hold_vnodeFunction · 0.85
cache_neg_insertFunction · 0.85
cache_enter_unlockFunction · 0.85
cache_allocFunction · 0.70
cache_freeFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected