View | Details | Raw Unified | Return to bug 254840 | Differences between
and this patch

Collapse All | Expand All

(-)sys/fs/nfs/nfsport.h (-2 / +5 lines)
Lines 357-366 Link Here
357
#define	NFSPROC_OPENLAYGET	54
357
#define	NFSPROC_OPENLAYGET	54
358
#define	NFSPROC_CREATELAYGET	55
358
#define	NFSPROC_CREATELAYGET	55
359
359
360
/* BindConnectionToSession, done by the krpc for a new connection. */
361
#define	NFSPROC_BINDCONNTOSESS	56
362
360
/*
363
/*
361
 * Must be defined as one higher than the last NFSv4.1 Proc# above.
364
 * Must be defined as one higher than the last NFSv4.1 Proc# above.
362
 */
365
 */
363
#define	NFSV41_NPROCS		56
366
#define	NFSV41_NPROCS		57
364
367
365
#endif	/* NFS_V3NPROCS */
368
#endif	/* NFS_V3NPROCS */
366
369
Lines 389-395 struct nfsstatsv1 { Link Here
389
	uint64_t	readlink_bios;
392
	uint64_t	readlink_bios;
390
	uint64_t	biocache_readdirs;
393
	uint64_t	biocache_readdirs;
391
	uint64_t	readdir_bios;
394
	uint64_t	readdir_bios;
392
	uint64_t	rpccnt[NFSV41_NPROCS + 13];
395
	uint64_t	rpccnt[NFSV41_NPROCS + 12];
393
	uint64_t	rpcretries;
396
	uint64_t	rpcretries;
394
	uint64_t	srvrpccnt[NFSV42_NOPS + NFSV4OP_FAKENOPS];
397
	uint64_t	srvrpccnt[NFSV42_NOPS + NFSV4OP_FAKENOPS];
395
	uint64_t	srvrpc_errs;
398
	uint64_t	srvrpc_errs;
(-)sys/fs/nfs/nfsproto.h (-1 / +4 lines)
Lines 359-368 Link Here
359
#define	NFSPROC_OPENLAYGET	54
359
#define	NFSPROC_OPENLAYGET	54
360
#define	NFSPROC_CREATELAYGET	55
360
#define	NFSPROC_CREATELAYGET	55
361
361
362
/* BindConnectionToSession, done by the krpc for a new connection. */
363
#define	NFSPROC_BINDCONNTOSESS	56
364
362
/*
365
/*
363
 * Must be defined as one higher than the last NFSv4.1 Proc# above.
366
 * Must be defined as one higher than the last NFSv4.1 Proc# above.
364
 */
367
 */
365
#define	NFSV41_NPROCS		56
368
#define	NFSV41_NPROCS		57
366
369
367
#endif	/* NFS_V3NPROCS */
370
#endif	/* NFS_V3NPROCS */
368
371
(-)sys/fs/nfs/nfs_commonsubs.c (-2 / +3 lines)
Lines 192-198 static struct nfsrv_lughash *nfsgroupnamehash; Link Here
192
 */
192
 */
193
static int nfs_bigreply[NFSV41_NPROCS] = { 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0,
193
static int nfs_bigreply[NFSV41_NPROCS] = { 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0,
194
    0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
194
    0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
195
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 };
195
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 };
196
196
197
/* local functions */
197
/* local functions */
198
static int nfsrv_skipace(struct nfsrv_descript *nd, int *acesizep);
198
static int nfsrv_skipace(struct nfsrv_descript *nd, int *acesizep);
Lines 267-272 static struct { Link Here
267
	{ NFSV4OP_COMMIT, 1, "CommitDS", 8, },
267
	{ NFSV4OP_COMMIT, 1, "CommitDS", 8, },
268
	{ NFSV4OP_OPEN, 3, "OpenLayoutGet", 13, },
268
	{ NFSV4OP_OPEN, 3, "OpenLayoutGet", 13, },
269
	{ NFSV4OP_OPEN, 8, "CreateLayGet", 12, },
269
	{ NFSV4OP_OPEN, 8, "CreateLayGet", 12, },
270
	{ NFSV4OP_BINDCONNTOSESS, 1, "BindConSess", 11, },
270
};
271
};
271
272
272
/*
273
/*
Lines 275-281 static struct { Link Here
275
static int nfs_bigrequest[NFSV41_NPROCS] = {
276
static int nfs_bigrequest[NFSV41_NPROCS] = {
276
	0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
277
	0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
277
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
278
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
278
	0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0
279
	0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0
279
};
280
};
280
281
281
/*
282
/*
(-)sys/fs/nfs/nfscl.h (+5 lines)
Lines 81-84 struct nfsv4node { Link Here
81
			printf(__VA_ARGS__);				\
81
			printf(__VA_ARGS__);				\
82
	} while (0)
82
	} while (0)
83
83
84
struct nfscl_reconarg {
85
	int	minorvers;
86
	uint8_t	sessionid[NFSX_V4SESSIONID];
87
};
88
84
#endif	/* _NFS_NFSCL_H */
89
#endif	/* _NFS_NFSCL_H */
(-)sys/fs/nfs/nfs_var.h (+1 lines)
Lines 535-540 int nfscl_doiods(vnode_t, struct uio *, int *, int *, Link Here
535
int nfscl_findlayoutforio(struct nfscllayout *, uint64_t, uint32_t,
535
int nfscl_findlayoutforio(struct nfscllayout *, uint64_t, uint32_t,
536
    struct nfsclflayout **);
536
    struct nfsclflayout **);
537
void nfscl_freenfsclds(struct nfsclds *);
537
void nfscl_freenfsclds(struct nfsclds *);
538
void nfsrpc_bindconnsess(CLIENT *, void *, struct ucred *);
538
539
539
/* nfs_clstate.c */
540
/* nfs_clstate.c */
540
int nfscl_open(vnode_t, u_int8_t *, int, u_int32_t, int,
541
int nfscl_open(vnode_t, u_int8_t *, int, u_int32_t, int,
(-)sys/fs/nfsclient/nfs_clrpcops.c (+91 lines)
Lines 924-929 nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli Link Here
924
	struct nfsclds *dsp;
924
	struct nfsclds *dsp;
925
	struct in6_addr a6;
925
	struct in6_addr a6;
926
	struct nfsclsession *tsep;
926
	struct nfsclsession *tsep;
927
	struct rpc_reconupcall recon;
928
	struct nfscl_reconarg *rcp;
927
929
928
	if (nfsboottime.tv_sec == 0)
930
	if (nfsboottime.tv_sec == 0)
929
		NFSSETBOOTTIME(nfsboottime);
931
		NFSSETBOOTTIME(nfsboottime);
Lines 942-947 nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli Link Here
942
			    &nmp->nm_sockreq,
944
			    &nmp->nm_sockreq,
943
			    dsp->nfsclds_sess.nfsess_sequenceid, 1, cred, p);
945
			    dsp->nfsclds_sess.nfsess_sequenceid, 1, cred, p);
944
		if (error == 0) {
946
		if (error == 0) {
947
			/*
948
			 * If the session supports a backchannel, set up
949
			 * the BindConnectionToSession call in the krpc
950
			 * so that it is done on a reconnection.
951
			 */
952
			if (nfscl_enablecallb != 0 && nfs_numnfscbd > 0) {
953
				rcp = mem_alloc(sizeof(*rcp));
954
				rcp->minorvers = nmp->nm_minorvers;
955
				memcpy(rcp->sessionid,
956
				    dsp->nfsclds_sess.nfsess_sessionid,
957
				    NFSX_V4SESSIONID);
958
				recon.call = nfsrpc_bindconnsess;
959
				recon.arg = rcp;
960
				CLNT_CONTROL(nmp->nm_client, CLSET_RECONUPCALL,
961
				    &recon);
962
			}
963
945
			NFSLOCKMNT(nmp);
964
			NFSLOCKMNT(nmp);
946
			/*
965
			/*
947
			 * The old sessions cannot be safely free'd
966
			 * The old sessions cannot be safely free'd
Lines 5854-5859 nfsm_copym(struct mbuf *m, int off, int xfer) Link Here
5854
	return (m2);
5873
	return (m2);
5855
}
5874
}
5856
5875
5876
5857
/*
5877
/*
5858
 * Find a file layout that will handle the first bytes of the requested
5878
 * Find a file layout that will handle the first bytes of the requested
5859
 * range and return the information from it needed to the I/O operation.
5879
 * range and return the information from it needed to the I/O operation.
Lines 7678-7682 out: Link Here
7678
			*islockedp = 1;
7698
			*islockedp = 1;
7679
	}
7699
	}
7680
	return (laystat);
7700
	return (laystat);
7701
}
7702
7703
/*
7704
 * Do the NFSv4.1 Bind Connection to Session.
7705
 * Called from the reconnect layer of the krpc (sys/rpc/clnt_rc.c).
7706
 */
7707
void
7708
nfsrpc_bindconnsess(CLIENT *cl, void *arg, struct ucred *cr)
7709
{
7710
	struct nfscl_reconarg *rcp = (struct nfscl_reconarg *)arg;
7711
	uint32_t res, *tl;
7712
	struct nfsrv_descript nfsd;
7713
	struct nfsrv_descript *nd = &nfsd;
7714
	struct rpc_callextra ext;
7715
	struct timeval utimeout;
7716
	enum clnt_stat stat;
7717
	int error;
7718
7719
	nfscl_reqstart(nd, NFSPROC_BINDCONNTOSESS, NULL, NULL, 0, NULL, NULL,
7720
	    NFS_VER4, rcp->minorvers);
7721
	NFSM_BUILD(tl, uint32_t *, NFSX_V4SESSIONID + 2 * NFSX_UNSIGNED);
7722
	memcpy(tl, rcp->sessionid, NFSX_V4SESSIONID);
7723
	tl += NFSX_V4SESSIONID / NFSX_UNSIGNED;
7724
	*tl++ = txdr_unsigned(NFSCDFC4_FORE_OR_BOTH);
7725
	*tl = newnfs_false;
7726
7727
	memset(&ext, 0, sizeof(ext));
7728
	utimeout.tv_sec = 30;
7729
	utimeout.tv_usec = 0;
7730
	ext.rc_auth = authunix_create(cr);
7731
	nd->nd_mrep = NULL;
7732
	stat = CLNT_CALL_MBUF(cl, &ext, NFSV4PROC_COMPOUND, nd->nd_mreq,
7733
	    &nd->nd_mrep, utimeout);
7734
	AUTH_DESTROY(ext.rc_auth);
7735
	if (stat != RPC_SUCCESS) {
7736
		printf("nfsrpc_bindconnsess: call failed stat=%d\n", stat);
7737
		return;
7738
	}
7739
	if (nd->nd_mrep == NULL) {
7740
		printf("nfsrpc_bindconnsess: no reply args\n");
7741
		return;
7742
	}
7743
	error = 0;
7744
	newnfs_realign(&nd->nd_mrep, M_WAITOK);
7745
	nd->nd_md = nd->nd_mrep;
7746
	nd->nd_dpos = mtod(nd->nd_md, char *);
7747
	NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED);
7748
	nd->nd_repstat = fxdr_unsigned(uint32_t, *tl++);
7749
	if (nd->nd_repstat == NFSERR_OK) {
7750
		res = fxdr_unsigned(uint32_t, *tl);
7751
		if (res > 0 && (error = nfsm_advance(nd, NFSM_RNDUP(res),
7752
		    -1)) != 0)
7753
			goto nfsmout;
7754
		NFSM_DISSECT(tl, uint32_t *, NFSX_V4SESSIONID +
7755
		    4 * NFSX_UNSIGNED);
7756
		tl += 3;
7757
		if (!NFSBCMP(tl, rcp->sessionid, NFSX_V4SESSIONID)) {
7758
			tl += NFSX_V4SESSIONID / NFSX_UNSIGNED;
7759
			res = fxdr_unsigned(uint32_t, *tl);
7760
			if (res != NFSCDFS4_BOTH)
7761
				printf("nfsrpc_bindconnsess: did not "
7762
				    "return FS4_BOTH\n");
7763
		} else
7764
			printf("nfsrpc_bindconnsess: not same "
7765
			    "sessionid\n");
7766
	} else if (nd->nd_repstat != NFSERR_BADSESSION)
7767
		printf("nfsrpc_bindconnsess: returned %d\n", nd->nd_repstat);
7768
nfsmout:
7769
	if (error != 0)
7770
		printf("nfsrpc_bindconnsess: reply bad xdr\n");
7771
	m_freem(nd->nd_mrep);
7681
}
7772
}
7682
7773
(-)sys/rpc/clnt.h (+6 lines)
Lines 357-362 enum clnt_stat clnt_call_private(CLIENT *, struct rpc_ Link Here
357
#define CLSET_PRIVPORT		27	/* set privileged source port flag */
357
#define CLSET_PRIVPORT		27	/* set privileged source port flag */
358
#define CLGET_PRIVPORT		28	/* get privileged source port flag */
358
#define CLGET_PRIVPORT		28	/* get privileged source port flag */
359
#define CLSET_BACKCHANNEL	29	/* set backchannel for socket */
359
#define CLSET_BACKCHANNEL	29	/* set backchannel for socket */
360
/* Structure used as the argument for CLSET_RECONUPCALL. */
361
struct rpc_reconupcall {
362
	void	(*call)(CLIENT *, void *, struct ucred *);
363
	void	*arg;
364
};
365
#define	CLSET_RECONUPCALL	30	/* Reconnect upcall */
360
#endif
366
#endif
361
367
362
368
(-)sys/rpc/krpc.h (+3 lines)
Lines 78-83 struct rc_data { Link Here
78
	CLIENT*			rc_client; /* underlying RPC client */
78
	CLIENT*			rc_client; /* underlying RPC client */
79
	struct rpc_err		rc_err;
79
	struct rpc_err		rc_err;
80
	void			*rc_backchannel;
80
	void			*rc_backchannel;
81
	void			(*rc_reconcall)(CLIENT *, void *,
82
				    struct ucred *); /* reconection upcall */
83
	void			*rc_reconarg;	/* upcall arg */
81
};
84
};
82
85
83
struct ct_data {
86
struct ct_data {
(-)sys/rpc/clnt_rc.c (+15 lines)
Lines 108-113 clnt_reconnect_create( Link Here
108
	rc->rc_closed = FALSE;
108
	rc->rc_closed = FALSE;
109
	rc->rc_ucred = crdup(curthread->td_ucred);
109
	rc->rc_ucred = crdup(curthread->td_ucred);
110
	rc->rc_client = NULL;
110
	rc->rc_client = NULL;
111
	rc->rc_reconcall = NULL;
112
	rc->rc_reconarg = NULL;
111
113
112
	cl->cl_refs = 1;
114
	cl->cl_refs = 1;
113
	cl->cl_ops = &clnt_reconnect_ops;
115
	cl->cl_ops = &clnt_reconnect_ops;
Lines 193-198 clnt_reconnect_connect(CLIENT *cl) Link Here
193
		newclient = clnt_vc_create(so,
195
		newclient = clnt_vc_create(so,
194
		    (struct sockaddr *) &rc->rc_addr, rc->rc_prog, rc->rc_vers,
196
		    (struct sockaddr *) &rc->rc_addr, rc->rc_prog, rc->rc_vers,
195
		    rc->rc_sendsz, rc->rc_recvsz, rc->rc_intr);
197
		    rc->rc_sendsz, rc->rc_recvsz, rc->rc_intr);
198
		if (newclient != NULL && rc->rc_reconcall != NULL)
199
			(*rc->rc_reconcall)(newclient, rc->rc_reconarg,
200
			    rc->rc_ucred);
196
	}
201
	}
197
	td->td_ucred = oldcred;
202
	td->td_ucred = oldcred;
198
203
Lines 385-390 clnt_reconnect_control(CLIENT *cl, u_int request, void Link Here
385
{
390
{
386
	struct rc_data *rc = (struct rc_data *)cl->cl_private;
391
	struct rc_data *rc = (struct rc_data *)cl->cl_private;
387
	SVCXPRT *xprt;
392
	SVCXPRT *xprt;
393
	struct rpc_reconupcall *upcp;
388
394
389
	if (info == NULL) {
395
	if (info == NULL) {
390
		return (FALSE);
396
		return (FALSE);
Lines 472-477 clnt_reconnect_control(CLIENT *cl, u_int request, void Link Here
472
		rc->rc_backchannel = info;
478
		rc->rc_backchannel = info;
473
		break;
479
		break;
474
480
481
	case CLSET_RECONUPCALL:
482
		upcp = (struct rpc_reconupcall *)info;
483
		rc->rc_reconcall = upcp->call;
484
		rc->rc_reconarg = upcp->arg;
485
		break;
486
475
	default:
487
	default:
476
		return (FALSE);
488
		return (FALSE);
477
	}
489
	}
Lines 514-524 clnt_reconnect_destroy(CLIENT *cl) Link Here
514
		CLNT_DESTROY(rc->rc_client);
526
		CLNT_DESTROY(rc->rc_client);
515
	if (rc->rc_backchannel) {
527
	if (rc->rc_backchannel) {
516
		xprt = (SVCXPRT *)rc->rc_backchannel;
528
		xprt = (SVCXPRT *)rc->rc_backchannel;
529
		KASSERT(xprt->xp_socket == NULL,
530
		    ("clnt_reconnect_destroy: xp_socket not NULL"));
517
		xprt_unregister(xprt);
531
		xprt_unregister(xprt);
518
		SVC_RELEASE(xprt);
532
		SVC_RELEASE(xprt);
519
	}
533
	}
520
	crfree(rc->rc_ucred);
534
	crfree(rc->rc_ucred);
521
	mtx_destroy(&rc->rc_lock);
535
	mtx_destroy(&rc->rc_lock);
536
	mem_free(rc->rc_reconarg, 0);
522
	mem_free(rc, sizeof(*rc));
537
	mem_free(rc, sizeof(*rc));
523
	mem_free(cl, sizeof (CLIENT));
538
	mem_free(cl, sizeof (CLIENT));
524
}
539
}

Return to bug 254840