View | Details | Raw Unified | Return to bug 219549
Collapse All | Expand All

(-)sys/fs/nfsserver/nfs_nfsdstate.c (-4 / +6 lines)
Lines 644-651 nfsrv_getclient(nfsquad_t clientid, int Link Here
644
				cbprogram, NFSV4_CBVERS);
644
				cbprogram, NFSV4_CBVERS);
645
			    if (clp->lc_req.nr_client != NULL) {
645
			    if (clp->lc_req.nr_client != NULL) {
646
				SVC_ACQUIRE(nd->nd_xprt);
646
				SVC_ACQUIRE(nd->nd_xprt);
647
				nd->nd_xprt->xp_p2 =
647
				mtx_lock(&nd->nd_xprt->xp_p2lock);
648
				    clp->lc_req.nr_client->cl_private;
648
				nd->nd_xprt->xp_p2 = clp->lc_req.nr_client;
649
				mtx_unlock(&nd->nd_xprt->xp_p2lock);
649
				/* Disable idle timeout. */
650
				/* Disable idle timeout. */
650
				nd->nd_xprt->xp_idletimeout = 0;
651
				nd->nd_xprt->xp_idletimeout = 0;
651
				nsep->sess_cbsess.nfsess_xprt = nd->nd_xprt;
652
				nsep->sess_cbsess.nfsess_xprt = nd->nd_xprt;
Lines 5881-5888 nfsrv_checksequence(struct nfsrv_descrip Link Here
5881
	    (sep->sess_crflags & NFSV4CRSESS_CONNBACKCHAN) != 0) {
5882
	    (sep->sess_crflags & NFSV4CRSESS_CONNBACKCHAN) != 0) {
5882
		savxprt = sep->sess_cbsess.nfsess_xprt;
5883
		savxprt = sep->sess_cbsess.nfsess_xprt;
5883
		SVC_ACQUIRE(nd->nd_xprt);
5884
		SVC_ACQUIRE(nd->nd_xprt);
5884
		nd->nd_xprt->xp_p2 =
5885
		mtx_lock(&nd->nd_xprt->xp_p2lock);
5885
		    sep->sess_clp->lc_req.nr_client->cl_private;
5886
		nd->nd_xprt->xp_p2 = sep->sess_clp->lc_req.nr_client;
5887
		mtx_unlock(&nd->nd_xprt->xp_p2lock);
5886
		nd->nd_xprt->xp_idletimeout = 0;	/* Disable timeout. */
5888
		nd->nd_xprt->xp_idletimeout = 0;	/* Disable timeout. */
5887
		sep->sess_cbsess.nfsess_xprt = nd->nd_xprt;
5889
		sep->sess_cbsess.nfsess_xprt = nd->nd_xprt;
5888
		if (savxprt != NULL)
5890
		if (savxprt != NULL)
(-)sys/rpc/clnt_bck.c (-4 / +3 lines)
Lines 299-305 call_again: Link Here
299
	/*
299
	/*
300
	 * sosend consumes mreq.
300
	 * sosend consumes mreq.
301
	 */
301
	 */
302
	sx_xlock(&xprt->xp_lock);
303
	error = sosend(xprt->xp_socket, NULL, NULL, mreq, NULL, 0, curthread);
302
	error = sosend(xprt->xp_socket, NULL, NULL, mreq, NULL, 0, curthread);
304
if (error != 0) printf("sosend=%d\n", error);
303
if (error != 0) printf("sosend=%d\n", error);
305
	mreq = NULL;
304
	mreq = NULL;
Lines 308-320 printf("emsgsize\n"); Link Here
308
		SOCKBUF_LOCK(&xprt->xp_socket->so_snd);
307
		SOCKBUF_LOCK(&xprt->xp_socket->so_snd);
309
		sbwait(&xprt->xp_socket->so_snd);
308
		sbwait(&xprt->xp_socket->so_snd);
310
		SOCKBUF_UNLOCK(&xprt->xp_socket->so_snd);
309
		SOCKBUF_UNLOCK(&xprt->xp_socket->so_snd);
311
		sx_xunlock(&xprt->xp_lock);
312
		AUTH_VALIDATE(auth, xid, NULL, NULL);
310
		AUTH_VALIDATE(auth, xid, NULL, NULL);
313
		mtx_lock(&ct->ct_lock);
311
		mtx_lock(&ct->ct_lock);
314
		TAILQ_REMOVE(&ct->ct_pending, cr, cr_link);
312
		TAILQ_REMOVE(&ct->ct_pending, cr, cr_link);
315
		goto call_again;
313
		goto call_again;
316
	}
314
	}
317
	sx_xunlock(&xprt->xp_lock);
318
315
319
	reply_msg.acpted_rply.ar_verf.oa_flavor = AUTH_NULL;
316
	reply_msg.acpted_rply.ar_verf.oa_flavor = AUTH_NULL;
320
	reply_msg.acpted_rply.ar_verf.oa_base = cr->cr_verf;
317
	reply_msg.acpted_rply.ar_verf.oa_base = cr->cr_verf;
Lines 550-559 clnt_bck_destroy(CLIENT *cl) Link Here
550
void
547
void
551
clnt_bck_svccall(void *arg, struct mbuf *mrep, uint32_t xid)
548
clnt_bck_svccall(void *arg, struct mbuf *mrep, uint32_t xid)
552
{
549
{
553
	struct ct_data *ct = (struct ct_data *)arg;
550
	CLIENT *cl = (CLIENT *)arg;
551
	struct ct_data *ct;
554
	struct ct_request *cr;
552
	struct ct_request *cr;
555
	int foundreq;
553
	int foundreq;
556
554
555
	ct = (struct ct_data *)cl->cl_private;
557
	mtx_lock(&ct->ct_lock);
556
	mtx_lock(&ct->ct_lock);
558
	ct->ct_upcallrefs++;
557
	ct->ct_upcallrefs++;
559
	/*
558
	/*
(-)sys/rpc/clnt_vc.c (-5 / +5 lines)
Lines 726-732 clnt_vc_control(CLIENT *cl, u_int reques Link Here
726
	case CLSET_BACKCHANNEL:
726
	case CLSET_BACKCHANNEL:
727
		xprt = (SVCXPRT *)info;
727
		xprt = (SVCXPRT *)info;
728
		if (ct->ct_backchannelxprt == NULL) {
728
		if (ct->ct_backchannelxprt == NULL) {
729
			xprt->xp_p2 = ct;
729
			mtx_lock(&xprt->xp_p2lock);
730
			xprt->xp_p2 = cl;
731
			mtx_unlock(&xprt->xp_p2lock);
730
			ct->ct_backchannelxprt = xprt;
732
			ct->ct_backchannelxprt = xprt;
731
		}
733
		}
732
		break;
734
		break;
Lines 804-814 clnt_vc_destroy(CLIENT *cl) Link Here
804
	xprt = ct->ct_backchannelxprt;
806
	xprt = ct->ct_backchannelxprt;
805
	ct->ct_backchannelxprt = NULL;
807
	ct->ct_backchannelxprt = NULL;
806
	if (xprt != NULL) {
808
	if (xprt != NULL) {
807
		mtx_unlock(&ct->ct_lock);	/* To avoid a LOR. */
809
		mtx_lock(&xprt->xp_p2lock);
808
		sx_xlock(&xprt->xp_lock);
809
		mtx_lock(&ct->ct_lock);
810
		xprt->xp_p2 = NULL;
810
		xprt->xp_p2 = NULL;
811
		sx_xunlock(&xprt->xp_lock);
811
		mtx_unlock(&xprt->xp_p2lock);
812
	}
812
	}
813
813
814
	if (ct->ct_socket) {
814
	if (ct->ct_socket) {
(-)sys/rpc/svc.h (+1 lines)
Lines 173-178 typedef struct __rpc_svcxprt { Link Here
173
	int		xp_upcallset;	/* socket upcall is set up */
173
	int		xp_upcallset;	/* socket upcall is set up */
174
	uint32_t	xp_snd_cnt;	/* # of bytes to send to socket */
174
	uint32_t	xp_snd_cnt;	/* # of bytes to send to socket */
175
	uint32_t	xp_snt_cnt;	/* # of bytes sent to socket */
175
	uint32_t	xp_snt_cnt;	/* # of bytes sent to socket */
176
	struct mtx	xp_p2lock;
176
#else
177
#else
177
	int		xp_fd;
178
	int		xp_fd;
178
	u_short		xp_port;	 /* associated port number */
179
	u_short		xp_port;	 /* associated port number */
(-)sys/rpc/svc_dg.c (+2 lines)
Lines 118-123 svc_dg_create(SVCPOOL *pool, struct sock Link Here
118
118
119
	xprt = svc_xprt_alloc();
119
	xprt = svc_xprt_alloc();
120
	sx_init(&xprt->xp_lock, "xprt->xp_lock");
120
	sx_init(&xprt->xp_lock, "xprt->xp_lock");
121
	mtx_init(&xprt->xp_p2lock, "xprt->xp_p2lock", NULL, MTX_DEF);
121
	xprt->xp_pool = pool;
122
	xprt->xp_pool = pool;
122
	xprt->xp_socket = so;
123
	xprt->xp_socket = so;
123
	xprt->xp_p1 = NULL;
124
	xprt->xp_p1 = NULL;
Lines 276-281 svc_dg_destroy(SVCXPRT *xprt) Link Here
276
	SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv);
277
	SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv);
277
278
278
	sx_destroy(&xprt->xp_lock);
279
	sx_destroy(&xprt->xp_lock);
280
	mtx_destroy(&xprt->xp_p2lock);
279
	if (xprt->xp_socket)
281
	if (xprt->xp_socket)
280
		(void)soclose(xprt->xp_socket);
282
		(void)soclose(xprt->xp_socket);
281
283
(-)sys/rpc/svc_vc.c (-14 / +36 lines)
Lines 163-168 svc_vc_create(SVCPOOL *pool, struct sock Link Here
163
163
164
	xprt = svc_xprt_alloc();
164
	xprt = svc_xprt_alloc();
165
	sx_init(&xprt->xp_lock, "xprt->xp_lock");
165
	sx_init(&xprt->xp_lock, "xprt->xp_lock");
166
	mtx_init(&xprt->xp_p2lock, "xprt->xp_p2lock", NULL, MTX_DEF);
166
	xprt->xp_pool = pool;
167
	xprt->xp_pool = pool;
167
	xprt->xp_socket = so;
168
	xprt->xp_socket = so;
168
	xprt->xp_p1 = NULL;
169
	xprt->xp_p1 = NULL;
Lines 192-197 svc_vc_create(SVCPOOL *pool, struct sock Link Here
192
193
193
cleanup_svc_vc_create:
194
cleanup_svc_vc_create:
194
	sx_destroy(&xprt->xp_lock);
195
	sx_destroy(&xprt->xp_lock);
196
	mtx_destroy(&xprt->xp_p2lock);
195
	svc_xprt_free(xprt);
197
	svc_xprt_free(xprt);
196
198
197
	return (NULL);
199
	return (NULL);
Lines 239-244 svc_vc_create_conn(SVCPOOL *pool, struct Link Here
239
241
240
	xprt = svc_xprt_alloc();
242
	xprt = svc_xprt_alloc();
241
	sx_init(&xprt->xp_lock, "xprt->xp_lock");
243
	sx_init(&xprt->xp_lock, "xprt->xp_lock");
244
	mtx_init(&xprt->xp_p2lock, "xprt->xp_p2lock", NULL, MTX_DEF);
242
	xprt->xp_pool = pool;
245
	xprt->xp_pool = pool;
243
	xprt->xp_socket = so;
246
	xprt->xp_socket = so;
244
	xprt->xp_p1 = cd;
247
	xprt->xp_p1 = cd;
Lines 280-285 svc_vc_create_conn(SVCPOOL *pool, struct Link Here
280
	return (xprt);
283
	return (xprt);
281
cleanup_svc_vc_create:
284
cleanup_svc_vc_create:
282
	sx_destroy(&xprt->xp_lock);
285
	sx_destroy(&xprt->xp_lock);
286
	mtx_destroy(&xprt->xp_p2lock);
283
	svc_xprt_free(xprt);
287
	svc_xprt_free(xprt);
284
	mem_free(cd, sizeof(*cd));
288
	mem_free(cd, sizeof(*cd));
285
289
Lines 300-305 svc_vc_create_backchannel(SVCPOOL *pool) Link Here
300
304
301
	xprt = svc_xprt_alloc();
305
	xprt = svc_xprt_alloc();
302
	sx_init(&xprt->xp_lock, "xprt->xp_lock");
306
	sx_init(&xprt->xp_lock, "xprt->xp_lock");
307
	mtx_init(&xprt->xp_p2lock, "xprt->xp_p2lock", NULL, MTX_DEF);
303
	xprt->xp_pool = pool;
308
	xprt->xp_pool = pool;
304
	xprt->xp_socket = NULL;
309
	xprt->xp_socket = NULL;
305
	xprt->xp_p1 = cd;
310
	xprt->xp_p1 = cd;
Lines 659-664 svc_vc_recv(SVCXPRT *xprt, struct rpc_ms Link Here
659
	XDR xdrs;
664
	XDR xdrs;
660
	int error, rcvflag;
665
	int error, rcvflag;
661
	uint32_t xid_plus_direction[2];
666
	uint32_t xid_plus_direction[2];
667
	CLIENT *cl;
662
668
663
	/*
669
	/*
664
	 * Serialise access to the socket and our own record parsing
670
	 * Serialise access to the socket and our own record parsing
Lines 682-691 svc_vc_recv(SVCXPRT *xprt, struct rpc_ms Link Here
682
			 * The XID is in the first uint32_t of the reply
688
			 * The XID is in the first uint32_t of the reply
683
			 * and the message direction is the second one.
689
			 * and the message direction is the second one.
684
			 */
690
			 */
691
			mtx_lock(&xprt->xp_p2lock);
685
			if ((cd->mreq->m_len >= sizeof(xid_plus_direction) ||
692
			if ((cd->mreq->m_len >= sizeof(xid_plus_direction) ||
686
			    m_length(cd->mreq, NULL) >=
693
			    m_length(cd->mreq, NULL) >=
687
			    sizeof(xid_plus_direction)) &&
694
			    sizeof(xid_plus_direction)) &&
688
			    xprt->xp_p2 != NULL) {
695
			    xprt->xp_p2 != NULL) {
696
				cl = (CLIENT *)xprt->xp_p2;
697
				CLNT_ACQUIRE(cl);
698
				mtx_unlock(&xprt->xp_p2lock);
689
				m_copydata(cd->mreq, 0,
699
				m_copydata(cd->mreq, 0,
690
				    sizeof(xid_plus_direction),
700
				    sizeof(xid_plus_direction),
691
				    (char *)xid_plus_direction);
701
				    (char *)xid_plus_direction);
Lines 695-707 svc_vc_recv(SVCXPRT *xprt, struct rpc_ms Link Here
695
				    ntohl(xid_plus_direction[1]);
705
				    ntohl(xid_plus_direction[1]);
696
				/* Check message direction. */
706
				/* Check message direction. */
697
				if (xid_plus_direction[1] == REPLY) {
707
				if (xid_plus_direction[1] == REPLY) {
698
					clnt_bck_svccall(xprt->xp_p2,
708
					clnt_bck_svccall(cl, cd->mreq,
699
					    cd->mreq,
700
					    xid_plus_direction[0]);
709
					    xid_plus_direction[0]);
701
					cd->mreq = NULL;
710
					cd->mreq = NULL;
711
					CLNT_RELEASE(cl);
702
					continue;
712
					continue;
703
				}
713
				}
704
			}
714
				CLNT_RELEASE(cl);
715
			} else
716
				mtx_unlock(&xprt->xp_p2lock);
705
717
706
			xdrmbuf_create(&xdrs, cd->mreq, XDR_DECODE);
718
			xdrmbuf_create(&xdrs, cd->mreq, XDR_DECODE);
707
			cd->mreq = NULL;
719
			cd->mreq = NULL;
Lines 794-820 svc_vc_backchannel_recv(SVCXPRT *xprt, s Link Here
794
    struct sockaddr **addrp, struct mbuf **mp)
806
    struct sockaddr **addrp, struct mbuf **mp)
795
{
807
{
796
	struct cf_conn *cd = (struct cf_conn *) xprt->xp_p1;
808
	struct cf_conn *cd = (struct cf_conn *) xprt->xp_p1;
809
	CLIENT *cl;
797
	struct ct_data *ct;
810
	struct ct_data *ct;
798
	struct mbuf *m;
811
	struct mbuf *m;
799
	XDR xdrs;
812
	XDR xdrs;
800
813
801
	sx_xlock(&xprt->xp_lock);
814
	mtx_lock(&xprt->xp_p2lock);
802
	ct = (struct ct_data *)xprt->xp_p2;
815
	cl = (CLIENT *)xprt->xp_p2;
803
	if (ct == NULL) {
816
	if (cl == NULL) {
804
		sx_xunlock(&xprt->xp_lock);
817
		mtx_unlock(&xprt->xp_p2lock);
805
		return (FALSE);
818
		return (FALSE);
806
	}
819
	}
820
	ct = (struct ct_data *)cl->cl_private;
821
	CLNT_ACQUIRE(cl);
822
	mtx_unlock(&xprt->xp_p2lock);
807
	mtx_lock(&ct->ct_lock);
823
	mtx_lock(&ct->ct_lock);
808
	m = cd->mreq;
824
	m = cd->mreq;
809
	if (m == NULL) {
825
	if (m == NULL) {
810
		xprt_inactive_self(xprt);
826
		xprt_inactive_self(xprt);
811
		mtx_unlock(&ct->ct_lock);
827
		mtx_unlock(&ct->ct_lock);
812
		sx_xunlock(&xprt->xp_lock);
828
		CLNT_RELEASE(cl);
813
		return (FALSE);
829
		return (FALSE);
814
	}
830
	}
815
	cd->mreq = m->m_nextpkt;
831
	cd->mreq = m->m_nextpkt;
816
	mtx_unlock(&ct->ct_lock);
832
	mtx_unlock(&ct->ct_lock);
817
	sx_xunlock(&xprt->xp_lock);
833
	CLNT_RELEASE(cl);
818
834
819
	xdrmbuf_create(&xdrs, m, XDR_DECODE);
835
	xdrmbuf_create(&xdrs, m, XDR_DECODE);
820
	if (! xdr_callmsg(&xdrs, msg)) {
836
	if (! xdr_callmsg(&xdrs, msg)) {
Lines 892-897 svc_vc_backchannel_reply(SVCXPRT *xprt, Link Here
892
	struct mbuf *mrep;
908
	struct mbuf *mrep;
893
	bool_t stat = TRUE;
909
	bool_t stat = TRUE;
894
	int error;
910
	int error;
911
	CLIENT *cl;
895
912
896
	/*
913
	/*
897
	 * Leave space for record mark.
914
	 * Leave space for record mark.
Lines 921-934 svc_vc_backchannel_reply(SVCXPRT *xprt, Link Here
921
		*mtod(mrep, uint32_t *) =
938
		*mtod(mrep, uint32_t *) =
922
			htonl(0x80000000 | (mrep->m_pkthdr.len
939
			htonl(0x80000000 | (mrep->m_pkthdr.len
923
				- sizeof(uint32_t)));
940
				- sizeof(uint32_t)));
924
		sx_xlock(&xprt->xp_lock);
941
		mtx_lock(&xprt->xp_p2lock);
925
		ct = (struct ct_data *)xprt->xp_p2;
942
		cl = (CLIENT *)xprt->xp_p2;
926
		if (ct != NULL)
943
		if (cl != NULL) {
944
			CLNT_ACQUIRE(cl);
945
			ct = (struct ct_data *)cl->cl_private;
946
			mtx_unlock(&xprt->xp_p2lock);
927
			error = sosend(ct->ct_socket, NULL, NULL, mrep, NULL,
947
			error = sosend(ct->ct_socket, NULL, NULL, mrep, NULL,
928
			    0, curthread);
948
			    0, curthread);
929
		else
949
			CLNT_RELEASE(cl);
950
		} else {
951
			mtx_unlock(&xprt->xp_p2lock);
930
			error = EPIPE;
952
			error = EPIPE;
931
		sx_xunlock(&xprt->xp_lock);
953
		}
932
		if (!error) {
954
		if (!error) {
933
			stat = TRUE;
955
			stat = TRUE;
934
		}
956
		}

Return to bug 219549