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 cifs_dbg(FYI, "%s: %s\n", __func__, ce->path); in flush_cache_ent()
130 hlist_del_init(&ce->hlist); in flush_cache_ent()
131 kfree(ce->path); in flush_cache_ent()
132 free_tgts(ce); in flush_cache_ent()
134 kmem_cache_free(cache_slab, ce); in flush_cache_ent()
144 struct cache_entry *ce; in flush_cache_ents() local
146 hlist_for_each_entry_safe(ce, n, l, hlist) { in flush_cache_ents()
147 if (!hlist_unhashed(&ce->hlist)) in flush_cache_ents()
148 flush_cache_ent(ce); in flush_cache_ents()
159 struct cache_entry *ce; in dfscache_proc_show() local
168 hlist_for_each_entry(ce, l, hlist) { in dfscache_proc_show()
169 if (hlist_unhashed(&ce->hlist)) in dfscache_proc_show()
174 ce->path, ce->srvtype == DFS_TYPE_ROOT ? "root" : "link", in dfscache_proc_show()
175 ce->ttl, ce->etime.tv_nsec, ce->hdr_flags, ce->ref_flags, in dfscache_proc_show()
176 DFS_INTERLINK(ce->hdr_flags) ? "yes" : "no", in dfscache_proc_show()
177 ce->path_consumed, cache_entry_expired(ce) ? "yes" : "no"); in dfscache_proc_show()
179 list_for_each_entry(t, &ce->tlist, list) { in dfscache_proc_show()
182 READ_ONCE(ce->tgthint) == t ? " (target hint)" : ""); in dfscache_proc_show()
227 static inline void dump_tgts(const struct cache_entry *ce) in dump_tgts() argument
232 list_for_each_entry(t, &ce->tlist, list) { in dump_tgts()
234 READ_ONCE(ce->tgthint) == t ? " (target hint)" : ""); in dump_tgts()
238 static inline void dump_ce(const struct cache_entry *ce) in dump_ce() argument
241 ce->path, in dump_ce()
242 ce->srvtype == DFS_TYPE_ROOT ? "root" : "link", ce->ttl, in dump_ce()
243 ce->etime.tv_nsec, in dump_ce()
244 ce->hdr_flags, ce->ref_flags, in dump_ce()
245 DFS_INTERLINK(ce->hdr_flags) ? "yes" : "no", in dump_ce()
246 ce->path_consumed, in dump_ce()
247 cache_entry_expired(ce) ? "yes" : "no"); in dump_ce()
248 dump_tgts(ce); in dump_ce()
341 static inline char *get_tgt_name(const struct cache_entry *ce) in get_tgt_name() argument
343 struct cache_dfs_tgt *t = READ_ONCE(ce->tgthint); in get_tgt_name()
384 struct cache_entry *ce, const char *tgthint) in copy_ref_data() argument
389 ce->ttl = max_t(int, refs[0].ttl, CACHE_MIN_TTL); in copy_ref_data()
390 ce->etime = get_expire_time(ce->ttl); in copy_ref_data()
391 ce->srvtype = refs[0].server_type; in copy_ref_data()
392 ce->hdr_flags = refs[0].flags; in copy_ref_data()
393 ce->ref_flags = refs[0].ref_flag; in copy_ref_data()
394 ce->path_consumed = refs[0].path_consumed; in copy_ref_data()
401 free_tgts(ce); in copy_ref_data()
405 list_add(&t->list, &ce->tlist); in copy_ref_data()
408 list_add_tail(&t->list, &ce->tlist); in copy_ref_data()
410 ce->numtgts++; in copy_ref_data()
413 target = list_first_entry_or_null(&ce->tlist, struct cache_dfs_tgt, in copy_ref_data()
415 WRITE_ONCE(ce->tgthint, target); in copy_ref_data()
423 struct cache_entry *ce; in alloc_cache_entry() local
426 ce = kmem_cache_zalloc(cache_slab, GFP_KERNEL); in alloc_cache_entry()
427 if (!ce) in alloc_cache_entry()
430 ce->path = refs[0].path_name; in alloc_cache_entry()
433 INIT_HLIST_NODE(&ce->hlist); in alloc_cache_entry()
434 INIT_LIST_HEAD(&ce->tlist); in alloc_cache_entry()
436 rc = copy_ref_data(refs, numrefs, ce, NULL); in alloc_cache_entry()
438 kfree(ce->path); in alloc_cache_entry()
439 kmem_cache_free(cache_slab, ce); in alloc_cache_entry()
440 ce = ERR_PTR(rc); in alloc_cache_entry()
442 return ce; in alloc_cache_entry()
449 struct cache_entry *ce; in purge_cache() local
456 hlist_for_each_entry_safe(ce, n, l, hlist) { in purge_cache()
457 if (hlist_unhashed(&ce->hlist)) in purge_cache()
459 if (ce->numtgts == 1) in purge_cache()
460 flush_cache_ent(ce); in purge_cache()
462 timespec64_compare(&ce->etime, in purge_cache()
464 oldest = ce; in purge_cache()
477 struct cache_entry *ce; in add_cache_entry_locked() local
492 ce = alloc_cache_entry(refs, numrefs); in add_cache_entry_locked()
493 if (IS_ERR(ce)) in add_cache_entry_locked()
494 return ce; in add_cache_entry_locked()
496 ttl = min_t(int, atomic_read(&dfs_cache_ttl), ce->ttl); in add_cache_entry_locked()
499 hlist_add_head(&ce->hlist, &cache_htable[hash]); in add_cache_entry_locked()
500 dump_ce(ce); in add_cache_entry_locked()
504 return ce; in add_cache_entry_locked()
535 struct cache_entry *ce; in __lookup_cache_entry() local
537 hlist_for_each_entry(ce, &cache_htable[hash], hlist) { in __lookup_cache_entry()
538 if (dfs_path_equal(ce->path, strlen(ce->path), path, len)) { in __lookup_cache_entry()
539 dump_ce(ce); in __lookup_cache_entry()
540 return ce; in __lookup_cache_entry()
557 struct cache_entry *ce; in lookup_cache_entry() local
593 ce = __lookup_cache_entry(path, hash, len); in lookup_cache_entry()
594 if (!IS_ERR(ce)) in lookup_cache_entry()
595 return ce; in lookup_cache_entry()
618 static int update_cache_entry_locked(struct cache_entry *ce, const struct dfs_info3_param *refs, in update_cache_entry_locked() argument
627 target = READ_ONCE(ce->tgthint); in update_cache_entry_locked()
634 free_tgts(ce); in update_cache_entry_locked()
635 ce->numtgts = 0; in update_cache_entry_locked()
637 rc = copy_ref_data(refs, numrefs, ce, th); in update_cache_entry_locked()
687 struct cache_entry *ce; in cache_refresh_path() local
695 ce = lookup_cache_entry(path); in cache_refresh_path()
696 if (!IS_ERR(ce)) { in cache_refresh_path()
697 if (!force_refresh && !cache_entry_expired(ce)) in cache_refresh_path()
698 return ce; in cache_refresh_path()
699 } else if (PTR_ERR(ce) != -ENOENT) { in cache_refresh_path()
701 return ce; in cache_refresh_path()
719 ce = ERR_PTR(rc); in cache_refresh_path()
727 ce = lookup_cache_entry(path); in cache_refresh_path()
728 if (!IS_ERR(ce)) { in cache_refresh_path()
729 if (force_refresh || cache_entry_expired(ce)) { in cache_refresh_path()
730 rc = update_cache_entry_locked(ce, refs, numrefs); in cache_refresh_path()
732 ce = ERR_PTR(rc); in cache_refresh_path()
734 } else if (PTR_ERR(ce) == -ENOENT) { in cache_refresh_path()
735 ce = add_cache_entry_locked(refs, numrefs); in cache_refresh_path()
738 if (IS_ERR(ce)) { in cache_refresh_path()
746 return ce; in cache_refresh_path()
754 static int setup_referral(const char *path, struct cache_entry *ce, in setup_referral() argument
773 ref->path_consumed = ce->path_consumed; in setup_referral()
774 ref->ttl = ce->ttl; in setup_referral()
775 ref->server_type = ce->srvtype; in setup_referral()
776 ref->ref_flag = ce->ref_flags; in setup_referral()
777 ref->flags = ce->hdr_flags; in setup_referral()
788 static int get_targets(struct cache_entry *ce, struct dfs_cache_tgt_list *tl) in get_targets() argument
798 list_for_each_entry(t, &ce->tlist, list) { in get_targets()
813 if (READ_ONCE(ce->tgthint) == t) in get_targets()
819 tl->tl_numtgts = ce->numtgts; in get_targets()
860 struct cache_entry *ce; in dfs_cache_find() local
866 ce = cache_refresh_path(xid, ses, npath, false); in dfs_cache_find()
867 if (IS_ERR(ce)) { in dfs_cache_find()
868 rc = PTR_ERR(ce); in dfs_cache_find()
873 rc = setup_referral(path, ce, ref, get_tgt_name(ce)); in dfs_cache_find()
877 rc = get_targets(ce, tgt_list); in dfs_cache_find()
906 struct cache_entry *ce; in dfs_cache_noreq_find() local
912 ce = lookup_cache_entry(path); in dfs_cache_noreq_find()
913 if (IS_ERR(ce)) { in dfs_cache_noreq_find()
914 rc = PTR_ERR(ce); in dfs_cache_noreq_find()
919 rc = setup_referral(path, ce, ref, get_tgt_name(ce)); in dfs_cache_noreq_find()
923 rc = get_targets(ce, tgt_list); in dfs_cache_noreq_find()
947 struct cache_entry *ce; in dfs_cache_noreq_update_tgthint() local
956 ce = lookup_cache_entry(path); in dfs_cache_noreq_update_tgthint()
957 if (IS_ERR(ce)) in dfs_cache_noreq_update_tgthint()
960 t = READ_ONCE(ce->tgthint); in dfs_cache_noreq_update_tgthint()
965 list_for_each_entry(t, &ce->tlist, list) { in dfs_cache_noreq_update_tgthint()
967 WRITE_ONCE(ce->tgthint, t); in dfs_cache_noreq_update_tgthint()
992 struct cache_entry *ce; in dfs_cache_get_tgt_referral() local
1001 ce = lookup_cache_entry(path); in dfs_cache_get_tgt_referral()
1002 if (IS_ERR(ce)) { in dfs_cache_get_tgt_referral()
1003 rc = PTR_ERR(ce); in dfs_cache_get_tgt_referral()
1009 rc = setup_referral(path, ce, ref, it->it_name); in dfs_cache_get_tgt_referral()
1165 struct cache_entry *ce; in refresh_ses_referral() local
1186 ce = cache_refresh_path(xid, ses, path, false); in refresh_ses_referral()
1187 if (!IS_ERR(ce)) in refresh_ses_referral()
1190 rc = PTR_ERR(ce); in refresh_ses_referral()
1202 struct cache_entry *ce; in __refresh_tcon_referral() local
1221 ce = lookup_cache_entry(path); in __refresh_tcon_referral()
1222 if (!IS_ERR(ce)) { in __refresh_tcon_referral()
1223 if (force_refresh || cache_entry_expired(ce)) in __refresh_tcon_referral()
1224 rc = update_cache_entry_locked(ce, refs, numrefs); in __refresh_tcon_referral()
1225 } else if (PTR_ERR(ce) == -ENOENT) { in __refresh_tcon_referral()
1226 ce = add_cache_entry_locked(refs, numrefs); in __refresh_tcon_referral()
1230 if (IS_ERR(ce)) in __refresh_tcon_referral()
1231 rc = PTR_ERR(ce); in __refresh_tcon_referral()
1242 struct cache_entry *ce; in refresh_tcon_referral() local
1261 ce = lookup_cache_entry(path); in refresh_tcon_referral()
1262 needs_refresh = force_refresh || IS_ERR(ce) || cache_entry_expired(ce); in refresh_tcon_referral()