Lines Matching refs:rqstp
30 static int svc_deferred_recv(struct svc_rqst *rqstp);
344 void svc_xprt_copy_addrs(struct svc_rqst *rqstp, struct svc_xprt *xprt) in svc_xprt_copy_addrs() argument
346 memcpy(&rqstp->rq_addr, &xprt->xpt_remote, xprt->xpt_remotelen); in svc_xprt_copy_addrs()
347 rqstp->rq_addrlen = xprt->xpt_remotelen; in svc_xprt_copy_addrs()
353 memcpy(&rqstp->rq_daddr, &xprt->xpt_local, xprt->xpt_locallen); in svc_xprt_copy_addrs()
354 rqstp->rq_daddrlen = xprt->xpt_locallen; in svc_xprt_copy_addrs()
365 char *svc_print_addr(struct svc_rqst *rqstp, char *buf, size_t len) in svc_print_addr() argument
367 return __svc_print_addr(svc_addr(rqstp), buf, len); in svc_print_addr()
379 static bool svc_xprt_reserve_slot(struct svc_rqst *rqstp, struct svc_xprt *xprt) in svc_xprt_reserve_slot() argument
381 if (!test_bit(RQ_DATA, &rqstp->rq_flags)) { in svc_xprt_reserve_slot()
385 set_bit(RQ_DATA, &rqstp->rq_flags); in svc_xprt_reserve_slot()
390 static void svc_xprt_release_slot(struct svc_rqst *rqstp) in svc_xprt_release_slot() argument
392 struct svc_xprt *xprt = rqstp->rq_xprt; in svc_xprt_release_slot()
393 if (test_and_clear_bit(RQ_DATA, &rqstp->rq_flags)) { in svc_xprt_release_slot()
430 struct svc_rqst *rqstp = NULL; in svc_xprt_do_enqueue() local
456 list_for_each_entry_rcu(rqstp, &pool->sp_all_threads, rq_all) { in svc_xprt_do_enqueue()
457 if (test_and_set_bit(RQ_BUSY, &rqstp->rq_flags)) in svc_xprt_do_enqueue()
460 rqstp->rq_qtime = ktime_get(); in svc_xprt_do_enqueue()
461 wake_up_process(rqstp->rq_task); in svc_xprt_do_enqueue()
465 rqstp = NULL; in svc_xprt_do_enqueue()
469 trace_svc_xprt_do_enqueue(xprt, rqstp); in svc_xprt_do_enqueue()
518 void svc_reserve(struct svc_rqst *rqstp, int space) in svc_reserve() argument
520 struct svc_xprt *xprt = rqstp->rq_xprt; in svc_reserve()
522 space += rqstp->rq_res.head[0].iov_len; in svc_reserve()
524 if (xprt && space < rqstp->rq_reserved) { in svc_reserve()
525 atomic_sub((rqstp->rq_reserved - space), &xprt->xpt_reserved); in svc_reserve()
526 rqstp->rq_reserved = space; in svc_reserve()
533 static void svc_xprt_release(struct svc_rqst *rqstp) in svc_xprt_release() argument
535 struct svc_xprt *xprt = rqstp->rq_xprt; in svc_xprt_release()
537 xprt->xpt_ops->xpo_release_rqst(rqstp); in svc_xprt_release()
539 kfree(rqstp->rq_deferred); in svc_xprt_release()
540 rqstp->rq_deferred = NULL; in svc_xprt_release()
542 pagevec_release(&rqstp->rq_pvec); in svc_xprt_release()
543 svc_free_res_pages(rqstp); in svc_xprt_release()
544 rqstp->rq_res.page_len = 0; in svc_xprt_release()
545 rqstp->rq_res.page_base = 0; in svc_xprt_release()
552 if ((rqstp->rq_res.len) > rqstp->rq_reserved) in svc_xprt_release()
554 rqstp->rq_reserved, in svc_xprt_release()
555 rqstp->rq_res.len); in svc_xprt_release()
557 rqstp->rq_res.head[0].iov_len = 0; in svc_xprt_release()
558 svc_reserve(rqstp, 0); in svc_xprt_release()
559 svc_xprt_release_slot(rqstp); in svc_xprt_release()
560 rqstp->rq_xprt = NULL; in svc_xprt_release()
573 struct svc_rqst *rqstp; in svc_wake_up() local
579 list_for_each_entry_rcu(rqstp, &pool->sp_all_threads, rq_all) { in svc_wake_up()
581 if (test_bit(RQ_BUSY, &rqstp->rq_flags)) in svc_wake_up()
584 wake_up_process(rqstp->rq_task); in svc_wake_up()
585 trace_svc_wake_up(rqstp->rq_task->pid); in svc_wake_up()
662 static int svc_alloc_arg(struct svc_rqst *rqstp) in svc_alloc_arg() argument
664 struct svc_serv *serv = rqstp->rq_server; in svc_alloc_arg()
665 struct xdr_buf *arg = &rqstp->rq_arg; in svc_alloc_arg()
668 pagevec_init(&rqstp->rq_pvec); in svc_alloc_arg()
680 rqstp->rq_pages); in svc_alloc_arg()
693 rqstp->rq_page_end = &rqstp->rq_pages[pages]; in svc_alloc_arg()
694 rqstp->rq_pages[pages] = NULL; /* this might be seen in nfsd_splice_actor() */ in svc_alloc_arg()
697 arg->head[0].iov_base = page_address(rqstp->rq_pages[0]); in svc_alloc_arg()
699 arg->pages = rqstp->rq_pages + 1; in svc_alloc_arg()
709 rqst_should_sleep(struct svc_rqst *rqstp) in rqst_should_sleep() argument
711 struct svc_pool *pool = rqstp->rq_pool; in rqst_should_sleep()
732 static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) in svc_get_next_xprt() argument
734 struct svc_pool *pool = rqstp->rq_pool; in svc_get_next_xprt()
738 WARN_ON_ONCE(rqstp->rq_xprt); in svc_get_next_xprt()
740 rqstp->rq_xprt = svc_xprt_dequeue(pool); in svc_get_next_xprt()
741 if (rqstp->rq_xprt) in svc_get_next_xprt()
751 clear_bit(RQ_BUSY, &rqstp->rq_flags); in svc_get_next_xprt()
754 if (likely(rqst_should_sleep(rqstp))) in svc_get_next_xprt()
761 set_bit(RQ_BUSY, &rqstp->rq_flags); in svc_get_next_xprt()
763 rqstp->rq_xprt = svc_xprt_dequeue(pool); in svc_get_next_xprt()
764 if (rqstp->rq_xprt) in svc_get_next_xprt()
778 rqstp->rq_chandle.thread_wait = 5*HZ; in svc_get_next_xprt()
780 rqstp->rq_chandle.thread_wait = 1*HZ; in svc_get_next_xprt()
781 trace_svc_xprt_dequeue(rqstp); in svc_get_next_xprt()
782 return rqstp->rq_xprt; in svc_get_next_xprt()
801 static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt) in svc_handle_xprt() argument
803 struct svc_serv *serv = rqstp->rq_server; in svc_handle_xprt()
830 } else if (svc_xprt_reserve_slot(rqstp, xprt)) { in svc_handle_xprt()
833 rqstp, rqstp->rq_pool->sp_id, xprt, in svc_handle_xprt()
835 rqstp->rq_deferred = svc_deferred_dequeue(xprt); in svc_handle_xprt()
836 if (rqstp->rq_deferred) in svc_handle_xprt()
837 len = svc_deferred_recv(rqstp); in svc_handle_xprt()
839 len = xprt->xpt_ops->xpo_recvfrom(rqstp); in svc_handle_xprt()
840 rqstp->rq_stime = ktime_get(); in svc_handle_xprt()
841 rqstp->rq_reserved = serv->sv_max_mesg; in svc_handle_xprt()
842 atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved); in svc_handle_xprt()
855 int svc_recv(struct svc_rqst *rqstp, long timeout) in svc_recv() argument
858 struct svc_serv *serv = rqstp->rq_server; in svc_recv()
861 err = svc_alloc_arg(rqstp); in svc_recv()
871 xprt = svc_get_next_xprt(rqstp, timeout); in svc_recv()
877 len = svc_handle_xprt(rqstp, xprt); in svc_recv()
883 trace_svc_xdr_recvfrom(&rqstp->rq_arg); in svc_recv()
887 xprt->xpt_ops->xpo_secure_port(rqstp); in svc_recv()
888 rqstp->rq_chandle.defer = svc_defer; in svc_recv()
889 rqstp->rq_xid = svc_getu32(&rqstp->rq_arg.head[0]); in svc_recv()
895 rqstp->rq_res.len = 0; in svc_recv()
896 svc_xprt_release(rqstp); in svc_recv()
905 void svc_drop(struct svc_rqst *rqstp) in svc_drop() argument
907 trace_svc_drop(rqstp); in svc_drop()
908 svc_xprt_release(rqstp); in svc_drop()
915 int svc_send(struct svc_rqst *rqstp) in svc_send() argument
921 xprt = rqstp->rq_xprt; in svc_send()
926 xb = &rqstp->rq_res; in svc_send()
930 trace_svc_xdr_sendto(rqstp->rq_xid, xb); in svc_send()
931 trace_svc_stats_latency(rqstp); in svc_send()
933 len = xprt->xpt_ops->xpo_sendto(rqstp); in svc_send()
935 trace_svc_send(rqstp, len); in svc_send()
936 svc_xprt_release(rqstp); in svc_send()
1193 struct svc_rqst *rqstp = container_of(req, struct svc_rqst, rq_chandle); in svc_defer() local
1196 if (rqstp->rq_arg.page_len || !test_bit(RQ_USEDEFERRAL, &rqstp->rq_flags)) in svc_defer()
1198 if (rqstp->rq_deferred) { in svc_defer()
1199 dr = rqstp->rq_deferred; in svc_defer()
1200 rqstp->rq_deferred = NULL; in svc_defer()
1205 size = sizeof(struct svc_deferred_req) + rqstp->rq_arg.len; in svc_defer()
1210 dr->handle.owner = rqstp->rq_server; in svc_defer()
1211 dr->prot = rqstp->rq_prot; in svc_defer()
1212 memcpy(&dr->addr, &rqstp->rq_addr, rqstp->rq_addrlen); in svc_defer()
1213 dr->addrlen = rqstp->rq_addrlen; in svc_defer()
1214 dr->daddr = rqstp->rq_daddr; in svc_defer()
1215 dr->argslen = rqstp->rq_arg.len >> 2; in svc_defer()
1216 dr->xprt_hlen = rqstp->rq_xprt_hlen; in svc_defer()
1219 skip = rqstp->rq_arg.len - rqstp->rq_arg.head[0].iov_len; in svc_defer()
1220 memcpy(dr->args, rqstp->rq_arg.head[0].iov_base - skip, in svc_defer()
1223 trace_svc_defer(rqstp); in svc_defer()
1224 svc_xprt_get(rqstp->rq_xprt); in svc_defer()
1225 dr->xprt = rqstp->rq_xprt; in svc_defer()
1226 set_bit(RQ_DROPME, &rqstp->rq_flags); in svc_defer()
1235 static noinline int svc_deferred_recv(struct svc_rqst *rqstp) in svc_deferred_recv() argument
1237 struct svc_deferred_req *dr = rqstp->rq_deferred; in svc_deferred_recv()
1242 rqstp->rq_arg.head[0].iov_base = dr->args + (dr->xprt_hlen>>2); in svc_deferred_recv()
1244 rqstp->rq_arg.head[0].iov_len = (dr->argslen<<2) - dr->xprt_hlen; in svc_deferred_recv()
1245 rqstp->rq_arg.page_len = 0; in svc_deferred_recv()
1247 rqstp->rq_arg.len = dr->argslen<<2; in svc_deferred_recv()
1248 rqstp->rq_prot = dr->prot; in svc_deferred_recv()
1249 memcpy(&rqstp->rq_addr, &dr->addr, dr->addrlen); in svc_deferred_recv()
1250 rqstp->rq_addrlen = dr->addrlen; in svc_deferred_recv()
1252 rqstp->rq_xprt_hlen = dr->xprt_hlen; in svc_deferred_recv()
1253 rqstp->rq_daddr = dr->daddr; in svc_deferred_recv()
1254 rqstp->rq_respages = rqstp->rq_pages; in svc_deferred_recv()
1255 svc_xprt_received(rqstp->rq_xprt); in svc_deferred_recv()