Lines Matching refs:nn
89 struct nfsd_net *nn) in nfsd_cacherep_alloc() argument
136 nfsd_cacherep_unlink_locked(struct nfsd_net *nn, struct nfsd_drc_bucket *b, in nfsd_cacherep_unlink_locked() argument
140 nfsd_stats_drc_mem_usage_sub(nn, rp->c_replvec.iov_len); in nfsd_cacherep_unlink_locked()
144 atomic_dec(&nn->num_drc_entries); in nfsd_cacherep_unlink_locked()
145 nfsd_stats_drc_mem_usage_sub(nn, sizeof(*rp)); in nfsd_cacherep_unlink_locked()
151 struct nfsd_net *nn) in nfsd_reply_cache_free_locked() argument
153 nfsd_cacherep_unlink_locked(nn, b, rp); in nfsd_reply_cache_free_locked()
159 struct nfsd_net *nn) in nfsd_reply_cache_free() argument
162 nfsd_cacherep_unlink_locked(nn, b, rp); in nfsd_reply_cache_free()
178 int nfsd_reply_cache_init(struct nfsd_net *nn) in nfsd_reply_cache_init() argument
183 nn->max_drc_entries = nfsd_cache_size_limit(); in nfsd_reply_cache_init()
184 atomic_set(&nn->num_drc_entries, 0); in nfsd_reply_cache_init()
185 hashsize = nfsd_hashsize(nn->max_drc_entries); in nfsd_reply_cache_init()
186 nn->maskbits = ilog2(hashsize); in nfsd_reply_cache_init()
188 nn->drc_hashtbl = kvzalloc(array_size(hashsize, in nfsd_reply_cache_init()
189 sizeof(*nn->drc_hashtbl)), GFP_KERNEL); in nfsd_reply_cache_init()
190 if (!nn->drc_hashtbl) in nfsd_reply_cache_init()
193 nn->nfsd_reply_cache_shrinker = shrinker_alloc(0, "nfsd-reply:%s", in nfsd_reply_cache_init()
194 nn->nfsd_name); in nfsd_reply_cache_init()
195 if (!nn->nfsd_reply_cache_shrinker) in nfsd_reply_cache_init()
198 nn->nfsd_reply_cache_shrinker->scan_objects = nfsd_reply_cache_scan; in nfsd_reply_cache_init()
199 nn->nfsd_reply_cache_shrinker->count_objects = nfsd_reply_cache_count; in nfsd_reply_cache_init()
200 nn->nfsd_reply_cache_shrinker->seeks = 1; in nfsd_reply_cache_init()
201 nn->nfsd_reply_cache_shrinker->private_data = nn; in nfsd_reply_cache_init()
203 shrinker_register(nn->nfsd_reply_cache_shrinker); in nfsd_reply_cache_init()
206 INIT_LIST_HEAD(&nn->drc_hashtbl[i].lru_head); in nfsd_reply_cache_init()
207 spin_lock_init(&nn->drc_hashtbl[i].cache_lock); in nfsd_reply_cache_init()
209 nn->drc_hashsize = hashsize; in nfsd_reply_cache_init()
213 kvfree(nn->drc_hashtbl); in nfsd_reply_cache_init()
218 void nfsd_reply_cache_shutdown(struct nfsd_net *nn) in nfsd_reply_cache_shutdown() argument
223 shrinker_free(nn->nfsd_reply_cache_shrinker); in nfsd_reply_cache_shutdown()
225 for (i = 0; i < nn->drc_hashsize; i++) { in nfsd_reply_cache_shutdown()
226 struct list_head *head = &nn->drc_hashtbl[i].lru_head; in nfsd_reply_cache_shutdown()
229 nfsd_reply_cache_free_locked(&nn->drc_hashtbl[i], in nfsd_reply_cache_shutdown()
230 rp, nn); in nfsd_reply_cache_shutdown()
234 kvfree(nn->drc_hashtbl); in nfsd_reply_cache_shutdown()
235 nn->drc_hashtbl = NULL; in nfsd_reply_cache_shutdown()
236 nn->drc_hashsize = 0; in nfsd_reply_cache_shutdown()
252 nfsd_cache_bucket_find(__be32 xid, struct nfsd_net *nn) in nfsd_cache_bucket_find() argument
254 unsigned int hash = hash_32((__force u32)xid, nn->maskbits); in nfsd_cache_bucket_find()
256 return &nn->drc_hashtbl[hash]; in nfsd_cache_bucket_find()
264 nfsd_prune_bucket_locked(struct nfsd_net *nn, struct nfsd_drc_bucket *b, in nfsd_prune_bucket_locked() argument
282 if (atomic_read(&nn->num_drc_entries) <= nn->max_drc_entries && in nfsd_prune_bucket_locked()
286 nfsd_cacherep_unlink_locked(nn, b, rp); in nfsd_prune_bucket_locked()
307 struct nfsd_net *nn = shrink->private_data; in nfsd_reply_cache_count() local
309 return atomic_read(&nn->num_drc_entries); in nfsd_reply_cache_count()
326 struct nfsd_net *nn = shrink->private_data; in nfsd_reply_cache_scan() local
331 for (i = 0; i < nn->drc_hashsize; i++) { in nfsd_reply_cache_scan()
332 struct nfsd_drc_bucket *b = &nn->drc_hashtbl[i]; in nfsd_reply_cache_scan()
338 nfsd_prune_bucket_locked(nn, b, 0, &dispose); in nfsd_reply_cache_scan()
402 const struct nfsd_cacherep *rp, struct nfsd_net *nn) in nfsd_cache_key_cmp() argument
406 nfsd_stats_payload_misses_inc(nn); in nfsd_cache_key_cmp()
407 trace_nfsd_drc_mismatch(nn, key, rp); in nfsd_cache_key_cmp()
420 struct nfsd_net *nn) in nfsd_cache_insert() argument
433 cmp = nfsd_cache_key_cmp(key, rp, nn); in nfsd_cache_insert()
447 if (entries > nn->longest_chain) { in nfsd_cache_insert()
448 nn->longest_chain = entries; in nfsd_cache_insert()
449 nn->longest_chain_cachesize = atomic_read(&nn->num_drc_entries); in nfsd_cache_insert()
450 } else if (entries == nn->longest_chain) { in nfsd_cache_insert()
452 nn->longest_chain_cachesize = min_t(unsigned int, in nfsd_cache_insert()
453 nn->longest_chain_cachesize, in nfsd_cache_insert()
454 atomic_read(&nn->num_drc_entries)); in nfsd_cache_insert()
482 struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); in nfsd_cache_lookup() local
491 nfsd_stats_rc_nocache_inc(nn); in nfsd_cache_lookup()
501 rp = nfsd_cacherep_alloc(rqstp, csum, nn); in nfsd_cache_lookup()
505 b = nfsd_cache_bucket_find(rqstp->rq_xid, nn); in nfsd_cache_lookup()
507 found = nfsd_cache_insert(b, rp, nn); in nfsd_cache_lookup()
512 nfsd_prune_bucket_locked(nn, b, 3, &dispose); in nfsd_cache_lookup()
517 nfsd_stats_rc_misses_inc(nn); in nfsd_cache_lookup()
518 atomic_inc(&nn->num_drc_entries); in nfsd_cache_lookup()
519 nfsd_stats_drc_mem_usage_add(nn, sizeof(*rp)); in nfsd_cache_lookup()
524 nfsd_reply_cache_free_locked(NULL, rp, nn); in nfsd_cache_lookup()
525 nfsd_stats_rc_hits_inc(nn); in nfsd_cache_lookup()
557 trace_nfsd_drc_found(nn, rqstp, rtn); in nfsd_cache_lookup()
588 struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); in nfsd_cache_update() local
597 b = nfsd_cache_bucket_find(rp->c_key.k_xid, nn); in nfsd_cache_update()
604 nfsd_reply_cache_free(b, rp, nn); in nfsd_cache_update()
619 nfsd_reply_cache_free(b, rp, nn); in nfsd_cache_update()
626 nfsd_reply_cache_free(b, rp, nn); in nfsd_cache_update()
630 nfsd_stats_drc_mem_usage_add(nn, bufsize); in nfsd_cache_update()
659 struct nfsd_net *nn = net_generic(file_inode(m->file)->i_sb->s_fs_info, in nfsd_reply_cache_stats_show() local
662 seq_printf(m, "max entries: %u\n", nn->max_drc_entries); in nfsd_reply_cache_stats_show()
664 atomic_read(&nn->num_drc_entries)); in nfsd_reply_cache_stats_show()
665 seq_printf(m, "hash buckets: %u\n", 1 << nn->maskbits); in nfsd_reply_cache_stats_show()
667 percpu_counter_sum_positive(&nn->counter[NFSD_STATS_DRC_MEM_USAGE])); in nfsd_reply_cache_stats_show()
669 percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_HITS])); in nfsd_reply_cache_stats_show()
671 percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_MISSES])); in nfsd_reply_cache_stats_show()
673 percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_NOCACHE])); in nfsd_reply_cache_stats_show()
675 percpu_counter_sum_positive(&nn->counter[NFSD_STATS_PAYLOAD_MISSES])); in nfsd_reply_cache_stats_show()
676 seq_printf(m, "longest chain len: %u\n", nn->longest_chain); in nfsd_reply_cache_stats_show()
677 seq_printf(m, "cachesize at longest: %u\n", nn->longest_chain_cachesize); in nfsd_reply_cache_stats_show()