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

Collapse All | Expand All

(-)sys/fs/nfs/nfs_commonsubs.c (-12 / +55 lines)
Lines 81-86 NFSNAMEIDMUTEX; Link Here
81
NFSSOCKMUTEX;
81
NFSSOCKMUTEX;
82
extern int nfsrv_lughashsize;
82
extern int nfsrv_lughashsize;
83
extern struct mtx nfsrv_dslock_mtx;
83
extern struct mtx nfsrv_dslock_mtx;
84
extern struct mtx nfs_clstate_mutex;
84
extern volatile int nfsrv_devidcnt;
85
extern volatile int nfsrv_devidcnt;
85
extern int nfscl_debuglevel;
86
extern int nfscl_debuglevel;
86
extern struct nfsdevicehead nfsrv_devidhead;
87
extern struct nfsdevicehead nfsrv_devidhead;
Lines 4823-4853 nfsv4_sequencelookup(struct nfsmount *nmp, struct nfsc Link Here
4823
{
4824
{
4824
	int i, maxslot, slotpos;
4825
	int i, maxslot, slotpos;
4825
	uint64_t bitval;
4826
	uint64_t bitval;
4827
	bool fnd_okslot;
4826
4828
4827
	/* Find an unused slot. */
4829
	/* Find an unused slot. */
4828
	slotpos = -1;
4830
	slotpos = -1;
4829
	maxslot = -1;
4831
	maxslot = -1;
4830
	mtx_lock(&sep->nfsess_mtx);
4832
	mtx_lock(&sep->nfsess_mtx);
4833
if (sep->nfsess_badslots != 0) printf("badslots=0x%lx\n", sep->nfsess_badslots);
4831
	do {
4834
	do {
4832
		if (nmp != NULL && sep->nfsess_defunct != 0) {
4835
		fnd_okslot = true;
4833
			/* Just return the bad session. */
4836
		if (nmp != NULL) {
4834
			bcopy(sep->nfsess_sessionid, sessionid,
4837
			KASSERT(TAILQ_FIRST(&nmp->nm_sess) != NULL,
4835
			    NFSX_V4SESSIONID);
4838
			    ("nfsv4_sequencelookup: no mds sess"));
4836
			mtx_unlock(&sep->nfsess_mtx);
4839
			if (sep->nfsess_defunct != 0) {
4837
			return (NFSERR_BADSESSION);
4840
				/* Just return the bad session. */
4841
				bcopy(sep->nfsess_sessionid, sessionid,
4842
				    NFSX_V4SESSIONID);
4843
				mtx_unlock(&sep->nfsess_mtx);
4844
				return (NFSERR_BADSESSION);
4845
			}
4846
4847
			/* Only check for bad slots on the MDS session. */
4848
			if (NFSMNT_MDSSESSION(nmp) == sep)
4849
				fnd_okslot = false;
4838
		}
4850
		}
4839
		bitval = 1;
4851
		bitval = 1;
4840
		for (i = 0; i < sep->nfsess_foreslots; i++) {
4852
		for (i = 0; i < sep->nfsess_foreslots; i++) {
4841
			if ((bitval & sep->nfsess_slots) == 0) {
4853
			if ((bitval & sep->nfsess_badslots) == 0) {
4842
				slotpos = i;
4854
				fnd_okslot = true;
4843
				sep->nfsess_slots |= bitval;
4855
				if ((bitval & sep->nfsess_slots) == 0) {
4844
				sep->nfsess_slotseq[i]++;
4856
					slotpos = i;
4845
				*slotseqp = sep->nfsess_slotseq[i];
4857
					sep->nfsess_slots |= bitval;
4846
				break;
4858
					sep->nfsess_slotseq[i]++;
4859
					*slotseqp = sep->nfsess_slotseq[i];
4860
					break;
4861
				}
4847
			}
4862
			}
4848
			bitval <<= 1;
4863
			bitval <<= 1;
4849
		}
4864
		}
4850
		if (slotpos == -1) {
4865
		if (slotpos == -1) {
4866
			if (!fnd_okslot) {
4867
				/*
4868
				 * All slots are broken, so mark the session
4869
				 * defunct.
4870
				 */
4871
				bcopy(sep->nfsess_sessionid, sessionid,
4872
				    NFSX_V4SESSIONID);
4873
				sep->nfsess_defunct = 1;
4874
printf("all badslots\n");
4875
				mtx_unlock(&sep->nfsess_mtx);
4876
				NFSCL_DEBUG(1, "Marked defunct\n");
4877
4878
				/*
4879
				 * If this is the current session,
4880
				 * initiate recovery.
4881
				 */
4882
				NFSLOCKCLSTATE();
4883
				NFSLOCKMNT(nmp);
4884
				if (nmp->nm_clp != NULL &&
4885
				    NFSMNT_MDSSESSION(nmp) == sep) {
4886
					nmp->nm_clp->nfsc_flags |=
4887
					    NFSCLFLAGS_RECOVER;
4888
					wakeup(nmp->nm_clp);
4889
				}
4890
				NFSUNLOCKCLSTATE();
4891
				NFSUNLOCKMNT(nmp);
4892
				return (NFSERR_BADSESSION);
4893
			}
4851
			/*
4894
			/*
4852
			 * If a forced dismount is in progress, just return.
4895
			 * If a forced dismount is in progress, just return.
4853
			 * This RPC attempt will fail when it calls
4896
			 * This RPC attempt will fail when it calls
(-)sys/fs/nfs/nfs_commonkrpc.c (-10 / +24 lines)
Lines 606-611 newnfs_request(struct nfsrv_descript *nd, struct nfsmo Link Here
606
	uint8_t sessionid[NFSX_V4SESSIONID];
606
	uint8_t sessionid[NFSX_V4SESSIONID];
607
	bool nextconn_set;
607
	bool nextconn_set;
608
	struct timespec trylater_delay, ts, waituntil;
608
	struct timespec trylater_delay, ts, waituntil;
609
	struct nfsclds *dsp;
609
610
610
	/* Initially 1msec. */
611
	/* Initially 1msec. */
611
	trylater_delay.tv_sec = 0;
612
	trylater_delay.tv_sec = 0;
Lines 951-956 tryagain: Link Here
951
			 */
952
			 */
952
			mtx_lock(&sep->nfsess_mtx);
953
			mtx_lock(&sep->nfsess_mtx);
953
			sep->nfsess_slotseq[nd->nd_slotid] += 10;
954
			sep->nfsess_slotseq[nd->nd_slotid] += 10;
955
			sep->nfsess_badslots |= (1 << nd->nd_slotid);
954
			mtx_unlock(&sep->nfsess_mtx);
956
			mtx_unlock(&sep->nfsess_mtx);
955
			/* And free the slot. */
957
			/* And free the slot. */
956
			nfsv4_freeslot(sep, nd->nd_slotid, false);
958
			nfsv4_freeslot(sep, nd->nd_slotid, false);
Lines 1093-1108 tryagain: Link Here
1093
				NFSCL_DEBUG(1, "Got badsession\n");
1095
				NFSCL_DEBUG(1, "Got badsession\n");
1094
				NFSLOCKCLSTATE();
1096
				NFSLOCKCLSTATE();
1095
				NFSLOCKMNT(nmp);
1097
				NFSLOCKMNT(nmp);
1096
				sep = NFSMNT_MDSSESSION(nmp);
1098
				TAILQ_FOREACH(dsp, &nmp->nm_sess,
1097
				if (bcmp(sep->nfsess_sessionid, nd->nd_sequence,
1099
				    nfsclds_list) {
1098
				    NFSX_V4SESSIONID) == 0) {
1100
					sep = &dsp->nfsclds_sess;
1099
					/* Initiate recovery. */
1101
					if ((dsp->nfsclds_flags &
1100
					sep->nfsess_defunct = 1;
1102
					    NFSCLDS_DSSESS) == 0 &&
1101
					NFSCL_DEBUG(1, "Marked defunct\n");
1103
					    bcmp(sep->nfsess_sessionid,
1102
					if (nmp->nm_clp != NULL) {
1104
					    nd->nd_sequence,
1103
						nmp->nm_clp->nfsc_flags |=
1105
					    NFSX_V4SESSIONID) == 0) {
1104
						    NFSCLFLAGS_RECOVER;
1106
						/* Initiate recovery. */
1105
						wakeup(nmp->nm_clp);
1107
						sep->nfsess_defunct = 1;
1108
						NFSCL_DEBUG(1,
1109
						    "Marked defunct\n");
1110
printf("newnfs_req: sess defunct\n");
1111
						if (nmp->nm_clp != NULL &&
1112
						    NFSMNT_MDSSESSION(nmp) ==
1113
						    sep) {
1114
printf("newnfs_req: init recvr\n");
1115
						    nmp->nm_clp->nfsc_flags |=
1116
							NFSCLFLAGS_RECOVER;
1117
						    wakeup(nmp->nm_clp);
1118
						}
1119
						break;
1106
					}
1120
					}
1107
				}
1121
				}
1108
				NFSUNLOCKCLSTATE();
1122
				NFSUNLOCKCLSTATE();
(-)sys/fs/nfs/nfsclstate.h (+2 lines)
Lines 67-72 struct nfsclsession { Link Here
67
	SVCXPRT		*nfsess_xprt;		/* For backchannel callback */
67
	SVCXPRT		*nfsess_xprt;		/* For backchannel callback */
68
	uint32_t	nfsess_slotseq[64];	/* Max for 64bit nm_slots */
68
	uint32_t	nfsess_slotseq[64];	/* Max for 64bit nm_slots */
69
	uint64_t	nfsess_slots;
69
	uint64_t	nfsess_slots;
70
	uint64_t	nfsess_badslots;	/* Slots that are broken */
70
	uint32_t	nfsess_sequenceid;
71
	uint32_t	nfsess_sequenceid;
71
	uint32_t	nfsess_maxcache;	/* Max size for cached reply. */
72
	uint32_t	nfsess_maxcache;	/* Max size for cached reply. */
72
	uint32_t	nfsess_maxreq;		/* Max request size. */
73
	uint32_t	nfsess_maxreq;		/* Max request size. */
Lines 103-108 struct nfsclds { Link Here
103
#define	NFSCLDS_CLOSED		0x0008
104
#define	NFSCLDS_CLOSED		0x0008
104
#define	NFSCLDS_SAMECONN	0x0010
105
#define	NFSCLDS_SAMECONN	0x0010
105
#define	NFSCLDS_MINORV2		0x0020
106
#define	NFSCLDS_MINORV2		0x0020
107
#define	NFSCLDS_DSSESS		0x0040
106
108
107
struct nfsclclient {
109
struct nfsclclient {
108
	LIST_ENTRY(nfsclclient) nfsc_list;
110
	LIST_ENTRY(nfsclclient) nfsc_list;
(-)sys/fs/nfsclient/nfs_clrpcops.c (+3 lines)
Lines 6001-6006 nfsrpc_fillsa(struct nfsmount *nmp, struct sockaddr_in Link Here
6001
			    firsttry++ == 0);
6001
			    firsttry++ == 0);
6002
			if (error != 0)
6002
			if (error != 0)
6003
				newnfs_disconnect(NULL, nrp);
6003
				newnfs_disconnect(NULL, nrp);
6004
			else
6005
				dsp->nfsclds_flags |= NFSCLDS_DSSESS;
6004
		} else {
6006
		} else {
6005
			dsp = malloc(sizeof(struct nfsclds), M_NFSCLDS,
6007
			dsp = malloc(sizeof(struct nfsclds), M_NFSCLDS,
6006
			    M_WAITOK | M_ZERO);
6008
			    M_WAITOK | M_ZERO);
Lines 6107-6112 nfscl_initsessionslots(struct nfsclsession *sep) Link Here
6107
	for (i = 0; i < 64; i++)
6109
	for (i = 0; i < 64; i++)
6108
		sep->nfsess_slotseq[i] = 0;
6110
		sep->nfsess_slotseq[i] = 0;
6109
	sep->nfsess_slots = 0;
6111
	sep->nfsess_slots = 0;
6112
	sep->nfsess_badslots = 0;
6110
}
6113
}
6111
6114
6112
/*
6115
/*

Return to bug 260011