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()
138 if (detail->nextcheck > new->expiry_time) in sunrpc_cache_add_entry()
139 detail->nextcheck = new->expiry_time + 1; in sunrpc_cache_add_entry()
141 spin_unlock(&detail->hash_lock); in sunrpc_cache_add_entry()
144 sunrpc_end_cache_remove_entry(freeme, detail); in sunrpc_cache_add_entry()
148 struct cache_head *sunrpc_cache_lookup_rcu(struct cache_detail *detail, in sunrpc_cache_lookup_rcu() argument
153 ret = sunrpc_cache_find_rcu(detail, key, hash); in sunrpc_cache_lookup_rcu()
157 return sunrpc_cache_add_entry(detail, key, hash); in sunrpc_cache_lookup_rcu()
161 static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch);
164 struct cache_detail *detail) in cache_fresh_locked() argument
167 if (now <= detail->flush_time) in cache_fresh_locked()
169 now = detail->flush_time + 1; in cache_fresh_locked()
177 struct cache_detail *detail) in cache_fresh_unlocked() argument
181 cache_dequeue(detail, head); in cache_fresh_unlocked()
185 static void cache_make_negative(struct cache_detail *detail, in cache_make_negative() argument
189 trace_cache_entry_make_negative(detail, h); in cache_make_negative()
192 static void cache_entry_update(struct cache_detail *detail, in cache_entry_update() argument
197 detail->update(h, new); in cache_entry_update()
198 trace_cache_entry_update(detail, h); in cache_entry_update()
200 cache_make_negative(detail, h); in cache_entry_update()
204 struct cache_head *sunrpc_cache_update(struct cache_detail *detail, in sunrpc_cache_update() argument
214 spin_lock(&detail->hash_lock); in sunrpc_cache_update()
216 cache_entry_update(detail, old, new); in sunrpc_cache_update()
217 cache_fresh_locked(old, new->expiry_time, detail); in sunrpc_cache_update()
218 spin_unlock(&detail->hash_lock); in sunrpc_cache_update()
219 cache_fresh_unlocked(old, detail); in sunrpc_cache_update()
222 spin_unlock(&detail->hash_lock); in sunrpc_cache_update()
225 tmp = detail->alloc(); in sunrpc_cache_update()
227 cache_put(old, detail); in sunrpc_cache_update()
230 cache_init(tmp, detail); in sunrpc_cache_update()
231 detail->init(tmp, old); in sunrpc_cache_update()
233 spin_lock(&detail->hash_lock); in sunrpc_cache_update()
234 cache_entry_update(detail, tmp, new); in sunrpc_cache_update()
235 hlist_add_head(&tmp->cache_list, &detail->hash_table[hash]); in sunrpc_cache_update()
236 detail->entries++; in sunrpc_cache_update()
238 cache_fresh_locked(tmp, new->expiry_time, detail); in sunrpc_cache_update()
239 cache_fresh_locked(old, 0, detail); in sunrpc_cache_update()
240 spin_unlock(&detail->hash_lock); in sunrpc_cache_update()
241 cache_fresh_unlocked(tmp, detail); in sunrpc_cache_update()
242 cache_fresh_unlocked(old, detail); in sunrpc_cache_update()
243 cache_put(old, detail); in sunrpc_cache_update()
269 static int try_to_negate_entry(struct cache_detail *detail, struct cache_head *h) in try_to_negate_entry() argument
273 spin_lock(&detail->hash_lock); in try_to_negate_entry()
276 cache_make_negative(detail, h); in try_to_negate_entry()
278 detail); in try_to_negate_entry()
281 spin_unlock(&detail->hash_lock); in try_to_negate_entry()
282 cache_fresh_unlocked(h, detail); in try_to_negate_entry()
286 int cache_check_rcu(struct cache_detail *detail, in cache_check_rcu() argument
306 switch (detail->cache_upcall(detail, h)) { in cache_check_rcu()
308 rv = try_to_negate_entry(detail, h); in cache_check_rcu()
311 cache_fresh_unlocked(h, detail); in cache_check_rcu()
346 int cache_check(struct cache_detail *detail, in cache_check() argument
351 rv = cache_check_rcu(detail, h, rqstp); in cache_check()
353 cache_put(h, detail); in cache_check()
543 void cache_purge(struct cache_detail *detail) in cache_purge() argument
549 spin_lock(&detail->hash_lock); in cache_purge()
550 if (!detail->entries) { in cache_purge()
551 spin_unlock(&detail->hash_lock); in cache_purge()
555 dprintk("RPC: %d entries in %s cache\n", detail->entries, detail->name); in cache_purge()
556 for (i = 0; i < detail->hash_size; i++) { in cache_purge()
557 head = &detail->hash_table[i]; in cache_purge()
561 sunrpc_begin_cache_remove_entry(ch, detail); in cache_purge()
562 spin_unlock(&detail->hash_lock); in cache_purge()
563 sunrpc_end_cache_remove_entry(ch, detail); in cache_purge()
564 spin_lock(&detail->hash_lock); in cache_purge()
567 spin_unlock(&detail->hash_lock); in cache_purge()
823 static int cache_request(struct cache_detail *detail, in cache_request() argument
829 detail->cache_request(detail, crq->item, &bp, &len); in cache_request()
1093 static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch) in cache_dequeue() argument
1100 list_for_each_entry_safe(cq, tmp, &detail->queue, list) in cache_dequeue()
1116 cache_put(cr->item, detail); in cache_dequeue()
1181 static void warn_no_listener(struct cache_detail *detail) in warn_no_listener() argument
1183 if (detail->last_warn != detail->last_close) { in warn_no_listener()
1184 detail->last_warn = detail->last_close; in warn_no_listener()
1185 if (detail->warn_no_listener) in warn_no_listener()
1186 detail->warn_no_listener(detail, detail->last_close != 0); in warn_no_listener()
1190 static bool cache_listeners_exist(struct cache_detail *detail) in cache_listeners_exist() argument
1192 if (atomic_read(&detail->writers)) in cache_listeners_exist()
1194 if (detail->last_close == 0) in cache_listeners_exist()
1197 if (detail->last_close < seconds_since_boot() - 30) in cache_listeners_exist()
1213 static int cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h) in cache_pipe_upcall() argument
1240 list_add_tail(&crq->q.list, &detail->queue); in cache_pipe_upcall()
1241 trace_cache_entry_upcall(detail, h); in cache_pipe_upcall()
1254 int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h) in sunrpc_cache_pipe_upcall() argument
1258 return cache_pipe_upcall(detail, h); in sunrpc_cache_pipe_upcall()
1262 int sunrpc_cache_pipe_upcall_timeout(struct cache_detail *detail, in sunrpc_cache_pipe_upcall_timeout() argument
1265 if (!cache_listeners_exist(detail)) { in sunrpc_cache_pipe_upcall_timeout()
1266 warn_no_listener(detail); in sunrpc_cache_pipe_upcall_timeout()
1267 trace_cache_entry_no_listener(detail, h); in sunrpc_cache_pipe_upcall_timeout()
1270 return sunrpc_cache_pipe_upcall(detail, h); in sunrpc_cache_pipe_upcall_timeout()