Lines Matching refs:rqstp
31 static int svc_deferred_recv(struct svc_rqst *rqstp);
380 * Copy the local and remote xprt addresses to the rqstp structure
382 void svc_xprt_copy_addrs(struct svc_rqst *rqstp, struct svc_xprt *xprt)
384 memcpy(&rqstp->rq_addr, &xprt->xpt_remote, xprt->xpt_remotelen);
385 rqstp->rq_addrlen = xprt->xpt_remotelen;
391 memcpy(&rqstp->rq_daddr, &xprt->xpt_local, xprt->xpt_locallen);
392 rqstp->rq_daddrlen = xprt->xpt_locallen;
398 * @rqstp: svc_rqst struct containing address to print
403 char *svc_print_addr(struct svc_rqst *rqstp, char *buf, size_t len)
405 return __svc_print_addr(svc_addr(rqstp), buf, len);
417 static bool svc_xprt_reserve_slot(struct svc_rqst *rqstp, struct svc_xprt *xprt)
419 if (!test_bit(RQ_DATA, &rqstp->rq_flags)) {
423 set_bit(RQ_DATA, &rqstp->rq_flags);
428 static void svc_xprt_release_slot(struct svc_rqst *rqstp)
430 struct svc_xprt *xprt = rqstp->rq_xprt;
431 if (test_and_clear_bit(RQ_DATA, &rqstp->rq_flags)) {
512 * @rqstp: The request in question
520 void svc_reserve(struct svc_rqst *rqstp, int space)
522 struct svc_xprt *xprt = rqstp->rq_xprt;
524 space += rqstp->rq_res.head[0].iov_len;
526 if (xprt && space < rqstp->rq_reserved) {
527 atomic_sub((rqstp->rq_reserved - space), &xprt->xpt_reserved);
528 rqstp->rq_reserved = space;
544 static void svc_xprt_release(struct svc_rqst *rqstp)
546 struct svc_xprt *xprt = rqstp->rq_xprt;
548 xprt->xpt_ops->xpo_release_ctxt(xprt, rqstp->rq_xprt_ctxt);
549 rqstp->rq_xprt_ctxt = NULL;
551 free_deferred(xprt, rqstp->rq_deferred);
552 rqstp->rq_deferred = NULL;
554 svc_rqst_release_pages(rqstp);
555 rqstp->rq_res.page_len = 0;
556 rqstp->rq_res.page_base = 0;
563 if ((rqstp->rq_res.len) > rqstp->rq_reserved)
565 rqstp->rq_reserved,
566 rqstp->rq_res.len);
568 rqstp->rq_res.head[0].iov_len = 0;
569 svc_reserve(rqstp, 0);
570 svc_xprt_release_slot(rqstp);
571 rqstp->rq_xprt = NULL;
652 static bool svc_alloc_arg(struct svc_rqst *rqstp)
654 struct svc_serv *serv = rqstp->rq_server;
655 struct xdr_buf *arg = &rqstp->rq_arg;
667 ret = alloc_pages_bulk(GFP_KERNEL, pages, rqstp->rq_pages);
673 if (svc_thread_should_stop(rqstp)) {
680 rqstp->rq_page_end = &rqstp->rq_pages[pages];
681 rqstp->rq_pages[pages] = NULL; /* this might be seen in nfsd_splice_actor() */
684 arg->head[0].iov_base = page_address(rqstp->rq_pages[0]);
686 arg->pages = rqstp->rq_pages + 1;
693 rqstp->rq_xid = xdr_zero;
698 svc_thread_should_sleep(struct svc_rqst *rqstp)
700 struct svc_pool *pool = rqstp->rq_pool;
711 if (svc_thread_should_stop(rqstp))
715 if (svc_is_backchannel(rqstp)) {
716 if (!lwq_empty(&rqstp->rq_server->sv_cb_list))
724 static void svc_thread_wait_for_work(struct svc_rqst *rqstp)
726 struct svc_pool *pool = rqstp->rq_pool;
728 if (svc_thread_should_sleep(rqstp)) {
730 llist_add(&rqstp->rq_idle, &pool->sp_idle_threads);
731 if (likely(svc_thread_should_sleep(rqstp)))
735 &rqstp->rq_idle)) {
737 * handle it after removing rqstp from the idle
770 static void svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
772 struct svc_serv *serv = rqstp->rq_server;
802 } else if (svc_xprt_reserve_slot(rqstp, xprt)) {
804 rqstp->rq_deferred = svc_deferred_dequeue(xprt);
805 if (rqstp->rq_deferred)
806 len = svc_deferred_recv(rqstp);
808 len = xprt->xpt_ops->xpo_recvfrom(rqstp);
809 rqstp->rq_reserved = serv->sv_max_mesg;
810 atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved);
814 trace_svc_xdr_recvfrom(&rqstp->rq_arg);
818 rqstp->rq_chandle.defer = svc_defer;
822 percpu_counter_inc(&rqstp->rq_pool->sp_messages_arrived);
823 rqstp->rq_stime = ktime_get();
824 svc_process(rqstp);
829 rqstp->rq_res.len = 0;
830 svc_xprt_release(rqstp);
833 static void svc_thread_wake_next(struct svc_rqst *rqstp)
835 if (!svc_thread_should_sleep(rqstp))
839 svc_pool_wake_idle_thread(rqstp->rq_pool);
844 * @rqstp: an idle RPC service thread
850 void svc_recv(struct svc_rqst *rqstp)
852 struct svc_pool *pool = rqstp->rq_pool;
854 if (!svc_alloc_arg(rqstp))
857 svc_thread_wait_for_work(rqstp);
861 if (svc_thread_should_stop(rqstp)) {
862 svc_thread_wake_next(rqstp);
866 rqstp->rq_xprt = svc_xprt_dequeue(pool);
867 if (rqstp->rq_xprt) {
868 struct svc_xprt *xprt = rqstp->rq_xprt;
870 svc_thread_wake_next(rqstp);
876 rqstp->rq_chandle.thread_wait = 5 * HZ;
878 rqstp->rq_chandle.thread_wait = 1 * HZ;
880 trace_svc_xprt_dequeue(rqstp);
881 svc_handle_xprt(rqstp, xprt);
885 if (svc_is_backchannel(rqstp)) {
886 struct svc_serv *serv = rqstp->rq_server;
892 svc_thread_wake_next(rqstp);
893 svc_process_bc(req, rqstp);
902 * @rqstp: RPC transaction context
905 void svc_send(struct svc_rqst *rqstp)
911 xprt = rqstp->rq_xprt;
914 xb = &rqstp->rq_res;
918 trace_svc_xdr_sendto(rqstp->rq_xid, xb);
919 trace_svc_stats_latency(rqstp);
921 status = xprt->xpt_ops->xpo_sendto(rqstp);
923 trace_svc_send(rqstp, status);
1175 struct svc_rqst *rqstp = container_of(req, struct svc_rqst, rq_chandle);
1178 if (rqstp->rq_arg.page_len || !test_bit(RQ_USEDEFERRAL, &rqstp->rq_flags))
1180 if (rqstp->rq_deferred) {
1181 dr = rqstp->rq_deferred;
1182 rqstp->rq_deferred = NULL;
1187 size = sizeof(struct svc_deferred_req) + rqstp->rq_arg.len;
1192 dr->handle.owner = rqstp->rq_server;
1193 dr->prot = rqstp->rq_prot;
1194 memcpy(&dr->addr, &rqstp->rq_addr, rqstp->rq_addrlen);
1195 dr->addrlen = rqstp->rq_addrlen;
1196 dr->daddr = rqstp->rq_daddr;
1197 dr->argslen = rqstp->rq_arg.len >> 2;
1200 skip = rqstp->rq_arg.len - rqstp->rq_arg.head[0].iov_len;
1201 memcpy(dr->args, rqstp->rq_arg.head[0].iov_base - skip,
1204 dr->xprt_ctxt = rqstp->rq_xprt_ctxt;
1205 rqstp->rq_xprt_ctxt = NULL;
1206 trace_svc_defer(rqstp);
1207 svc_xprt_get(rqstp->rq_xprt);
1208 dr->xprt = rqstp->rq_xprt;
1209 set_bit(RQ_DROPME, &rqstp->rq_flags);
1218 static noinline int svc_deferred_recv(struct svc_rqst *rqstp)
1220 struct svc_deferred_req *dr = rqstp->rq_deferred;
1225 rqstp->rq_arg.head[0].iov_base = dr->args;
1227 rqstp->rq_arg.head[0].iov_len = dr->argslen << 2;
1228 rqstp->rq_arg.page_len = 0;
1230 rqstp->rq_arg.len = dr->argslen << 2;
1231 rqstp->rq_prot = dr->prot;
1232 memcpy(&rqstp->rq_addr, &dr->addr, dr->addrlen);
1233 rqstp->rq_addrlen = dr->addrlen;
1235 rqstp->rq_daddr = dr->daddr;
1236 rqstp->rq_respages = rqstp->rq_pages;
1237 rqstp->rq_xprt_ctxt = dr->xprt_ctxt;
1240 svc_xprt_received(rqstp->rq_xprt);