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()
542 static void svc_xprt_release(struct svc_rqst *rqstp) in svc_xprt_release() argument
544 struct svc_xprt *xprt = rqstp->rq_xprt; in svc_xprt_release()
546 xprt->xpt_ops->xpo_release_ctxt(xprt, rqstp->rq_xprt_ctxt); in svc_xprt_release()
547 rqstp->rq_xprt_ctxt = NULL; in svc_xprt_release()
549 free_deferred(xprt, rqstp->rq_deferred); in svc_xprt_release()
550 rqstp->rq_deferred = NULL; in svc_xprt_release()
552 pagevec_release(&rqstp->rq_pvec); in svc_xprt_release()
553 svc_free_res_pages(rqstp); in svc_xprt_release()
554 rqstp->rq_res.page_len = 0; in svc_xprt_release()
555 rqstp->rq_res.page_base = 0; in svc_xprt_release()
562 if ((rqstp->rq_res.len) > rqstp->rq_reserved) in svc_xprt_release()
564 rqstp->rq_reserved, in svc_xprt_release()
565 rqstp->rq_res.len); in svc_xprt_release()
567 rqstp->rq_res.head[0].iov_len = 0; in svc_xprt_release()
568 svc_reserve(rqstp, 0); in svc_xprt_release()
569 svc_xprt_release_slot(rqstp); in svc_xprt_release()
570 rqstp->rq_xprt = NULL; in svc_xprt_release()
583 struct svc_rqst *rqstp; in svc_wake_up() local
589 list_for_each_entry_rcu(rqstp, &pool->sp_all_threads, rq_all) { in svc_wake_up()
591 if (test_bit(RQ_BUSY, &rqstp->rq_flags)) in svc_wake_up()
594 wake_up_process(rqstp->rq_task); in svc_wake_up()
595 trace_svc_wake_up(rqstp->rq_task->pid); in svc_wake_up()
672 static int svc_alloc_arg(struct svc_rqst *rqstp) in svc_alloc_arg() argument
674 struct svc_serv *serv = rqstp->rq_server; in svc_alloc_arg()
675 struct xdr_buf *arg = &rqstp->rq_arg; in svc_alloc_arg()
678 pagevec_init(&rqstp->rq_pvec); in svc_alloc_arg()
690 rqstp->rq_pages); in svc_alloc_arg()
702 rqstp->rq_page_end = &rqstp->rq_pages[pages]; in svc_alloc_arg()
703 rqstp->rq_pages[pages] = NULL; /* this might be seen in nfsd_splice_actor() */ in svc_alloc_arg()
706 arg->head[0].iov_base = page_address(rqstp->rq_pages[0]); in svc_alloc_arg()
708 arg->pages = rqstp->rq_pages + 1; in svc_alloc_arg()
718 rqst_should_sleep(struct svc_rqst *rqstp) in rqst_should_sleep() argument
720 struct svc_pool *pool = rqstp->rq_pool; in rqst_should_sleep()
741 static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) in svc_get_next_xprt() argument
743 struct svc_pool *pool = rqstp->rq_pool; in svc_get_next_xprt()
747 WARN_ON_ONCE(rqstp->rq_xprt); in svc_get_next_xprt()
749 rqstp->rq_xprt = svc_xprt_dequeue(pool); in svc_get_next_xprt()
750 if (rqstp->rq_xprt) in svc_get_next_xprt()
760 clear_bit(RQ_BUSY, &rqstp->rq_flags); in svc_get_next_xprt()
763 if (likely(rqst_should_sleep(rqstp))) in svc_get_next_xprt()
770 set_bit(RQ_BUSY, &rqstp->rq_flags); in svc_get_next_xprt()
772 rqstp->rq_xprt = svc_xprt_dequeue(pool); in svc_get_next_xprt()
773 if (rqstp->rq_xprt) in svc_get_next_xprt()
787 rqstp->rq_chandle.thread_wait = 5*HZ; in svc_get_next_xprt()
789 rqstp->rq_chandle.thread_wait = 1*HZ; in svc_get_next_xprt()
790 trace_svc_xprt_dequeue(rqstp); in svc_get_next_xprt()
791 return rqstp->rq_xprt; in svc_get_next_xprt()
810 static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt) in svc_handle_xprt() argument
812 struct svc_serv *serv = rqstp->rq_server; in svc_handle_xprt()
839 } else if (svc_xprt_reserve_slot(rqstp, xprt)) { in svc_handle_xprt()
842 rqstp, rqstp->rq_pool->sp_id, xprt, in svc_handle_xprt()
844 rqstp->rq_deferred = svc_deferred_dequeue(xprt); in svc_handle_xprt()
845 if (rqstp->rq_deferred) in svc_handle_xprt()
846 len = svc_deferred_recv(rqstp); in svc_handle_xprt()
848 len = xprt->xpt_ops->xpo_recvfrom(rqstp); in svc_handle_xprt()
849 rqstp->rq_stime = ktime_get(); in svc_handle_xprt()
850 rqstp->rq_reserved = serv->sv_max_mesg; in svc_handle_xprt()
851 atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved); in svc_handle_xprt()
864 int svc_recv(struct svc_rqst *rqstp, long timeout) in svc_recv() argument
867 struct svc_serv *serv = rqstp->rq_server; in svc_recv()
870 err = svc_alloc_arg(rqstp); in svc_recv()
880 xprt = svc_get_next_xprt(rqstp, timeout); in svc_recv()
886 len = svc_handle_xprt(rqstp, xprt); in svc_recv()
892 trace_svc_xdr_recvfrom(&rqstp->rq_arg); in svc_recv()
896 xprt->xpt_ops->xpo_secure_port(rqstp); in svc_recv()
897 rqstp->rq_chandle.defer = svc_defer; in svc_recv()
898 rqstp->rq_xid = svc_getu32(&rqstp->rq_arg.head[0]); in svc_recv()
904 rqstp->rq_res.len = 0; in svc_recv()
905 svc_xprt_release(rqstp); in svc_recv()
914 void svc_drop(struct svc_rqst *rqstp) in svc_drop() argument
916 trace_svc_drop(rqstp); in svc_drop()
917 svc_xprt_release(rqstp); in svc_drop()
924 int svc_send(struct svc_rqst *rqstp) in svc_send() argument
930 xprt = rqstp->rq_xprt; in svc_send()
935 xb = &rqstp->rq_res; in svc_send()
939 trace_svc_xdr_sendto(rqstp->rq_xid, xb); in svc_send()
940 trace_svc_stats_latency(rqstp); in svc_send()
942 len = xprt->xpt_ops->xpo_sendto(rqstp); in svc_send()
944 trace_svc_send(rqstp, len); in svc_send()
945 svc_xprt_release(rqstp); in svc_send()
1202 struct svc_rqst *rqstp = container_of(req, struct svc_rqst, rq_chandle); in svc_defer() local
1205 if (rqstp->rq_arg.page_len || !test_bit(RQ_USEDEFERRAL, &rqstp->rq_flags)) in svc_defer()
1207 if (rqstp->rq_deferred) { in svc_defer()
1208 dr = rqstp->rq_deferred; in svc_defer()
1209 rqstp->rq_deferred = NULL; in svc_defer()
1214 size = sizeof(struct svc_deferred_req) + rqstp->rq_arg.len; in svc_defer()
1219 dr->handle.owner = rqstp->rq_server; in svc_defer()
1220 dr->prot = rqstp->rq_prot; in svc_defer()
1221 memcpy(&dr->addr, &rqstp->rq_addr, rqstp->rq_addrlen); in svc_defer()
1222 dr->addrlen = rqstp->rq_addrlen; in svc_defer()
1223 dr->daddr = rqstp->rq_daddr; in svc_defer()
1224 dr->argslen = rqstp->rq_arg.len >> 2; in svc_defer()
1227 skip = rqstp->rq_arg.len - rqstp->rq_arg.head[0].iov_len; in svc_defer()
1228 memcpy(dr->args, rqstp->rq_arg.head[0].iov_base - skip, in svc_defer()
1231 dr->xprt_ctxt = rqstp->rq_xprt_ctxt; in svc_defer()
1232 rqstp->rq_xprt_ctxt = NULL; in svc_defer()
1233 trace_svc_defer(rqstp); in svc_defer()
1234 svc_xprt_get(rqstp->rq_xprt); in svc_defer()
1235 dr->xprt = rqstp->rq_xprt; in svc_defer()
1236 set_bit(RQ_DROPME, &rqstp->rq_flags); in svc_defer()
1245 static noinline int svc_deferred_recv(struct svc_rqst *rqstp) in svc_deferred_recv() argument
1247 struct svc_deferred_req *dr = rqstp->rq_deferred; in svc_deferred_recv()
1252 rqstp->rq_arg.head[0].iov_base = dr->args; in svc_deferred_recv()
1254 rqstp->rq_arg.head[0].iov_len = dr->argslen << 2; in svc_deferred_recv()
1255 rqstp->rq_arg.page_len = 0; in svc_deferred_recv()
1257 rqstp->rq_arg.len = dr->argslen << 2; in svc_deferred_recv()
1258 rqstp->rq_prot = dr->prot; in svc_deferred_recv()
1259 memcpy(&rqstp->rq_addr, &dr->addr, dr->addrlen); in svc_deferred_recv()
1260 rqstp->rq_addrlen = dr->addrlen; in svc_deferred_recv()
1262 rqstp->rq_daddr = dr->daddr; in svc_deferred_recv()
1263 rqstp->rq_respages = rqstp->rq_pages; in svc_deferred_recv()
1264 rqstp->rq_xprt_ctxt = dr->xprt_ctxt; in svc_deferred_recv()
1267 svc_xprt_received(rqstp->rq_xprt); in svc_deferred_recv()