Lines Matching refs:ce

108 static inline bool cache_entry_expired(const struct cache_entry *ce)  in cache_entry_expired()  argument
113 return timespec64_compare(&ts, &ce->etime) >= 0; in cache_entry_expired()
116 static inline void free_tgts(struct cache_entry *ce) in free_tgts() argument
120 list_for_each_entry_safe(t, n, &ce->tlist, list) { in free_tgts()
127 static inline void flush_cache_ent(struct cache_entry *ce) in flush_cache_ent() argument
129 hlist_del_init(&ce->hlist); in flush_cache_ent()
130 kfree(ce->path); in flush_cache_ent()
131 free_tgts(ce); in flush_cache_ent()
133 kmem_cache_free(cache_slab, ce); in flush_cache_ent()
143 struct cache_entry *ce; in flush_cache_ents() local
145 hlist_for_each_entry_safe(ce, n, l, hlist) { in flush_cache_ents()
146 if (!hlist_unhashed(&ce->hlist)) in flush_cache_ents()
147 flush_cache_ent(ce); in flush_cache_ents()
158 struct cache_entry *ce; in dfscache_proc_show() local
167 hlist_for_each_entry(ce, l, hlist) { in dfscache_proc_show()
168 if (hlist_unhashed(&ce->hlist)) in dfscache_proc_show()
173 ce->path, ce->srvtype == DFS_TYPE_ROOT ? "root" : "link", in dfscache_proc_show()
174 ce->ttl, ce->etime.tv_nsec, ce->hdr_flags, ce->ref_flags, in dfscache_proc_show()
175 DFS_INTERLINK(ce->hdr_flags) ? "yes" : "no", in dfscache_proc_show()
176 ce->path_consumed, cache_entry_expired(ce) ? "yes" : "no"); in dfscache_proc_show()
178 list_for_each_entry(t, &ce->tlist, list) { in dfscache_proc_show()
181 READ_ONCE(ce->tgthint) == t ? " (target hint)" : ""); in dfscache_proc_show()
226 static inline void dump_tgts(const struct cache_entry *ce) in dump_tgts() argument
231 list_for_each_entry(t, &ce->tlist, list) { in dump_tgts()
233 READ_ONCE(ce->tgthint) == t ? " (target hint)" : ""); in dump_tgts()
237 static inline void dump_ce(const struct cache_entry *ce) in dump_ce() argument
240 ce->path, in dump_ce()
241 ce->srvtype == DFS_TYPE_ROOT ? "root" : "link", ce->ttl, in dump_ce()
242 ce->etime.tv_nsec, in dump_ce()
243 ce->hdr_flags, ce->ref_flags, in dump_ce()
244 DFS_INTERLINK(ce->hdr_flags) ? "yes" : "no", in dump_ce()
245 ce->path_consumed, in dump_ce()
246 cache_entry_expired(ce) ? "yes" : "no"); in dump_ce()
247 dump_tgts(ce); in dump_ce()
340 static inline char *get_tgt_name(const struct cache_entry *ce) in get_tgt_name() argument
342 struct cache_dfs_tgt *t = READ_ONCE(ce->tgthint); in get_tgt_name()
383 struct cache_entry *ce, const char *tgthint) in copy_ref_data() argument
388 ce->ttl = max_t(int, refs[0].ttl, CACHE_MIN_TTL); in copy_ref_data()
389 ce->etime = get_expire_time(ce->ttl); in copy_ref_data()
390 ce->srvtype = refs[0].server_type; in copy_ref_data()
391 ce->hdr_flags = refs[0].flags; in copy_ref_data()
392 ce->ref_flags = refs[0].ref_flag; in copy_ref_data()
393 ce->path_consumed = refs[0].path_consumed; in copy_ref_data()
400 free_tgts(ce); in copy_ref_data()
404 list_add(&t->list, &ce->tlist); in copy_ref_data()
407 list_add_tail(&t->list, &ce->tlist); in copy_ref_data()
409 ce->numtgts++; in copy_ref_data()
412 target = list_first_entry_or_null(&ce->tlist, struct cache_dfs_tgt, in copy_ref_data()
414 WRITE_ONCE(ce->tgthint, target); in copy_ref_data()
422 struct cache_entry *ce; in alloc_cache_entry() local
425 ce = kmem_cache_zalloc(cache_slab, GFP_KERNEL); in alloc_cache_entry()
426 if (!ce) in alloc_cache_entry()
429 ce->path = refs[0].path_name; in alloc_cache_entry()
432 INIT_HLIST_NODE(&ce->hlist); in alloc_cache_entry()
433 INIT_LIST_HEAD(&ce->tlist); in alloc_cache_entry()
435 rc = copy_ref_data(refs, numrefs, ce, NULL); in alloc_cache_entry()
437 kfree(ce->path); in alloc_cache_entry()
438 kmem_cache_free(cache_slab, ce); in alloc_cache_entry()
439 ce = ERR_PTR(rc); in alloc_cache_entry()
441 return ce; in alloc_cache_entry()
447 struct cache_entry *ce; in remove_oldest_entry_locked() local
455 hlist_for_each_entry(ce, l, hlist) { in remove_oldest_entry_locked()
456 if (hlist_unhashed(&ce->hlist)) in remove_oldest_entry_locked()
458 if (!to_del || timespec64_compare(&ce->etime, in remove_oldest_entry_locked()
460 to_del = ce; in remove_oldest_entry_locked()
479 struct cache_entry *ce; in add_cache_entry_locked() local
494 ce = alloc_cache_entry(refs, numrefs); in add_cache_entry_locked()
495 if (IS_ERR(ce)) in add_cache_entry_locked()
496 return ce; in add_cache_entry_locked()
498 ttl = min_t(int, atomic_read(&dfs_cache_ttl), ce->ttl); in add_cache_entry_locked()
501 hlist_add_head(&ce->hlist, &cache_htable[hash]); in add_cache_entry_locked()
502 dump_ce(ce); in add_cache_entry_locked()
506 return ce; in add_cache_entry_locked()
537 struct cache_entry *ce; in __lookup_cache_entry() local
539 hlist_for_each_entry(ce, &cache_htable[hash], hlist) { in __lookup_cache_entry()
540 if (dfs_path_equal(ce->path, strlen(ce->path), path, len)) { in __lookup_cache_entry()
541 dump_ce(ce); in __lookup_cache_entry()
542 return ce; in __lookup_cache_entry()
559 struct cache_entry *ce; in lookup_cache_entry() local
595 ce = __lookup_cache_entry(path, hash, len); in lookup_cache_entry()
596 if (!IS_ERR(ce)) in lookup_cache_entry()
597 return ce; in lookup_cache_entry()
620 static int update_cache_entry_locked(struct cache_entry *ce, const struct dfs_info3_param *refs, in update_cache_entry_locked() argument
629 target = READ_ONCE(ce->tgthint); in update_cache_entry_locked()
636 free_tgts(ce); in update_cache_entry_locked()
637 ce->numtgts = 0; in update_cache_entry_locked()
639 rc = copy_ref_data(refs, numrefs, ce, th); in update_cache_entry_locked()
689 struct cache_entry *ce; in cache_refresh_path() local
697 ce = lookup_cache_entry(path); in cache_refresh_path()
698 if (!IS_ERR(ce)) { in cache_refresh_path()
699 if (!force_refresh && !cache_entry_expired(ce)) in cache_refresh_path()
700 return ce; in cache_refresh_path()
701 } else if (PTR_ERR(ce) != -ENOENT) { in cache_refresh_path()
703 return ce; in cache_refresh_path()
721 ce = ERR_PTR(rc); in cache_refresh_path()
729 ce = lookup_cache_entry(path); in cache_refresh_path()
730 if (!IS_ERR(ce)) { in cache_refresh_path()
731 if (force_refresh || cache_entry_expired(ce)) { in cache_refresh_path()
732 rc = update_cache_entry_locked(ce, refs, numrefs); in cache_refresh_path()
734 ce = ERR_PTR(rc); in cache_refresh_path()
736 } else if (PTR_ERR(ce) == -ENOENT) { in cache_refresh_path()
737 ce = add_cache_entry_locked(refs, numrefs); in cache_refresh_path()
740 if (IS_ERR(ce)) { in cache_refresh_path()
748 return ce; in cache_refresh_path()
756 static int setup_referral(const char *path, struct cache_entry *ce, in setup_referral() argument
775 ref->path_consumed = ce->path_consumed; in setup_referral()
776 ref->ttl = ce->ttl; in setup_referral()
777 ref->server_type = ce->srvtype; in setup_referral()
778 ref->ref_flag = ce->ref_flags; in setup_referral()
779 ref->flags = ce->hdr_flags; in setup_referral()
790 static int get_targets(struct cache_entry *ce, struct dfs_cache_tgt_list *tl) in get_targets() argument
800 list_for_each_entry(t, &ce->tlist, list) { in get_targets()
815 if (READ_ONCE(ce->tgthint) == t) in get_targets()
821 tl->tl_numtgts = ce->numtgts; in get_targets()
862 struct cache_entry *ce; in dfs_cache_find() local
868 ce = cache_refresh_path(xid, ses, npath, false); in dfs_cache_find()
869 if (IS_ERR(ce)) { in dfs_cache_find()
870 rc = PTR_ERR(ce); in dfs_cache_find()
875 rc = setup_referral(path, ce, ref, get_tgt_name(ce)); in dfs_cache_find()
879 rc = get_targets(ce, tgt_list); in dfs_cache_find()
908 struct cache_entry *ce; in dfs_cache_noreq_find() local
914 ce = lookup_cache_entry(path); in dfs_cache_noreq_find()
915 if (IS_ERR(ce)) { in dfs_cache_noreq_find()
916 rc = PTR_ERR(ce); in dfs_cache_noreq_find()
921 rc = setup_referral(path, ce, ref, get_tgt_name(ce)); in dfs_cache_noreq_find()
925 rc = get_targets(ce, tgt_list); in dfs_cache_noreq_find()
949 struct cache_entry *ce; in dfs_cache_noreq_update_tgthint() local
958 ce = lookup_cache_entry(path); in dfs_cache_noreq_update_tgthint()
959 if (IS_ERR(ce)) in dfs_cache_noreq_update_tgthint()
962 t = READ_ONCE(ce->tgthint); in dfs_cache_noreq_update_tgthint()
967 list_for_each_entry(t, &ce->tlist, list) { in dfs_cache_noreq_update_tgthint()
969 WRITE_ONCE(ce->tgthint, t); in dfs_cache_noreq_update_tgthint()
994 struct cache_entry *ce; in dfs_cache_get_tgt_referral() local
1003 ce = lookup_cache_entry(path); in dfs_cache_get_tgt_referral()
1004 if (IS_ERR(ce)) { in dfs_cache_get_tgt_referral()
1005 rc = PTR_ERR(ce); in dfs_cache_get_tgt_referral()
1011 rc = setup_referral(path, ce, ref, it->it_name); in dfs_cache_get_tgt_referral()
1182 struct cache_entry *ce; in __refresh_ses_referral() local
1200 ce = lookup_cache_entry(path); in __refresh_ses_referral()
1201 needs_refresh = force_refresh || IS_ERR(ce) || cache_entry_expired(ce); in __refresh_ses_referral()
1202 if (!IS_ERR(ce)) { in __refresh_ses_referral()
1203 rc = get_targets(ce, &old_tl); in __refresh_ses_referral()
1220 ce = cache_refresh_path(xid, ses, path, true); in __refresh_ses_referral()
1221 if (!IS_ERR(ce)) { in __refresh_ses_referral()
1222 rc = get_targets(ce, &new_tl); in __refresh_ses_referral()