Lines Matching full:detail
45 static void cache_init(struct cache_head *h, struct cache_detail *detail) in cache_init() argument
52 if (now <= detail->flush_time) in cache_init()
54 now = detail->flush_time + 1; in cache_init()
59 struct cache_detail *detail);
61 static struct cache_head *sunrpc_cache_find_rcu(struct cache_detail *detail, in sunrpc_cache_find_rcu() argument
65 struct hlist_head *head = &detail->hash_table[hash]; in sunrpc_cache_find_rcu()
70 if (!detail->match(tmp, key)) in sunrpc_cache_find_rcu()
73 cache_is_expired(detail, tmp)) in sunrpc_cache_find_rcu()
99 static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail, in sunrpc_cache_add_entry() argument
104 struct hlist_head *head = &detail->hash_table[hash]; in sunrpc_cache_add_entry()
106 new = detail->alloc(); in sunrpc_cache_add_entry()
113 cache_init(new, detail); in sunrpc_cache_add_entry()
114 detail->init(new, key); in sunrpc_cache_add_entry()
116 spin_lock(&detail->hash_lock); in sunrpc_cache_add_entry()
120 lockdep_is_held(&detail->hash_lock)) { in sunrpc_cache_add_entry()
121 if (!detail->match(tmp, key)) in sunrpc_cache_add_entry()
124 cache_is_expired(detail, tmp)) { in sunrpc_cache_add_entry()
125 sunrpc_begin_cache_remove_entry(tmp, detail); in sunrpc_cache_add_entry()
126 trace_cache_entry_expired(detail, tmp); in sunrpc_cache_add_entry()
131 spin_unlock(&detail->hash_lock); in sunrpc_cache_add_entry()
132 cache_put(new, detail); in sunrpc_cache_add_entry()
137 detail->entries++; in sunrpc_cache_add_entry()
139 spin_unlock(&detail->hash_lock); in sunrpc_cache_add_entry()
142 sunrpc_end_cache_remove_entry(freeme, detail); in sunrpc_cache_add_entry()
146 struct cache_head *sunrpc_cache_lookup_rcu(struct cache_detail *detail, in sunrpc_cache_lookup_rcu() argument
151 ret = sunrpc_cache_find_rcu(detail, key, hash); in sunrpc_cache_lookup_rcu()
155 return sunrpc_cache_add_entry(detail, key, hash); in sunrpc_cache_lookup_rcu()
159 static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch);
162 struct cache_detail *detail) in cache_fresh_locked() argument
165 if (now <= detail->flush_time) in cache_fresh_locked()
167 now = detail->flush_time + 1; in cache_fresh_locked()
175 struct cache_detail *detail) in cache_fresh_unlocked() argument
179 cache_dequeue(detail, head); in cache_fresh_unlocked()
183 static void cache_make_negative(struct cache_detail *detail, in cache_make_negative() argument
187 trace_cache_entry_make_negative(detail, h); in cache_make_negative()
190 static void cache_entry_update(struct cache_detail *detail, in cache_entry_update() argument
195 detail->update(h, new); in cache_entry_update()
196 trace_cache_entry_update(detail, h); in cache_entry_update()
198 cache_make_negative(detail, h); in cache_entry_update()
202 struct cache_head *sunrpc_cache_update(struct cache_detail *detail, in sunrpc_cache_update() argument
212 spin_lock(&detail->hash_lock); in sunrpc_cache_update()
214 cache_entry_update(detail, old, new); in sunrpc_cache_update()
215 cache_fresh_locked(old, new->expiry_time, detail); in sunrpc_cache_update()
216 spin_unlock(&detail->hash_lock); in sunrpc_cache_update()
217 cache_fresh_unlocked(old, detail); in sunrpc_cache_update()
220 spin_unlock(&detail->hash_lock); in sunrpc_cache_update()
223 tmp = detail->alloc(); in sunrpc_cache_update()
225 cache_put(old, detail); in sunrpc_cache_update()
228 cache_init(tmp, detail); in sunrpc_cache_update()
229 detail->init(tmp, old); in sunrpc_cache_update()
231 spin_lock(&detail->hash_lock); in sunrpc_cache_update()
232 cache_entry_update(detail, tmp, new); in sunrpc_cache_update()
233 hlist_add_head(&tmp->cache_list, &detail->hash_table[hash]); in sunrpc_cache_update()
234 detail->entries++; in sunrpc_cache_update()
236 cache_fresh_locked(tmp, new->expiry_time, detail); in sunrpc_cache_update()
237 cache_fresh_locked(old, 0, detail); in sunrpc_cache_update()
238 spin_unlock(&detail->hash_lock); in sunrpc_cache_update()
239 cache_fresh_unlocked(tmp, detail); in sunrpc_cache_update()
240 cache_fresh_unlocked(old, detail); in sunrpc_cache_update()
241 cache_put(old, detail); in sunrpc_cache_update()
267 static int try_to_negate_entry(struct cache_detail *detail, struct cache_head *h) in try_to_negate_entry() argument
271 spin_lock(&detail->hash_lock); in try_to_negate_entry()
274 cache_make_negative(detail, h); in try_to_negate_entry()
276 detail); in try_to_negate_entry()
279 spin_unlock(&detail->hash_lock); in try_to_negate_entry()
280 cache_fresh_unlocked(h, detail); in try_to_negate_entry()
298 int cache_check(struct cache_detail *detail, in cache_check() argument
318 switch (detail->cache_upcall(detail, h)) { in cache_check()
320 rv = try_to_negate_entry(detail, h); in cache_check()
323 cache_fresh_unlocked(h, detail); in cache_check()
340 cache_put(h, detail); in cache_check()
531 void cache_purge(struct cache_detail *detail) in cache_purge() argument
537 spin_lock(&detail->hash_lock); in cache_purge()
538 if (!detail->entries) { in cache_purge()
539 spin_unlock(&detail->hash_lock); in cache_purge()
543 dprintk("RPC: %d entries in %s cache\n", detail->entries, detail->name); in cache_purge()
544 for (i = 0; i < detail->hash_size; i++) { in cache_purge()
545 head = &detail->hash_table[i]; in cache_purge()
549 sunrpc_begin_cache_remove_entry(ch, detail); in cache_purge()
550 spin_unlock(&detail->hash_lock); in cache_purge()
551 sunrpc_end_cache_remove_entry(ch, detail); in cache_purge()
552 spin_lock(&detail->hash_lock); in cache_purge()
555 spin_unlock(&detail->hash_lock); in cache_purge()
814 static int cache_request(struct cache_detail *detail, in cache_request() argument
820 detail->cache_request(detail, crq->item, &bp, &len); in cache_request()
1084 static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch) in cache_dequeue() argument
1092 list_for_each_entry_safe(cq, tmp, &detail->queue, list) in cache_dequeue()
1108 cache_put(cr->item, detail); in cache_dequeue()
1173 static void warn_no_listener(struct cache_detail *detail) in warn_no_listener() argument
1175 if (detail->last_warn != detail->last_close) { in warn_no_listener()
1176 detail->last_warn = detail->last_close; in warn_no_listener()
1177 if (detail->warn_no_listener) in warn_no_listener()
1178 detail->warn_no_listener(detail, detail->last_close != 0); in warn_no_listener()
1182 static bool cache_listeners_exist(struct cache_detail *detail) in cache_listeners_exist() argument
1184 if (atomic_read(&detail->writers)) in cache_listeners_exist()
1186 if (detail->last_close == 0) in cache_listeners_exist()
1189 if (detail->last_close < seconds_since_boot() - 30) in cache_listeners_exist()
1205 static int cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h) in cache_pipe_upcall() argument
1232 list_add_tail(&crq->q.list, &detail->queue); in cache_pipe_upcall()
1233 trace_cache_entry_upcall(detail, h); in cache_pipe_upcall()
1246 int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h) in sunrpc_cache_pipe_upcall() argument
1250 return cache_pipe_upcall(detail, h); in sunrpc_cache_pipe_upcall()
1254 int sunrpc_cache_pipe_upcall_timeout(struct cache_detail *detail, in sunrpc_cache_pipe_upcall_timeout() argument
1257 if (!cache_listeners_exist(detail)) { in sunrpc_cache_pipe_upcall_timeout()
1258 warn_no_listener(detail); in sunrpc_cache_pipe_upcall_timeout()
1259 trace_cache_entry_no_listener(detail, h); in sunrpc_cache_pipe_upcall_timeout()
1262 return sunrpc_cache_pipe_upcall(detail, h); in sunrpc_cache_pipe_upcall_timeout()