Lines Matching refs:ce

103 static inline bool cache_entry_expired(const struct dfs_cache_entry *ce)  in cache_entry_expired()  argument
108 return timespec64_compare(&ts, &ce->ce_etime) >= 0; in cache_entry_expired()
111 static inline void free_tgts(struct dfs_cache_entry *ce) in free_tgts() argument
115 list_for_each_entry_safe(t, n, &ce->ce_tlist, t_list) { in free_tgts()
124 struct dfs_cache_entry *ce = container_of(rcu, struct dfs_cache_entry, in free_cache_entry() local
126 kmem_cache_free(dfs_cache_slab, ce); in free_cache_entry()
129 static inline void flush_cache_ent(struct dfs_cache_entry *ce) in flush_cache_ent() argument
131 if (hlist_unhashed(&ce->ce_hlist)) in flush_cache_ent()
134 hlist_del_init_rcu(&ce->ce_hlist); in flush_cache_ent()
135 kfree_const(ce->ce_path); in flush_cache_ent()
136 free_tgts(ce); in flush_cache_ent()
138 call_rcu(&ce->ce_rcu, free_cache_entry); in flush_cache_ent()
148 struct dfs_cache_entry *ce; in flush_cache_ents() local
150 hlist_for_each_entry_rcu(ce, l, ce_hlist) in flush_cache_ents()
151 flush_cache_ent(ce); in flush_cache_ents()
162 struct dfs_cache_entry *ce; in dfscache_proc_show() local
170 hash_for_each_rcu(dfs_cache_htable, bucket, ce, ce_hlist) { in dfscache_proc_show()
174 ce->ce_path, in dfscache_proc_show()
175 ce->ce_srvtype == DFS_TYPE_ROOT ? "root" : "link", in dfscache_proc_show()
176 ce->ce_ttl, ce->ce_etime.tv_nsec, in dfscache_proc_show()
177 IS_INTERLINK_SET(ce->ce_flags) ? "yes" : "no", in dfscache_proc_show()
178 ce->ce_path_consumed, in dfscache_proc_show()
179 cache_entry_expired(ce) ? "yes" : "no"); in dfscache_proc_show()
181 list_for_each_entry(t, &ce->ce_tlist, t_list) { in dfscache_proc_show()
184 ce->ce_tgthint == t ? " (target hint)" : ""); in dfscache_proc_show()
229 static inline void dump_tgts(const struct dfs_cache_entry *ce) in dump_tgts() argument
234 list_for_each_entry(t, &ce->ce_tlist, t_list) { in dump_tgts()
236 ce->ce_tgthint == t ? " (target hint)" : ""); in dump_tgts()
240 static inline void dump_ce(const struct dfs_cache_entry *ce) in dump_ce() argument
243 "interlink=%s,path_consumed=%d,expired=%s\n", ce->ce_path, in dump_ce()
244 ce->ce_srvtype == DFS_TYPE_ROOT ? "root" : "link", ce->ce_ttl, in dump_ce()
245 ce->ce_etime.tv_nsec, in dump_ce()
246 IS_INTERLINK_SET(ce->ce_flags) ? "yes" : "no", in dump_ce()
247 ce->ce_path_consumed, in dump_ce()
248 cache_entry_expired(ce) ? "yes" : "no"); in dump_ce()
249 dump_tgts(ce); in dump_ce()
328 static inline char *get_tgt_name(const struct dfs_cache_entry *ce) in get_tgt_name() argument
330 struct dfs_cache_tgt *t = ce->ce_tgthint; in get_tgt_name()
370 struct dfs_cache_entry *ce, const char *tgthint) in copy_ref_data() argument
374 ce->ce_ttl = refs[0].ttl; in copy_ref_data()
375 ce->ce_etime = get_expire_time(ce->ce_ttl); in copy_ref_data()
376 ce->ce_srvtype = refs[0].server_type; in copy_ref_data()
377 ce->ce_flags = refs[0].ref_flag; in copy_ref_data()
378 ce->ce_path_consumed = refs[0].path_consumed; in copy_ref_data()
385 free_tgts(ce); in copy_ref_data()
389 list_add(&t->t_list, &ce->ce_tlist); in copy_ref_data()
392 list_add_tail(&t->t_list, &ce->ce_tlist); in copy_ref_data()
394 ce->ce_numtgts++; in copy_ref_data()
397 ce->ce_tgthint = list_first_entry_or_null(&ce->ce_tlist, in copy_ref_data()
408 struct dfs_cache_entry *ce; in alloc_cache_entry() local
411 ce = kmem_cache_zalloc(dfs_cache_slab, GFP_KERNEL); in alloc_cache_entry()
412 if (!ce) in alloc_cache_entry()
415 ce->ce_path = kstrdup_const(path, GFP_KERNEL); in alloc_cache_entry()
416 if (!ce->ce_path) { in alloc_cache_entry()
417 kmem_cache_free(dfs_cache_slab, ce); in alloc_cache_entry()
420 INIT_HLIST_NODE(&ce->ce_hlist); in alloc_cache_entry()
421 INIT_LIST_HEAD(&ce->ce_tlist); in alloc_cache_entry()
423 rc = copy_ref_data(refs, numrefs, ce, NULL); in alloc_cache_entry()
425 kfree_const(ce->ce_path); in alloc_cache_entry()
426 kmem_cache_free(dfs_cache_slab, ce); in alloc_cache_entry()
427 ce = ERR_PTR(rc); in alloc_cache_entry()
429 return ce; in alloc_cache_entry()
435 struct dfs_cache_entry *ce; in remove_oldest_entry() local
439 hash_for_each_rcu(dfs_cache_htable, bucket, ce, ce_hlist) { in remove_oldest_entry()
440 if (!to_del || timespec64_compare(&ce->ce_etime, in remove_oldest_entry()
442 to_del = ce; in remove_oldest_entry()
460 struct dfs_cache_entry *ce; in add_cache_entry() local
462 ce = alloc_cache_entry(path, refs, numrefs); in add_cache_entry()
463 if (IS_ERR(ce)) in add_cache_entry()
464 return ce; in add_cache_entry()
466 hlist_add_head_rcu(&ce->ce_hlist, &dfs_cache_htable[hash]); in add_cache_entry()
470 dfs_cache.dc_ttl = ce->ce_ttl; in add_cache_entry()
474 dfs_cache.dc_ttl = min_t(int, dfs_cache.dc_ttl, ce->ce_ttl); in add_cache_entry()
480 return ce; in add_cache_entry()
486 struct dfs_cache_entry *ce; in __find_cache_entry() local
490 hlist_for_each_entry_rcu(ce, &dfs_cache_htable[hash], ce_hlist) { in __find_cache_entry()
491 if (!strcasecmp(path, ce->ce_path)) { in __find_cache_entry()
493 char *name = get_tgt_name(ce); in __find_cache_entry()
507 return found ? ce : ERR_PTR(-ENOENT); in __find_cache_entry()
569 struct dfs_cache_entry *ce; in __update_cache_entry() local
572 ce = find_cache_entry(path, &h); in __update_cache_entry()
573 if (IS_ERR(ce)) in __update_cache_entry()
574 return ce; in __update_cache_entry()
576 if (ce->ce_tgthint) { in __update_cache_entry()
577 s = ce->ce_tgthint->t_name; in __update_cache_entry()
583 free_tgts(ce); in __update_cache_entry()
584 ce->ce_numtgts = 0; in __update_cache_entry()
586 rc = copy_ref_data(refs, numrefs, ce, th); in __update_cache_entry()
590 ce = ERR_PTR(rc); in __update_cache_entry()
592 return ce; in __update_cache_entry()
599 const char *path, struct dfs_cache_entry *ce) in update_cache_entry() argument
620 ce = ERR_PTR(rc); in update_cache_entry()
622 ce = __update_cache_entry(path, refs, numrefs); in update_cache_entry()
627 return ce; in update_cache_entry()
646 struct dfs_cache_entry *ce; in do_dfs_cache_find() local
652 ce = find_cache_entry(path, &h); in do_dfs_cache_find()
653 if (IS_ERR(ce)) { in do_dfs_cache_find()
660 return ce; in do_dfs_cache_find()
667 ce = ERR_PTR(-EOPNOTSUPP); in do_dfs_cache_find()
668 return ce; in do_dfs_cache_find()
671 ce = ERR_PTR(-EINVAL); in do_dfs_cache_find()
672 return ce; in do_dfs_cache_find()
685 ce = ERR_PTR(rc); in do_dfs_cache_find()
686 return ce; in do_dfs_cache_find()
698 ce = add_cache_entry(h, path, nrefs, numnrefs); in do_dfs_cache_find()
701 if (IS_ERR(ce)) in do_dfs_cache_find()
702 return ce; in do_dfs_cache_find()
707 dump_ce(ce); in do_dfs_cache_find()
711 return ce; in do_dfs_cache_find()
713 if (cache_entry_expired(ce)) { in do_dfs_cache_find()
715 ce = update_cache_entry(xid, ses, nls_codepage, remap, path, in do_dfs_cache_find()
716 ce); in do_dfs_cache_find()
717 if (IS_ERR(ce)) { in do_dfs_cache_find()
722 return ce; in do_dfs_cache_find()
726 static int setup_ref(const char *path, const struct dfs_cache_entry *ce, in setup_ref() argument
739 ref->path_consumed = ce->ce_path_consumed; in setup_ref()
747 ref->ttl = ce->ce_ttl; in setup_ref()
748 ref->server_type = ce->ce_srvtype; in setup_ref()
749 ref->ref_flag = ce->ce_flags; in setup_ref()
760 static int get_tgt_list(const struct dfs_cache_entry *ce, in get_tgt_list() argument
771 list_for_each_entry(t, &ce->ce_tlist, t_list) { in get_tgt_list()
786 if (ce->ce_tgthint == t) in get_tgt_list()
791 tl->tl_numtgts = ce->ce_numtgts; in get_tgt_list()
832 struct dfs_cache_entry *ce; in dfs_cache_find() local
842 ce = do_dfs_cache_find(xid, ses, nls_codepage, remap, npath, false); in dfs_cache_find()
843 if (!IS_ERR(ce)) { in dfs_cache_find()
845 rc = setup_ref(path, ce, ref, get_tgt_name(ce)); in dfs_cache_find()
849 rc = get_tgt_list(ce, tgt_list); in dfs_cache_find()
851 rc = PTR_ERR(ce); in dfs_cache_find()
879 struct dfs_cache_entry *ce; in dfs_cache_noreq_find() local
889 ce = do_dfs_cache_find(0, NULL, NULL, 0, npath, true); in dfs_cache_noreq_find()
890 if (IS_ERR(ce)) { in dfs_cache_noreq_find()
891 rc = PTR_ERR(ce); in dfs_cache_noreq_find()
896 rc = setup_ref(path, ce, ref, get_tgt_name(ce)); in dfs_cache_noreq_find()
900 rc = get_tgt_list(ce, tgt_list); in dfs_cache_noreq_find()
932 struct dfs_cache_entry *ce; in dfs_cache_update_tgthint() local
945 ce = do_dfs_cache_find(xid, ses, nls_codepage, remap, npath, false); in dfs_cache_update_tgthint()
946 if (IS_ERR(ce)) { in dfs_cache_update_tgthint()
947 rc = PTR_ERR(ce); in dfs_cache_update_tgthint()
953 t = ce->ce_tgthint; in dfs_cache_update_tgthint()
958 list_for_each_entry(t, &ce->ce_tlist, t_list) { in dfs_cache_update_tgthint()
960 ce->ce_tgthint = t; in dfs_cache_update_tgthint()
992 struct dfs_cache_entry *ce; in dfs_cache_noreq_update_tgthint() local
1006 ce = do_dfs_cache_find(0, NULL, NULL, 0, npath, true); in dfs_cache_noreq_update_tgthint()
1007 if (IS_ERR(ce)) { in dfs_cache_noreq_update_tgthint()
1008 rc = PTR_ERR(ce); in dfs_cache_noreq_update_tgthint()
1014 t = ce->ce_tgthint; in dfs_cache_noreq_update_tgthint()
1019 list_for_each_entry(t, &ce->ce_tlist, t_list) { in dfs_cache_noreq_update_tgthint()
1021 ce->ce_tgthint = t; in dfs_cache_noreq_update_tgthint()
1050 struct dfs_cache_entry *ce; in dfs_cache_get_tgt_referral() local
1066 ce = find_cache_entry(npath, &h); in dfs_cache_get_tgt_referral()
1067 if (IS_ERR(ce)) { in dfs_cache_get_tgt_referral()
1068 rc = PTR_ERR(ce); in dfs_cache_get_tgt_referral()
1074 rc = setup_ref(path, ce, ref, it->it_name); in dfs_cache_get_tgt_referral()
1384 struct dfs_cache_entry *ce; in do_refresh_tcon() local
1398 ce = find_cache_entry(npath, &h); in do_refresh_tcon()
1401 if (IS_ERR(ce)) { in do_refresh_tcon()
1402 rc = PTR_ERR(ce); in do_refresh_tcon()
1406 if (!cache_entry_expired(ce)) in do_refresh_tcon()
1429 ce = __update_cache_entry(npath, refs, numrefs); in do_refresh_tcon()
1433 if (IS_ERR(ce)) in do_refresh_tcon()
1434 rc = PTR_ERR(ce); in do_refresh_tcon()