Lines Matching refs:rqstp
601 svc_init_buffer(struct svc_rqst *rqstp, unsigned int size, int node)
606 if (svc_is_backchannel(rqstp))
617 rqstp->rq_pages);
625 svc_release_buffer(struct svc_rqst *rqstp)
629 for (i = 0; i < ARRAY_SIZE(rqstp->rq_pages); i++)
630 if (rqstp->rq_pages[i])
631 put_page(rqstp->rq_pages[i]);
637 struct svc_rqst *rqstp;
639 rqstp = kzalloc_node(sizeof(*rqstp), GFP_KERNEL, node);
640 if (!rqstp)
641 return rqstp;
643 folio_batch_init(&rqstp->rq_fbatch);
645 __set_bit(RQ_BUSY, &rqstp->rq_flags);
646 rqstp->rq_server = serv;
647 rqstp->rq_pool = pool;
649 rqstp->rq_scratch_page = alloc_pages_node(node, GFP_KERNEL, 0);
650 if (!rqstp->rq_scratch_page)
653 rqstp->rq_argp = kmalloc_node(serv->sv_xdrsize, GFP_KERNEL, node);
654 if (!rqstp->rq_argp)
657 rqstp->rq_resp = kmalloc_node(serv->sv_xdrsize, GFP_KERNEL, node);
658 if (!rqstp->rq_resp)
661 if (!svc_init_buffer(rqstp, serv->sv_max_mesg, node))
664 return rqstp;
666 svc_rqst_free(rqstp);
674 struct svc_rqst *rqstp;
676 rqstp = svc_rqst_alloc(serv, pool, node);
677 if (!rqstp)
687 list_add_rcu(&rqstp->rq_all, &pool->sp_all_threads);
689 return rqstp;
703 struct svc_rqst *rqstp;
706 list_for_each_entry_rcu(rqstp, &pool->sp_all_threads, rq_all) {
707 if (test_and_set_bit(RQ_BUSY, &rqstp->rq_flags))
710 WRITE_ONCE(rqstp->rq_qtime, ktime_get());
711 wake_up_process(rqstp->rq_task);
714 trace_svc_wake_up(rqstp->rq_task->pid);
749 struct svc_rqst *rqstp;
751 rqstp = list_entry(pool->sp_all_threads.next, struct svc_rqst, rq_all);
752 set_bit(RQ_VICTIM, &rqstp->rq_flags);
753 list_del_rcu(&rqstp->rq_all);
754 task = rqstp->rq_task;
763 struct svc_rqst *rqstp;
774 rqstp = svc_prepare_thread(serv, chosen_pool, node);
775 if (IS_ERR(rqstp))
776 return PTR_ERR(rqstp);
777 task = kthread_create_on_node(serv->sv_threadfn, rqstp,
780 svc_exit_thread(rqstp);
784 rqstp->rq_task = task;
798 struct svc_rqst *rqstp;
806 rqstp = kthread_data(task);
809 svc_exit_thread(rqstp);
853 * @rqstp: svc_rqst with pages to replace
863 bool svc_rqst_replace_page(struct svc_rqst *rqstp, struct page *page)
865 struct page **begin = rqstp->rq_pages;
866 struct page **end = &rqstp->rq_pages[RPCSVC_MAXPAGES];
868 if (unlikely(rqstp->rq_next_page < begin || rqstp->rq_next_page > end)) {
869 trace_svc_replace_page_err(rqstp);
873 if (*rqstp->rq_next_page) {
874 if (!folio_batch_add(&rqstp->rq_fbatch,
875 page_folio(*rqstp->rq_next_page)))
876 __folio_batch_release(&rqstp->rq_fbatch);
880 *(rqstp->rq_next_page++) = page;
887 * @rqstp: RPC transaction context
892 void svc_rqst_release_pages(struct svc_rqst *rqstp)
894 int i, count = rqstp->rq_next_page - rqstp->rq_respages;
897 release_pages(rqstp->rq_respages, count);
899 rqstp->rq_respages[i] = NULL;
908 svc_rqst_free(struct svc_rqst *rqstp)
910 folio_batch_release(&rqstp->rq_fbatch);
911 svc_release_buffer(rqstp);
912 if (rqstp->rq_scratch_page)
913 put_page(rqstp->rq_scratch_page);
914 kfree(rqstp->rq_resp);
915 kfree(rqstp->rq_argp);
916 kfree(rqstp->rq_auth_data);
917 kfree_rcu(rqstp, rq_rcu_head);
922 svc_exit_thread(struct svc_rqst *rqstp)
924 struct svc_serv *serv = rqstp->rq_server;
925 struct svc_pool *pool = rqstp->rq_pool;
929 if (!test_and_set_bit(RQ_VICTIM, &rqstp->rq_flags))
930 list_del_rcu(&rqstp->rq_all);
938 svc_rqst_free(rqstp);
1217 void svc_printk(struct svc_rqst *rqstp, const char *fmt, ...)
1228 dprintk("svc: %s: %pV", svc_print_addr(rqstp, buf, sizeof(buf)), &vaf);
1233 static __printf(2,3) void svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) {}
1237 svc_generic_init_request(struct svc_rqst *rqstp,
1244 if (rqstp->rq_vers >= progp->pg_nvers )
1246 versp = progp->pg_vers[rqstp->rq_vers];
1261 if (versp->vs_need_cong_ctrl && rqstp->rq_xprt &&
1262 !test_bit(XPT_CONG_CTRL, &rqstp->rq_xprt->xpt_flags))
1265 if (rqstp->rq_proc >= versp->vs_nproc)
1267 rqstp->rq_procinfo = procp = &versp->vs_proc[rqstp->rq_proc];
1272 memset(rqstp->rq_argp, 0, procp->pc_argzero);
1273 memset(rqstp->rq_resp, 0, procp->pc_ressize);
1276 this_cpu_inc(versp->vs_count[rqstp->rq_proc]);
1293 svc_process_common(struct svc_rqst *rqstp)
1295 struct xdr_stream *xdr = &rqstp->rq_res_stream;
1298 struct svc_serv *serv = rqstp->rq_server;
1306 set_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
1308 set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
1309 clear_bit(RQ_DROPME, &rqstp->rq_flags);
1312 svcxdr_init_encode(rqstp);
1313 xdr_stream_encode_be32(xdr, rqstp->rq_xid);
1316 p = xdr_inline_decode(&rqstp->rq_arg_stream, XDR_UNIT * 4);
1324 rqstp->rq_prog = be32_to_cpup(p++);
1325 rqstp->rq_vers = be32_to_cpup(p++);
1326 rqstp->rq_proc = be32_to_cpup(p);
1329 if (rqstp->rq_prog == progp->pg_prog)
1337 auth_res = svc_authenticate(rqstp);
1340 auth_res = progp->pg_authenticate(rqstp);
1341 trace_svc_authenticate(rqstp, auth_res);
1365 switch (progp->pg_init_request(rqstp, progp, &process)) {
1376 procp = rqstp->rq_procinfo;
1383 trace_svc_process(rqstp, progp->pg_name);
1391 svc_reserve_auth(rqstp, procp->pc_xdrressize<<2);
1394 rc = process.dispatch(rqstp);
1396 procp->pc_release(rqstp);
1401 if (rqstp->rq_auth_stat != rpc_auth_ok)
1404 if (*rqstp->rq_accept_statp != rpc_success)
1411 if (svc_authorise(rqstp))
1416 svc_authorise(rqstp); /* doesn't hurt to call this twice */
1421 svc_authorise(rqstp);
1423 if (rqstp->rq_xprt && test_bit(XPT_TEMP, &rqstp->rq_xprt->xpt_flags))
1424 svc_xprt_close(rqstp->rq_xprt);
1429 svc_printk(rqstp, "short len %u, dropping request\n",
1430 rqstp->rq_arg.len);
1444 be32_to_cpu(rqstp->rq_auth_stat));
1450 xdr_stream_encode_be32(xdr, rqstp->rq_auth_stat);
1454 dprintk("svc: unknown program %d\n", rqstp->rq_prog);
1456 *rqstp->rq_accept_statp = rpc_prog_unavail;
1460 svc_printk(rqstp, "unknown version (%d for prog %d, %s)\n",
1461 rqstp->rq_vers, rqstp->rq_prog, progp->pg_name);
1464 *rqstp->rq_accept_statp = rpc_prog_mismatch;
1475 svc_printk(rqstp, "unknown procedure (%d)\n", rqstp->rq_proc);
1478 *rqstp->rq_accept_statp = rpc_proc_unavail;
1482 svc_printk(rqstp, "failed to decode RPC header\n");
1485 *rqstp->rq_accept_statp = rpc_garbage_args;
1490 *rqstp->rq_accept_statp = rpc_system_err;
1496 * @rqstp: RPC transaction context
1499 void svc_process(struct svc_rqst *rqstp)
1501 struct kvec *resv = &rqstp->rq_res.head[0];
1507 svc_xprt_deferred_close(rqstp->rq_xprt);
1514 rqstp->rq_next_page = &rqstp->rq_respages[1];
1515 resv->iov_base = page_address(rqstp->rq_respages[0]);
1517 rqstp->rq_res.pages = rqstp->rq_next_page;
1518 rqstp->rq_res.len = 0;
1519 rqstp->rq_res.page_base = 0;
1520 rqstp->rq_res.page_len = 0;
1521 rqstp->rq_res.buflen = PAGE_SIZE;
1522 rqstp->rq_res.tail[0].iov_base = NULL;
1523 rqstp->rq_res.tail[0].iov_len = 0;
1525 svcxdr_init_decode(rqstp);
1526 p = xdr_inline_decode(&rqstp->rq_arg_stream, XDR_UNIT * 2);
1529 rqstp->rq_xid = *p++;
1533 if (!svc_process_common(rqstp))
1535 svc_send(rqstp);
1539 svc_printk(rqstp, "bad direction 0x%08x, dropping request\n",
1541 rqstp->rq_server->sv_stats->rpcbadfmt++;
1543 svc_drop(rqstp);
1553 struct svc_rqst *rqstp)
1562 rqstp->rq_xid = req->rq_xid;
1563 rqstp->rq_prot = req->rq_xprt->prot;
1564 rqstp->rq_server = serv;
1565 rqstp->rq_bc_net = req->rq_xprt->xprt_net;
1567 rqstp->rq_addrlen = sizeof(req->rq_xprt->addr);
1568 memcpy(&rqstp->rq_addr, &req->rq_xprt->addr, rqstp->rq_addrlen);
1569 memcpy(&rqstp->rq_arg, &req->rq_rcv_buf, sizeof(rqstp->rq_arg));
1570 memcpy(&rqstp->rq_res, &req->rq_snd_buf, sizeof(rqstp->rq_res));
1573 rqstp->rq_arg.len = req->rq_private_buf.len;
1574 if (rqstp->rq_arg.len <= rqstp->rq_arg.head[0].iov_len) {
1575 rqstp->rq_arg.head[0].iov_len = rqstp->rq_arg.len;
1576 rqstp->rq_arg.page_len = 0;
1577 } else if (rqstp->rq_arg.len <= rqstp->rq_arg.head[0].iov_len +
1578 rqstp->rq_arg.page_len)
1579 rqstp->rq_arg.page_len = rqstp->rq_arg.len -
1580 rqstp->rq_arg.head[0].iov_len;
1582 rqstp->rq_arg.len = rqstp->rq_arg.head[0].iov_len +
1583 rqstp->rq_arg.page_len;
1586 rqstp->rq_res.head[0].iov_len = 0;
1592 svcxdr_init_decode(rqstp);
1593 if (!xdr_inline_decode(&rqstp->rq_arg_stream, XDR_UNIT * 2)) {
1599 proc_error = svc_process_common(rqstp);
1609 memcpy(&req->rq_snd_buf, &rqstp->rq_res, sizeof(req->rq_snd_buf));
1629 * @rqstp: RPC transaction context
1634 u32 svc_max_payload(const struct svc_rqst *rqstp)
1636 u32 max = rqstp->rq_xprt->xpt_class->xcl_max_payload;
1638 if (rqstp->rq_server->sv_max_payload < max)
1639 max = rqstp->rq_server->sv_max_payload;
1646 * @rqstp: svc_rqst to operate on
1651 const char *svc_proc_name(const struct svc_rqst *rqstp)
1653 if (rqstp && rqstp->rq_procinfo)
1654 return rqstp->rq_procinfo->pc_name;
1661 * @rqstp: svc_rqst to operate on
1662 * @offset: payload's byte offset in rqstp->rq_res
1668 int svc_encode_result_payload(struct svc_rqst *rqstp, unsigned int offset,
1671 return rqstp->rq_xprt->xpt_ops->xpo_result_payload(rqstp, offset,
1678 * @rqstp: svc_rqst to operate on
1681 * Fills in rqstp::rq_vec, and returns the number of elements.
1683 unsigned int svc_fill_write_vector(struct svc_rqst *rqstp,
1688 struct kvec *vec = rqstp->rq_vec;
1711 WARN_ON_ONCE(i > ARRAY_SIZE(rqstp->rq_vec));
1718 * @rqstp: svc_rqst to operate on
1727 char *svc_fill_symlink_pathname(struct svc_rqst *rqstp, struct kvec *first,