Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Aug 2017 01:19:46 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r322639 - projects/pnfs-planb-server-stable11/sys/fs/nfsserver
Message-ID:  <201708180119.v7I1JkMZ041454@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Fri Aug 18 01:19:46 2017
New Revision: 322639
URL: https://svnweb.freebsd.org/changeset/base/322639

Log:
  Fix the searches of the device id lists so that they include the mirror
  entries. Also, modify nfsrv_dssetsockmnt() so that it only returns ENOENT
  if none of the DSs were found. This will allow a mirrored system to run in
  a degraded mode when one mirror is offline.
  
  The mirroring is now working for normal operation, although Flex File layout
  has not yet been tested (all I/O goes through MDS when mirroring is set up).
  
  Now, the fun part is to code handling of a DS mirror failure and resilvering
  of a DS mirror to bring it back online.
  Also, testing of Flex File layout against a recent Linux client needs to be
  done.

Modified:
  projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdport.c
  projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdstate.c

Modified: projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdport.c	Fri Aug 18 00:25:27 2017	(r322638)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdport.c	Fri Aug 18 01:19:46 2017	(r322639)
@@ -4171,10 +4171,10 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char 
 	struct vnode *dvp, **tdvpp;
 	struct nfsmount *nmp;
 	struct sockaddr *sad;
-	struct nfsdevice *ds;
+	struct nfsdevice *ds, *mds;
 	struct pnfsdsfile *pf;
 	uint32_t dsdir;
-	int error, fhiszero, i, j, mirrorcnt;
+	int done, error, fhiszero, gotone, i, j, mirrorcnt;
 
 	*mirrorcntp = 1;
 	fhiszero = 0;
@@ -4192,6 +4192,7 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char 
 	    buflen != sizeof(*pf) * mirrorcnt))
 		error = ENOATTR;
 	pf = (struct pnfsdsfile *)buf;
+	gotone = 0;
 	for (i = 0; i < mirrorcnt && error == 0; i++, pf++) {
 		sad = (struct sockaddr *)&pf->dsf_sin;
 		dsdir = pf->dsf_dir;
@@ -4203,8 +4204,21 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char 
 			if (NFSBCMP(&zerofh, &pf->dsf_fh, sizeof(zerofh)) == 0)
 				fhiszero = 1;
 			/* Use the socket address to find the mount point. */
+			done = 0;
 			NFSDDSLOCK();
 			TAILQ_FOREACH(ds, &nfsrv_devidhead, nfsdev_list) {
+				TAILQ_FOREACH(mds, &ds->nfsdev_mirrors,
+				    nfsdev_list) {
+					dvp = mds->nfsdev_dvp;
+					nmp = VFSTONFS(dvp->v_mount);
+					if (nfsaddr2_match(sad, nmp->nm_nam)) {
+						ds = mds;
+						done = 1;
+						break;
+					}
+				}
+				if (done != 0)
+					break;
 				dvp = ds->nfsdev_dvp;
 				nmp = VFSTONFS(dvp->v_mount);
 				if (nfsaddr2_match(sad, nmp->nm_nam))
@@ -4212,6 +4226,7 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char 
 			}
 			NFSDDSUNLOCK();
 			if (ds != NULL) {
+				gotone = 1;
 				if (dvpp != NULL || fhiszero != 0) {
 					dvp = ds->nfsdev_dsdir[dsdir];
 					error = vn_lock(dvp, lktype);
@@ -4234,26 +4249,30 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char 
 					    NFSX_V4DEVICEID);
 					devid += NFSX_V4DEVICEID;
 				}
-			} else
-				error = ENOENT;
-		}
-		if (error == 0) {
-			if (dvpp != NULL) {
-				*tdvpp++ = dvp;
-				*nmpp++ = nmp;
+				if (error == 0) {
+					if (dvpp != NULL) {
+						*tdvpp++ = dvp;
+						*nmpp++ = nmp;
+					}
+					if (fhp != NULL)
+						NFSBCOPY(&pf->dsf_fh, fhp++,
+						    NFSX_MYFH);
+					if (fnamep != NULL && i == 0)
+						strlcpy(fnamep,
+						    pf->dsf_filename,
+						    sizeof(pf->dsf_filename));
+				} else
+					NFSD_DEBUG(4, "nfsrv_dsgetsockmnt "
+					    "err=%d\n", error);
 			}
-			if (fhp != NULL)
-				NFSBCOPY(&pf->dsf_fh, fhp++, NFSX_MYFH);
-			if (fnamep != NULL && i == 0)
-				strlcpy(fnamep, pf->dsf_filename,
-				    sizeof(pf->dsf_filename));
-		} else
-			NFSD_DEBUG(4, "nfsrv_dsgetsockmnt err=%d\n", error);
+		}
 	}
+	if (error == 0 && gotone == 0)
+		error = ENOENT;
 
 	if (error == 0)
 		*mirrorcntp = mirrorcnt;
-	else if (i > 1 && dvpp != NULL) {
+	else if (i > 1 && dvpp != NULL && gotone != 0) {
 		/*
 		 * If the error didn't occur on the first one and dvpp != NULL,
 		 * the one(s) prior to the failure will have locked dvp's that

Modified: projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdstate.c	Fri Aug 18 00:25:27 2017	(r322638)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdstate.c	Fri Aug 18 01:19:46 2017	(r322639)
@@ -6596,8 +6596,8 @@ int
 nfsrv_getdevinfo(char *devid, int layouttype, uint32_t *maxcnt,
     uint32_t *notify, int *devaddrlen, char **devaddr)
 {
-	struct nfsdevice *ds;
-	int i;
+	struct nfsdevice *ds, *mds;
+	int done, i;
 
 	if (layouttype != NFSLAYOUT_NFSV4_1_FILES)
 		return (NFSERR_UNKNLAYOUTTYPE);
@@ -6607,8 +6607,19 @@ nfsrv_getdevinfo(char *devid, int layouttype, uint32_t
 	 * away, but the order changes in the list.  As such, the lock only
 	 * needs to be held during the search through the list.
 	 */
+	done = 0;
 	NFSDDSLOCK();
 	TAILQ_FOREACH(ds, &nfsrv_devidhead, nfsdev_list) {
+		TAILQ_FOREACH(mds, &ds->nfsdev_mirrors, nfsdev_list) {
+			if (NFSBCMP(devid, mds->nfsdev_deviceid,
+			    NFSX_V4DEVICEID) == 0) {
+				ds = mds;
+				done = 1;
+				break;
+			}
+		}
+		if (done != 0)
+			break;
 		if (NFSBCMP(devid, ds->nfsdev_deviceid, NFSX_V4DEVICEID) == 0)
 			break;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708180119.v7I1JkMZ041454>