Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 May 2018 22:32:09 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r333691 - in projects/pnfs-planb-server/sys/fs: nfs nfsserver
Message-ID:  <201805162232.w4GMW9Bm075697@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Wed May 16 22:32:08 2018
New Revision: 333691
URL: https://svnweb.freebsd.org/changeset/base/333691

Log:
  Delete the "nmpp" argument for nfsrv_dsgetsockmnt() since it is not needed.
  Also, do a little cleanup of nfsrv_dsgetsockmnt() and add a few sanity checks.
  I don not believe this changes the server'semantics, except maybe for the
  case of "devid", which was filled in even for the error case.

Modified:
  projects/pnfs-planb-server/sys/fs/nfs/nfs_var.h
  projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c
  projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c

Modified: projects/pnfs-planb-server/sys/fs/nfs/nfs_var.h
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfs/nfs_var.h	Wed May 16 22:29:20 2018	(r333690)
+++ projects/pnfs-planb-server/sys/fs/nfs/nfs_var.h	Wed May 16 22:32:08 2018	(r333691)
@@ -703,9 +703,8 @@ void nfsrv_backupstable(void);
 int nfsrv_dsgetdevandfh(struct vnode *, NFSPROC_T *, int *, fhandle_t *,
     char *);
 int nfsrv_dsgetsockmnt(struct vnode *, int, char *, int *, int *,
-    NFSPROC_T *, struct vnode **, struct nfsmount **, fhandle_t *, char *,
-    char *, struct vnode **, struct nfsmount *, struct nfsmount *, int *,
-    int *);
+    NFSPROC_T *, struct vnode **, fhandle_t *, char *, char *,
+    struct vnode **, struct nfsmount *, struct nfsmount *, int *, int *);
 int nfsrv_dscreate(struct vnode *, struct vattr *, struct vattr *,
     fhandle_t *, struct pnfsdsfile *, struct pnfsdsattr *, char *,
     struct ucred *, NFSPROC_T *, struct vnode **);

Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c	Wed May 16 22:29:20 2018	(r333690)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c	Wed May 16 22:32:08 2018	(r333691)
@@ -3948,6 +3948,7 @@ nfsrv_pnfscreate(struct vnode *vp, struct vattr *vap, 
 
 	NFSFREECRED(tcred);
 	if (error == 0) {
+		ASSERT_VOP_ELOCKED(vp, "nfsrv_pnfscreate vp");
 		error = vn_start_write(vp, &mp, V_WAIT);
 		if (error == 0) {
 			error = vn_extattr_set(vp, IO_NODELOCKED,
@@ -3978,7 +3979,6 @@ static void
 nfsrv_pnfsremovesetup(struct vnode *vp, NFSPROC_T *p, struct vnode **dvpp,
     int *mirrorcntp, char *fname)
 {
-	struct nfsmount *nmp[NFSDEV_MAXMIRRORS];
 	struct vattr va;
 	struct ucred *tcred;
 	char *buf;
@@ -4005,7 +4005,7 @@ nfsrv_pnfsremovesetup(struct vnode *vp, NFSPROC_T *p, 
 	buf = malloc(buflen, M_TEMP, M_WAITOK);
 	/* Get the directory vnode for the DS mount and the file handle. */
 	error = nfsrv_dsgetsockmnt(vp, LK_EXCLUSIVE, buf, &buflen, mirrorcntp,
-	    p, dvpp, nmp, NULL, NULL, fname, NULL, NULL, NULL, NULL, NULL);
+	    p, dvpp, NULL, NULL, fname, NULL, NULL, NULL, NULL, NULL);
 	free(buf, M_TEMP);
 	if (error != 0)
 		printf("pNFS: nfsrv_pnfsremovesetup getsockmnt=%d\n", error);
@@ -4285,9 +4285,12 @@ tryagain:
 	if (error == 0) {
 		buflen = 1024;
 		error = nfsrv_dsgetsockmnt(vp, LK_SHARED, buf, &buflen,
-		    &mirrorcnt, p, dvp, nmp, fh, NULL, NULL, NULL, NULL, NULL,
+		    &mirrorcnt, p, dvp, fh, NULL, NULL, NULL, NULL, NULL,
 		    NULL, NULL);
-		if (error != 0)
+		if (error == 0) {
+			for (i = 0; i < mirrorcnt; i++)
+				nmp[i] = VFSTONFS(dvp[i]->v_mount);
+		} else
 			printf("pNFS: proxy getextattr sockaddr=%d\n", error);
 	} else
 		printf("pNFS: nfsrv_dsgetsockmnt=%d\n", error);
@@ -4387,10 +4390,9 @@ tryagain:
  */
 int
 nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char *buf, int *buflenp,
-    int *mirrorcntp, NFSPROC_T *p, struct vnode **dvpp, struct nfsmount **nmpp,
-    fhandle_t *fhp, char *devid, char *fnamep, struct vnode **nvpp,
-    struct nfsmount *newnmp, struct nfsmount *curnmp, int *zeroippos,
-    int *dsdirp)
+    int *mirrorcntp, NFSPROC_T *p, struct vnode **dvpp, fhandle_t *fhp,
+    char *devid, char *fnamep, struct vnode **nvpp, struct nfsmount *newnmp,
+    struct nfsmount *curnmp, int *zeroippos, int *dsdirp)
 {
 	struct vnode *dvp, *nvp, **tdvpp;
 	struct nfsmount *nmp;
@@ -4401,16 +4403,15 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char 
 	uint32_t dsdir;
 	int done, error, fnd, fhiszero, gotone, i, mirrorcnt;
 
+	ASSERT_VOP_LOCKED(vp, "nfsrv_dsgetsockmnt vp");
 	*mirrorcntp = 1;
 	tdvpp = dvpp;
 	if (lktype == 0)
 		lktype = LK_SHARED;
 	if (nvpp != NULL)
 		*nvpp = NULL;
-	if (dvpp != NULL) {
+	if (dvpp != NULL)
 		*dvpp = NULL;
-		*nmpp = NULL;
-	}
 	if (zeroippos != NULL)
 		*zeroippos = -1;
 	error = vn_extattr_get(vp, IO_NODELOCKED, EXTATTR_NAMESPACE_SYSTEM,
@@ -4465,6 +4466,10 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char 
 					if (mds->nfsdev_nmp != NULL) {
 						dvp = mds->nfsdev_dvp;
 						nmp = VFSTONFS(dvp->v_mount);
+						if (nmp != mds->nfsdev_nmp)
+							printf("different nmp "
+							    "%p %p\n", nmp,
+							    mds->nfsdev_nmp);
 						if (nfsaddr2_match(sad,
 						    nmp->nm_nam)) {
 							ds = mds;
@@ -4477,6 +4482,9 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char 
 					break;
 				dvp = ds->nfsdev_dvp;
 				nmp = VFSTONFS(dvp->v_mount);
+				if (nmp != ds->nfsdev_nmp)
+					printf("different2 nmp %p %p\n",
+					    nmp, ds->nfsdev_nmp);
 				if (nfsaddr2_match(sad, nmp->nm_nam))
 					break;
 			}
@@ -4513,18 +4521,16 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char 
 							NFSVOPUNLOCK(dvp, 0);
 					}
 				}
-				if (devid != NULL) {
-					NFSBCOPY(ds->nfsdev_deviceid, devid,
-					    NFSX_V4DEVICEID);
-					devid += NFSX_V4DEVICEID;
-				}
 				if (error == 0) {
 					gotone++;
 					NFSD_DEBUG(4, "gotone=%d\n", gotone);
-					if (dvpp != NULL) {
-						*tdvpp++ = dvp;
-						*nmpp++ = nmp;
+					if (devid != NULL) {
+						NFSBCOPY(ds->nfsdev_deviceid,
+						    devid, NFSX_V4DEVICEID);
+						devid += NFSX_V4DEVICEID;
 					}
+					if (dvpp != NULL)
+						*tdvpp++ = dvp;
 					if (fhp != NULL)
 						NFSBCOPY(&pf->dsf_fh, fhp++,
 						    NFSX_MYFH);
@@ -4579,6 +4585,7 @@ nfsrv_setextattr(struct vnode *vp, struct nfsvattr *na
 	struct mount *mp;
 	int error;
 
+	ASSERT_VOP_ELOCKED(vp, "nfsrv_setextattr vp");
 	error = vn_start_write(vp, &mp, V_WAIT);
 	if (error == 0) {
 		dsattr.dsa_filerev = nap->na_filerev;
@@ -5307,7 +5314,7 @@ nfsrv_dsgetdevandfh(struct vnode *vp, NFSPROC_T *p, in
 	buflen = 1024;
 	buf = malloc(buflen, M_TEMP, M_WAITOK);
 	error = nfsrv_dsgetsockmnt(vp, 0, buf, &buflen, mirrorcntp, p, NULL,
-	    NULL, fhp, devid, NULL, NULL, NULL, NULL, NULL, NULL);
+	    fhp, devid, NULL, NULL, NULL, NULL, NULL, NULL);
 	free(buf, M_TEMP);
 	return (error);
 }

Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c	Wed May 16 22:29:20 2018	(r333690)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c	Wed May 16 22:32:08 2018	(r333691)
@@ -7990,7 +7990,7 @@ nfsrv_mdscopymr(char *mdspathp, char *dspathp, char *c
 	 * nfsrv_dsgetsockmnt() returns EEXIST, so no copying will occur.
 	 */
 	error = nfsrv_dsgetsockmnt(vp, LK_EXCLUSIVE, buf, buflenp,
-	    &mirrorcnt, p, NULL, NULL, NULL, NULL, fname, nvpp, nmp, curnmp,
+	    &mirrorcnt, p, NULL, NULL, NULL, fname, nvpp, nmp, curnmp,
 	    &zeroippos, &dsdir);
 	vput(nd.ni_vp);
 	vput(curvp);



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