Lines Matching refs:ce

104 static inline bool cache_entry_expired(const struct cache_entry *ce)
109 return timespec64_compare(&ts, &ce->etime) >= 0;
112 static inline void free_tgts(struct cache_entry *ce)
116 list_for_each_entry_safe(t, n, &ce->tlist, list) {
123 static inline void flush_cache_ent(struct cache_entry *ce)
125 hlist_del_init(&ce->hlist);
126 kfree(ce->path);
127 free_tgts(ce);
129 kmem_cache_free(cache_slab, ce);
139 struct cache_entry *ce;
141 hlist_for_each_entry_safe(ce, n, l, hlist) {
142 if (!hlist_unhashed(&ce->hlist))
143 flush_cache_ent(ce);
154 struct cache_entry *ce;
163 hlist_for_each_entry(ce, l, hlist) {
164 if (hlist_unhashed(&ce->hlist))
170 ce->path,
171 ce->srvtype == DFS_TYPE_ROOT ? "root" : "link",
172 ce->ttl, ce->etime.tv_nsec,
173 IS_INTERLINK_SET(ce->flags) ? "yes" : "no",
174 ce->path_consumed,
175 cache_entry_expired(ce) ? "yes" : "no");
177 list_for_each_entry(t, &ce->tlist, list) {
180 ce->tgthint == t ? " (target hint)" : "");
225 static inline void dump_tgts(const struct cache_entry *ce)
230 list_for_each_entry(t, &ce->tlist, list) {
232 ce->tgthint == t ? " (target hint)" : "");
236 static inline void dump_ce(const struct cache_entry *ce)
239 ce->path,
240 ce->srvtype == DFS_TYPE_ROOT ? "root" : "link", ce->ttl,
241 ce->etime.tv_nsec,
242 IS_INTERLINK_SET(ce->flags) ? "yes" : "no",
243 ce->path_consumed,
244 cache_entry_expired(ce) ? "yes" : "no");
245 dump_tgts(ce);
333 static inline char *get_tgt_name(const struct cache_entry *ce)
335 struct cache_dfs_tgt *t = ce->tgthint;
376 struct cache_entry *ce, const char *tgthint)
380 ce->ttl = refs[0].ttl;
381 ce->etime = get_expire_time(ce->ttl);
382 ce->srvtype = refs[0].server_type;
383 ce->flags = refs[0].ref_flag;
384 ce->path_consumed = refs[0].path_consumed;
391 free_tgts(ce);
395 list_add(&t->list, &ce->tlist);
398 list_add_tail(&t->list, &ce->tlist);
400 ce->numtgts++;
403 ce->tgthint = list_first_entry_or_null(&ce->tlist,
414 struct cache_entry *ce;
417 ce = kmem_cache_zalloc(cache_slab, GFP_KERNEL);
418 if (!ce)
421 ce->path = kstrndup(path, strlen(path), GFP_KERNEL);
422 if (!ce->path) {
423 kmem_cache_free(cache_slab, ce);
426 INIT_HLIST_NODE(&ce->hlist);
427 INIT_LIST_HEAD(&ce->tlist);
429 rc = copy_ref_data(refs, numrefs, ce, NULL);
431 kfree(ce->path);
432 kmem_cache_free(cache_slab, ce);
433 ce = ERR_PTR(rc);
435 return ce;
442 struct cache_entry *ce;
448 hlist_for_each_entry(ce, l, hlist) {
449 if (hlist_unhashed(&ce->hlist))
451 if (!to_del || timespec64_compare(&ce->etime,
453 to_del = ce;
471 struct cache_entry *ce;
473 ce = alloc_cache_entry(path, refs, numrefs);
474 if (IS_ERR(ce))
475 return PTR_ERR(ce);
479 cache_ttl = ce->ttl;
482 cache_ttl = min_t(int, cache_ttl, ce->ttl);
488 hlist_add_head(&ce->hlist, &cache_htable[hash]);
489 dump_ce(ce);
497 struct cache_entry *ce;
503 hlist_for_each_entry(ce, &cache_htable[h], hlist) {
504 if (!strcasecmp(path, ce->path)) {
506 dump_ce(ce);
512 ce = ERR_PTR(-ENOENT);
513 return ce;
526 struct cache_entry *ce = ERR_PTR(-ENOENT);
544 ce = __lookup_cache_entry(path);
567 ce = __lookup_cache_entry(npath);
568 if (!IS_ERR(ce)) {
582 return ce;
634 struct cache_entry *ce;
637 ce = lookup_cache_entry(path, NULL);
638 if (IS_ERR(ce))
639 return PTR_ERR(ce);
641 if (ce->tgthint) {
642 s = ce->tgthint->name;
648 free_tgts(ce);
649 ce->numtgts = 0;
651 rc = copy_ref_data(refs, numrefs, ce, th);
707 struct cache_entry *ce;
716 ce = lookup_cache_entry(path, &hash);
724 return PTR_ERR_OR_ZERO(ce);
727 if (!IS_ERR(ce)) {
728 if (!cache_entry_expired(ce)) {
729 dump_ce(ce);
779 static int setup_referral(const char *path, struct cache_entry *ce,
798 ref->path_consumed = ce->path_consumed;
799 ref->ttl = ce->ttl;
800 ref->server_type = ce->srvtype;
801 ref->ref_flag = ce->flags;
812 static int get_targets(struct cache_entry *ce, struct dfs_cache_tgt_list *tl)
822 list_for_each_entry(t, &ce->tlist, list) {
837 if (ce->tgthint == t)
843 tl->tl_numtgts = ce->numtgts;
884 struct cache_entry *ce;
896 ce = lookup_cache_entry(npath, NULL);
897 if (IS_ERR(ce)) {
899 rc = PTR_ERR(ce);
904 rc = setup_referral(path, ce, ref, get_tgt_name(ce));
908 rc = get_targets(ce, tgt_list);
938 struct cache_entry *ce;
948 ce = lookup_cache_entry(npath, NULL);
949 if (IS_ERR(ce)) {
950 rc = PTR_ERR(ce);
955 rc = setup_referral(path, ce, ref, get_tgt_name(ce));
959 rc = get_targets(ce, tgt_list);
993 struct cache_entry *ce;
1008 ce = lookup_cache_entry(npath, NULL);
1009 if (IS_ERR(ce)) {
1010 rc = PTR_ERR(ce);
1014 t = ce->tgthint;
1019 list_for_each_entry(t, &ce->tlist, list) {
1021 ce->tgthint = t;
1055 struct cache_entry *ce;
1069 ce = lookup_cache_entry(npath, NULL);
1070 if (IS_ERR(ce)) {
1071 rc = PTR_ERR(ce);
1076 t = ce->tgthint;
1081 list_for_each_entry(t, &ce->tlist, list) {
1083 ce->tgthint = t;
1113 struct cache_entry *ce;
1126 ce = lookup_cache_entry(npath, NULL);
1127 if (IS_ERR(ce)) {
1128 rc = PTR_ERR(ce);
1134 rc = setup_referral(path, ce, ref, it->it_name);
1475 struct cache_entry *ce;
1488 ce = lookup_cache_entry(rpath, NULL);
1489 if (IS_ERR(ce)) {
1491 ses = ERR_CAST(ce);
1495 rc = setup_referral(path, ce, &ref, get_tgt_name(ce));
1544 struct cache_entry *ce;
1559 ce = lookup_cache_entry(npath, NULL);
1560 if (IS_ERR(ce)) {
1561 rc = PTR_ERR(ce);
1566 if (!cache_entry_expired(ce)) {