Lines Matching full: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()
57 struct cache_detail *detail);
59 static struct cache_head *sunrpc_cache_find_rcu(struct cache_detail *detail, in sunrpc_cache_find_rcu() argument
63 struct hlist_head *head = &detail->hash_table[hash]; in sunrpc_cache_find_rcu()
68 if (!detail->match(tmp, key)) in sunrpc_cache_find_rcu()
71 cache_is_expired(detail, tmp)) in sunrpc_cache_find_rcu()
97 static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail, in sunrpc_cache_add_entry() argument
102 struct hlist_head *head = &detail->hash_table[hash]; in sunrpc_cache_add_entry()
104 new = detail->alloc(); in sunrpc_cache_add_entry()
111 cache_init(new, detail); in sunrpc_cache_add_entry()
112 detail->init(new, key); in sunrpc_cache_add_entry()
114 spin_lock(&detail->hash_lock); in sunrpc_cache_add_entry()
118 lockdep_is_held(&detail->hash_lock)) { in sunrpc_cache_add_entry()
119 if (!detail->match(tmp, key)) in sunrpc_cache_add_entry()
122 cache_is_expired(detail, tmp)) { in sunrpc_cache_add_entry()
123 sunrpc_begin_cache_remove_entry(tmp, detail); in sunrpc_cache_add_entry()
124 trace_cache_entry_expired(detail, tmp); in sunrpc_cache_add_entry()
129 spin_unlock(&detail->hash_lock); in sunrpc_cache_add_entry()
130 cache_put(new, detail); in sunrpc_cache_add_entry()
135 detail->entries++; in sunrpc_cache_add_entry()
137 spin_unlock(&detail->hash_lock); in sunrpc_cache_add_entry()
140 sunrpc_end_cache_remove_entry(freeme, detail); in sunrpc_cache_add_entry()
144 struct cache_head *sunrpc_cache_lookup_rcu(struct cache_detail *detail, in sunrpc_cache_lookup_rcu() argument
149 ret = sunrpc_cache_find_rcu(detail, key, hash); in sunrpc_cache_lookup_rcu()
153 return sunrpc_cache_add_entry(detail, key, hash); in sunrpc_cache_lookup_rcu()
157 static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch);
160 struct cache_detail *detail) in cache_fresh_locked() argument
163 if (now <= detail->flush_time) in cache_fresh_locked()
165 now = detail->flush_time + 1; in cache_fresh_locked()
173 struct cache_detail *detail) in cache_fresh_unlocked() argument
177 cache_dequeue(detail, head); in cache_fresh_unlocked()
181 static void cache_make_negative(struct cache_detail *detail, in cache_make_negative() argument
185 trace_cache_entry_make_negative(detail, h); in cache_make_negative()
188 static void cache_entry_update(struct cache_detail *detail, in cache_entry_update() argument
193 detail->update(h, new); in cache_entry_update()
194 trace_cache_entry_update(detail, h); in cache_entry_update()
196 cache_make_negative(detail, h); in cache_entry_update()
200 struct cache_head *sunrpc_cache_update(struct cache_detail *detail, in sunrpc_cache_update() argument
210 spin_lock(&detail->hash_lock); in sunrpc_cache_update()
212 cache_entry_update(detail, old, new); in sunrpc_cache_update()
213 cache_fresh_locked(old, new->expiry_time, detail); in sunrpc_cache_update()
214 spin_unlock(&detail->hash_lock); in sunrpc_cache_update()
215 cache_fresh_unlocked(old, detail); in sunrpc_cache_update()
218 spin_unlock(&detail->hash_lock); in sunrpc_cache_update()
221 tmp = detail->alloc(); in sunrpc_cache_update()
223 cache_put(old, detail); in sunrpc_cache_update()
226 cache_init(tmp, detail); in sunrpc_cache_update()
227 detail->init(tmp, old); in sunrpc_cache_update()
229 spin_lock(&detail->hash_lock); in sunrpc_cache_update()
230 cache_entry_update(detail, tmp, new); in sunrpc_cache_update()
231 hlist_add_head(&tmp->cache_list, &detail->hash_table[hash]); in sunrpc_cache_update()
232 detail->entries++; in sunrpc_cache_update()
234 cache_fresh_locked(tmp, new->expiry_time, detail); in sunrpc_cache_update()
235 cache_fresh_locked(old, 0, detail); in sunrpc_cache_update()
236 spin_unlock(&detail->hash_lock); in sunrpc_cache_update()
237 cache_fresh_unlocked(tmp, detail); in sunrpc_cache_update()
238 cache_fresh_unlocked(old, detail); in sunrpc_cache_update()
239 cache_put(old, detail); in sunrpc_cache_update()
265 static int try_to_negate_entry(struct cache_detail *detail, struct cache_head *h) in try_to_negate_entry() argument
269 spin_lock(&detail->hash_lock); in try_to_negate_entry()
272 cache_make_negative(detail, h); in try_to_negate_entry()
274 detail); in try_to_negate_entry()
277 spin_unlock(&detail->hash_lock); in try_to_negate_entry()
278 cache_fresh_unlocked(h, detail); in try_to_negate_entry()
296 int cache_check(struct cache_detail *detail, in cache_check() argument
316 switch (detail->cache_upcall(detail, h)) { in cache_check()
318 rv = try_to_negate_entry(detail, h); in cache_check()
321 cache_fresh_unlocked(h, detail); in cache_check()
338 cache_put(h, detail); in cache_check()
529 void cache_purge(struct cache_detail *detail) in cache_purge() argument
535 spin_lock(&detail->hash_lock); in cache_purge()
536 if (!detail->entries) { in cache_purge()
537 spin_unlock(&detail->hash_lock); in cache_purge()
541 dprintk("RPC: %d entries in %s cache\n", detail->entries, detail->name); in cache_purge()
542 for (i = 0; i < detail->hash_size; i++) { in cache_purge()
543 head = &detail->hash_table[i]; in cache_purge()
547 sunrpc_begin_cache_remove_entry(ch, detail); in cache_purge()
548 spin_unlock(&detail->hash_lock); in cache_purge()
549 sunrpc_end_cache_remove_entry(ch, detail); in cache_purge()
550 spin_lock(&detail->hash_lock); in cache_purge()
553 spin_unlock(&detail->hash_lock); in cache_purge()
799 static int cache_request(struct cache_detail *detail, in cache_request() argument
805 detail->cache_request(detail, crq->item, &bp, &len); in cache_request()
1087 static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch) in cache_dequeue() argument
1095 list_for_each_entry_safe(cq, tmp, &detail->queue, list) in cache_dequeue()
1111 cache_put(cr->item, detail); in cache_dequeue()
1176 static void warn_no_listener(struct cache_detail *detail) in warn_no_listener() argument
1178 if (detail->last_warn != detail->last_close) { in warn_no_listener()
1179 detail->last_warn = detail->last_close; in warn_no_listener()
1180 if (detail->warn_no_listener) in warn_no_listener()
1181 detail->warn_no_listener(detail, detail->last_close != 0); in warn_no_listener()
1185 static bool cache_listeners_exist(struct cache_detail *detail) in cache_listeners_exist() argument
1187 if (atomic_read(&detail->writers)) in cache_listeners_exist()
1189 if (detail->last_close == 0) in cache_listeners_exist()
1192 if (detail->last_close < seconds_since_boot() - 30) in cache_listeners_exist()
1208 static int cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h) in cache_pipe_upcall() argument
1235 list_add_tail(&crq->q.list, &detail->queue); in cache_pipe_upcall()
1236 trace_cache_entry_upcall(detail, h); in cache_pipe_upcall()
1249 int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h) in sunrpc_cache_pipe_upcall() argument
1253 return cache_pipe_upcall(detail, h); in sunrpc_cache_pipe_upcall()
1257 int sunrpc_cache_pipe_upcall_timeout(struct cache_detail *detail, in sunrpc_cache_pipe_upcall_timeout() argument
1260 if (!cache_listeners_exist(detail)) { in sunrpc_cache_pipe_upcall_timeout()
1261 warn_no_listener(detail); in sunrpc_cache_pipe_upcall_timeout()
1262 trace_cache_entry_no_listener(detail, h); in sunrpc_cache_pipe_upcall_timeout()
1265 return sunrpc_cache_pipe_upcall(detail, h); in sunrpc_cache_pipe_upcall_timeout()