Lines Matching refs:rp

91 	struct nfsd_cacherep *rp;  in nfsd_cacherep_alloc()  local
93 rp = kmem_cache_alloc(drc_slab, GFP_KERNEL); in nfsd_cacherep_alloc()
94 if (rp) { in nfsd_cacherep_alloc()
95 rp->c_state = RC_UNUSED; in nfsd_cacherep_alloc()
96 rp->c_type = RC_NOCACHE; in nfsd_cacherep_alloc()
97 RB_CLEAR_NODE(&rp->c_node); in nfsd_cacherep_alloc()
98 INIT_LIST_HEAD(&rp->c_lru); in nfsd_cacherep_alloc()
100 memset(&rp->c_key, 0, sizeof(rp->c_key)); in nfsd_cacherep_alloc()
101 rp->c_key.k_xid = rqstp->rq_xid; in nfsd_cacherep_alloc()
102 rp->c_key.k_proc = rqstp->rq_proc; in nfsd_cacherep_alloc()
103 rpc_copy_addr((struct sockaddr *)&rp->c_key.k_addr, svc_addr(rqstp)); in nfsd_cacherep_alloc()
104 rpc_set_port((struct sockaddr *)&rp->c_key.k_addr, rpc_get_port(svc_addr(rqstp))); in nfsd_cacherep_alloc()
105 rp->c_key.k_prot = rqstp->rq_prot; in nfsd_cacherep_alloc()
106 rp->c_key.k_vers = rqstp->rq_vers; in nfsd_cacherep_alloc()
107 rp->c_key.k_len = rqstp->rq_arg.len; in nfsd_cacherep_alloc()
108 rp->c_key.k_csum = csum; in nfsd_cacherep_alloc()
110 return rp; in nfsd_cacherep_alloc()
113 static void nfsd_cacherep_free(struct nfsd_cacherep *rp) in nfsd_cacherep_free() argument
115 if (rp->c_type == RC_REPLBUFF) in nfsd_cacherep_free()
116 kfree(rp->c_replvec.iov_base); in nfsd_cacherep_free()
117 kmem_cache_free(drc_slab, rp); in nfsd_cacherep_free()
123 struct nfsd_cacherep *rp; in nfsd_cacherep_dispose() local
127 rp = list_first_entry(dispose, struct nfsd_cacherep, c_lru); in nfsd_cacherep_dispose()
128 list_del(&rp->c_lru); in nfsd_cacherep_dispose()
129 nfsd_cacherep_free(rp); in nfsd_cacherep_dispose()
137 struct nfsd_cacherep *rp) in nfsd_cacherep_unlink_locked() argument
139 if (rp->c_type == RC_REPLBUFF && rp->c_replvec.iov_base) in nfsd_cacherep_unlink_locked()
140 nfsd_stats_drc_mem_usage_sub(nn, rp->c_replvec.iov_len); in nfsd_cacherep_unlink_locked()
141 if (rp->c_state != RC_UNUSED) { in nfsd_cacherep_unlink_locked()
142 rb_erase(&rp->c_node, &b->rb_head); in nfsd_cacherep_unlink_locked()
143 list_del(&rp->c_lru); in nfsd_cacherep_unlink_locked()
145 nfsd_stats_drc_mem_usage_sub(nn, sizeof(*rp)); in nfsd_cacherep_unlink_locked()
150 nfsd_reply_cache_free_locked(struct nfsd_drc_bucket *b, struct nfsd_cacherep *rp, in nfsd_reply_cache_free_locked() argument
153 nfsd_cacherep_unlink_locked(nn, b, rp); in nfsd_reply_cache_free_locked()
154 nfsd_cacherep_free(rp); in nfsd_reply_cache_free_locked()
158 nfsd_reply_cache_free(struct nfsd_drc_bucket *b, struct nfsd_cacherep *rp, in nfsd_reply_cache_free() argument
162 nfsd_cacherep_unlink_locked(nn, b, rp); in nfsd_reply_cache_free()
164 nfsd_cacherep_free(rp); in nfsd_reply_cache_free()
220 struct nfsd_cacherep *rp; in nfsd_reply_cache_shutdown() local
228 rp = list_first_entry(head, struct nfsd_cacherep, c_lru); in nfsd_reply_cache_shutdown()
230 rp, nn); in nfsd_reply_cache_shutdown()
245 lru_put_end(struct nfsd_drc_bucket *b, struct nfsd_cacherep *rp) in lru_put_end() argument
247 rp->c_timestamp = jiffies; in lru_put_end()
248 list_move_tail(&rp->c_lru, &b->lru_head); in lru_put_end()
268 struct nfsd_cacherep *rp, *tmp; in nfsd_prune_bucket_locked() local
274 list_for_each_entry_safe(rp, tmp, &b->lru_head, c_lru) { in nfsd_prune_bucket_locked()
279 if (rp->c_state == RC_INPROG) in nfsd_prune_bucket_locked()
283 time_before(expiry, rp->c_timestamp)) in nfsd_prune_bucket_locked()
286 nfsd_cacherep_unlink_locked(nn, b, rp); in nfsd_prune_bucket_locked()
287 list_add(&rp->c_lru, dispose); in nfsd_prune_bucket_locked()
402 const struct nfsd_cacherep *rp, struct nfsd_net *nn) in nfsd_cache_key_cmp() argument
404 if (key->c_key.k_xid == rp->c_key.k_xid && in nfsd_cache_key_cmp()
405 key->c_key.k_csum != rp->c_key.k_csum) { in nfsd_cache_key_cmp()
407 trace_nfsd_drc_mismatch(nn, key, rp); in nfsd_cache_key_cmp()
410 return memcmp(&key->c_key, &rp->c_key, sizeof(key->c_key)); in nfsd_cache_key_cmp()
422 struct nfsd_cacherep *rp, *ret = key; in nfsd_cache_insert() local
431 rp = rb_entry(parent, struct nfsd_cacherep, c_node); in nfsd_cache_insert()
433 cmp = nfsd_cache_key_cmp(key, rp, nn); in nfsd_cache_insert()
439 ret = rp; in nfsd_cache_insert()
483 struct nfsd_cacherep *rp, *found; in nfsd_cache_lookup() local
501 rp = nfsd_cacherep_alloc(rqstp, csum, nn); in nfsd_cache_lookup()
502 if (!rp) in nfsd_cache_lookup()
507 found = nfsd_cache_insert(b, rp, nn); in nfsd_cache_lookup()
508 if (found != rp) in nfsd_cache_lookup()
510 *cacherep = rp; in nfsd_cache_lookup()
511 rp->c_state = RC_INPROG; 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()
527 rp = found; in nfsd_cache_lookup()
530 if (rp->c_state == RC_INPROG) in nfsd_cache_lookup()
536 if (!test_bit(RQ_SECURE, &rqstp->rq_flags) && rp->c_secure) in nfsd_cache_lookup()
540 switch (rp->c_type) { in nfsd_cache_lookup()
544 xdr_stream_encode_be32(&rqstp->rq_res_stream, rp->c_replstat); in nfsd_cache_lookup()
548 if (!nfsd_cache_append(rqstp, &rp->c_replvec)) in nfsd_cache_lookup()
553 WARN_ONCE(1, "nfsd: bad repcache type %d\n", rp->c_type); in nfsd_cache_lookup()
585 void nfsd_cache_update(struct svc_rqst *rqstp, struct nfsd_cacherep *rp, in nfsd_cache_update() argument
594 if (!rp) in nfsd_cache_update()
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()
612 rp->c_replstat = *statp; in nfsd_cache_update()
615 cachv = &rp->c_replvec; 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()
631 lru_put_end(b, rp); in nfsd_cache_update()
632 rp->c_secure = test_bit(RQ_SECURE, &rqstp->rq_flags); in nfsd_cache_update()
633 rp->c_type = cachetype; in nfsd_cache_update()
634 rp->c_state = RC_DONE; in nfsd_cache_update()