Lines Matching refs:detail
41 static bool cache_listeners_exist(struct cache_detail *detail);
43 static void cache_init(struct cache_head *h, struct cache_detail *detail) in cache_init() argument
50 if (now <= detail->flush_time) in cache_init()
52 now = detail->flush_time + 1; in cache_init()
58 struct cache_detail *detail);
60 struct cache_detail *detail);
62 static struct cache_head *sunrpc_cache_find_rcu(struct cache_detail *detail, in sunrpc_cache_find_rcu() argument
66 struct hlist_head *head = &detail->hash_table[hash]; in sunrpc_cache_find_rcu()
71 if (detail->match(tmp, key)) { in sunrpc_cache_find_rcu()
72 if (cache_is_expired(detail, tmp)) in sunrpc_cache_find_rcu()
83 static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail, in sunrpc_cache_add_entry() argument
88 struct hlist_head *head = &detail->hash_table[hash]; in sunrpc_cache_add_entry()
90 new = detail->alloc(); in sunrpc_cache_add_entry()
97 cache_init(new, detail); in sunrpc_cache_add_entry()
98 detail->init(new, key); in sunrpc_cache_add_entry()
100 spin_lock(&detail->hash_lock); in sunrpc_cache_add_entry()
104 if (detail->match(tmp, key)) { in sunrpc_cache_add_entry()
105 if (cache_is_expired(detail, tmp)) { in sunrpc_cache_add_entry()
107 detail->entries --; in sunrpc_cache_add_entry()
110 cache_fresh_locked(tmp, 0, detail); in sunrpc_cache_add_entry()
115 spin_unlock(&detail->hash_lock); in sunrpc_cache_add_entry()
116 cache_put(new, detail); in sunrpc_cache_add_entry()
122 detail->entries++; in sunrpc_cache_add_entry()
124 spin_unlock(&detail->hash_lock); in sunrpc_cache_add_entry()
127 cache_fresh_unlocked(freeme, detail); in sunrpc_cache_add_entry()
128 cache_put(freeme, detail); in sunrpc_cache_add_entry()
133 struct cache_head *sunrpc_cache_lookup_rcu(struct cache_detail *detail, in sunrpc_cache_lookup_rcu() argument
138 ret = sunrpc_cache_find_rcu(detail, key, hash); in sunrpc_cache_lookup_rcu()
142 return sunrpc_cache_add_entry(detail, key, hash); in sunrpc_cache_lookup_rcu()
146 static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch);
149 struct cache_detail *detail) in cache_fresh_locked() argument
152 if (now <= detail->flush_time) in cache_fresh_locked()
154 now = detail->flush_time + 1; in cache_fresh_locked()
162 struct cache_detail *detail) in cache_fresh_unlocked() argument
166 cache_dequeue(detail, head); in cache_fresh_unlocked()
170 struct cache_head *sunrpc_cache_update(struct cache_detail *detail, in sunrpc_cache_update() argument
180 spin_lock(&detail->hash_lock); in sunrpc_cache_update()
185 detail->update(old, new); in sunrpc_cache_update()
186 cache_fresh_locked(old, new->expiry_time, detail); in sunrpc_cache_update()
187 spin_unlock(&detail->hash_lock); in sunrpc_cache_update()
188 cache_fresh_unlocked(old, detail); in sunrpc_cache_update()
191 spin_unlock(&detail->hash_lock); in sunrpc_cache_update()
194 tmp = detail->alloc(); in sunrpc_cache_update()
196 cache_put(old, detail); in sunrpc_cache_update()
199 cache_init(tmp, detail); in sunrpc_cache_update()
200 detail->init(tmp, old); in sunrpc_cache_update()
202 spin_lock(&detail->hash_lock); in sunrpc_cache_update()
206 detail->update(tmp, new); in sunrpc_cache_update()
207 hlist_add_head(&tmp->cache_list, &detail->hash_table[hash]); in sunrpc_cache_update()
208 detail->entries++; in sunrpc_cache_update()
210 cache_fresh_locked(tmp, new->expiry_time, detail); in sunrpc_cache_update()
211 cache_fresh_locked(old, 0, detail); in sunrpc_cache_update()
212 spin_unlock(&detail->hash_lock); in sunrpc_cache_update()
213 cache_fresh_unlocked(tmp, detail); in sunrpc_cache_update()
214 cache_fresh_unlocked(old, detail); in sunrpc_cache_update()
215 cache_put(old, detail); in sunrpc_cache_update()
248 static int try_to_negate_entry(struct cache_detail *detail, struct cache_head *h) in try_to_negate_entry() argument
252 spin_lock(&detail->hash_lock); in try_to_negate_entry()
257 detail); in try_to_negate_entry()
260 spin_unlock(&detail->hash_lock); in try_to_negate_entry()
261 cache_fresh_unlocked(h, detail); in try_to_negate_entry()
279 int cache_check(struct cache_detail *detail, in cache_check() argument
300 switch (cache_make_upcall(detail, h)) { in cache_check()
302 rv = try_to_negate_entry(detail, h); in cache_check()
305 cache_fresh_unlocked(h, detail); in cache_check()
308 } else if (!cache_listeners_exist(detail)) in cache_check()
309 rv = try_to_negate_entry(detail, h); in cache_check()
324 cache_put(h, detail); in cache_check()
517 void cache_purge(struct cache_detail *detail) in cache_purge() argument
524 spin_lock(&detail->hash_lock); in cache_purge()
525 if (!detail->entries) { in cache_purge()
526 spin_unlock(&detail->hash_lock); in cache_purge()
530 dprintk("RPC: %d entries in %s cache\n", detail->entries, detail->name); in cache_purge()
531 for (i = 0; i < detail->hash_size; i++) { in cache_purge()
532 head = &detail->hash_table[i]; in cache_purge()
535 detail->entries--; in cache_purge()
538 spin_unlock(&detail->hash_lock); in cache_purge()
539 cache_fresh_unlocked(ch, detail); in cache_purge()
540 cache_put(ch, detail); in cache_purge()
541 spin_lock(&detail->hash_lock); in cache_purge()
544 spin_unlock(&detail->hash_lock); in cache_purge()
790 static int cache_request(struct cache_detail *detail, in cache_request() argument
796 detail->cache_request(detail, crq->item, &bp, &len); in cache_request()
1078 static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch) in cache_dequeue() argument
1086 list_for_each_entry_safe(cq, tmp, &detail->queue, list) in cache_dequeue()
1102 cache_put(cr->item, detail); in cache_dequeue()
1167 static void warn_no_listener(struct cache_detail *detail) in warn_no_listener() argument
1169 if (detail->last_warn != detail->last_close) { in warn_no_listener()
1170 detail->last_warn = detail->last_close; in warn_no_listener()
1171 if (detail->warn_no_listener) in warn_no_listener()
1172 detail->warn_no_listener(detail, detail->last_close != 0); in warn_no_listener()
1176 static bool cache_listeners_exist(struct cache_detail *detail) in cache_listeners_exist() argument
1178 if (atomic_read(&detail->writers)) in cache_listeners_exist()
1180 if (detail->last_close == 0) in cache_listeners_exist()
1183 if (detail->last_close < seconds_since_boot() - 30) in cache_listeners_exist()
1199 int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h) in sunrpc_cache_pipe_upcall() argument
1206 if (!detail->cache_request) in sunrpc_cache_pipe_upcall()
1209 if (!cache_listeners_exist(detail)) { in sunrpc_cache_pipe_upcall()
1210 warn_no_listener(detail); in sunrpc_cache_pipe_upcall()
1234 list_add_tail(&crq->q.list, &detail->queue); in sunrpc_cache_pipe_upcall()