Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Aug 2017 21:53:52 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r322905 - in projects/pnfs-planb-server/sys/fs: nfs nfsserver
Message-ID:  <201708252153.v7PLrqJV096365@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Fri Aug 25 21:53:51 2017
New Revision: 322905
URL: https://svnweb.freebsd.org/changeset/base/322905

Log:
  Fix a few things related to Flex File Layout. The XDR needed to be fixed
  for the DeviceInfo. The layout was changed to provide non-empty string for
  uid/gid. These aren't used by the client, but the Linux client doesn't like
  empty strings. Also, get rid of the No_IO_through_MDS flag, since this makes
  the Linux client loop internally. It is just a hint, so I believe that is
  a Linux Flex File Layout driver bug.
  
  The Linux client still doesn't like the Flex File Layout for some reason,
  but the XDR looks ok on the wire and Linux falls back to I/O through the
  MDS, so at least the Linux mounts work now.

Modified:
  projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c
  projects/pnfs-planb-server/sys/fs/nfs/nfsproto.h
  projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdserv.c
  projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c

Modified: projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c	Fri Aug 25 21:42:56 2017	(r322904)
+++ projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c	Fri Aug 25 21:53:51 2017	(r322905)
@@ -69,6 +69,7 @@ int nfsrv_lease = NFSRV_LEASE;
 int ncl_mbuf_mlen = MLEN;
 int nfsd_enable_stringtouid = 0;
 int nfsrv_doflexfile = 0;
+int nfsrv_maxpnfsmirror = 1;
 static int nfs_enable_uidtostring = 0;
 NFSNAMEIDMUTEX;
 NFSSOCKMUTEX;
@@ -1776,18 +1777,17 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
 			attrsum += NFSX_UNSIGNED;
 			i = fxdr_unsigned(int, *tl);
 			if (i > 0) {
-				if (nfsrv_doflexfile != 0)
-					m = NFSLAYOUT_FLEXFILE;
-				else
-					m = NFSLAYOUT_NFSV4_1_FILES;
 				NFSM_DISSECT(tl, u_int32_t *, i *
 				    NFSX_UNSIGNED);
 				attrsum += i * NFSX_UNSIGNED;
-				for (j = 0; j < i; j++) {
-					k = fxdr_unsigned(int, *tl++);
-					if (compare && !(*retcmpp) && k != m)
-						*retcmpp = NFSERR_NOTSAME;
-				}
+				j = fxdr_unsigned(int, *tl);
+				if (i == 1 && compare && !(*retcmpp) &&
+				    (((nfsrv_doflexfile != 0 ||
+				       nfsrv_maxpnfsmirror > 1) &&
+				      j != NFSLAYOUT_FLEXFILE) ||
+				    (nfsrv_doflexfile == 0 &&
+				     j != NFSLAYOUT_NFSV4_1_FILES)))
+					*retcmpp = NFSERR_NOTSAME;
 			}
 			NFSDDSLOCK();
 			if (TAILQ_EMPTY(&nfsrv_devidhead)) {
@@ -2564,7 +2564,8 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount
 			if (siz == 2) {
 				NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
 				*tl++ = txdr_unsigned(1);	/* One entry. */
-				if (nfsrv_doflexfile != 0)
+				if (nfsrv_doflexfile != 0 ||
+				    nfsrv_maxpnfsmirror > 1)
 					*tl = txdr_unsigned(NFSLAYOUT_FLEXFILE);
 				else
 					*tl = txdr_unsigned(

Modified: projects/pnfs-planb-server/sys/fs/nfs/nfsproto.h
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfs/nfsproto.h	Fri Aug 25 21:42:56 2017	(r322904)
+++ projects/pnfs-planb-server/sys/fs/nfs/nfsproto.h	Fri Aug 25 21:53:51 2017	(r322905)
@@ -263,7 +263,7 @@
 				 NFSX_HYPER + NFSM_RNDUP(NFSX_V4PNFSFH))
 #define	NFSX_V4FLEXLAYOUT(m)	(NFSX_HYPER + 3 * NFSX_UNSIGNED +		\
     ((m) * (NFSX_V4DEVICEID + NFSX_STATEID + NFSM_RNDUP(NFSX_V4PNFSFH) +	\
-    6 * NFSX_UNSIGNED)))
+    8 * NFSX_UNSIGNED)))
 
 /* sizes common to multiple NFS versions */
 #define	NFSX_FHMAX		(NFSX_V4FHMAX)

Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdserv.c	Fri Aug 25 21:42:56 2017	(r322904)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdserv.c	Fri Aug 25 21:53:51 2017	(r322905)
@@ -68,8 +68,8 @@ SYSCTL_DECL(_vfs_nfsd);
 SYSCTL_INT(_vfs_nfsd, OID_AUTO, async, CTLFLAG_RW, &nfs_async, 0,
     "Tell client that writes were synced even though they were not");
 extern int	nfsrv_doflexfile;
-SYSCTL_INT(_vfs_nfsd, OID_AUTO, enable_flexfile, CTLFLAG_RW,
-    &nfsrv_doflexfile, 0, "Enable generation of Flex File Layouts for pNFS");
+SYSCTL_INT(_vfs_nfsd, OID_AUTO, default_flexfile, CTLFLAG_RW,
+    &nfsrv_doflexfile, 0, "Make Flex File Layout the default for pNFS");
 
 /*
  * This list defines the GSS mechanisms supported.
@@ -4373,9 +4373,9 @@ nfsrvd_layoutget(struct nfsrv_descript *nd, __unused i
 	}
 
 	layp = NULL;
-	if (layouttype == NFSLAYOUT_NFSV4_1_FILES && nfsrv_doflexfile == 0)
+	if (layouttype == NFSLAYOUT_NFSV4_1_FILES && nfsrv_maxpnfsmirror == 1)
 		layp = malloc(NFSX_V4FILELAYOUT, M_TEMP, M_WAITOK);
-	else if (layouttype == NFSLAYOUT_FLEXFILE && nfsrv_doflexfile != 0)
+	else if (layouttype == NFSLAYOUT_FLEXFILE)
 		layp = malloc(NFSX_V4FLEXLAYOUT(nfsrv_maxpnfsmirror), M_TEMP,
 		    M_WAITOK);
 	else
@@ -4610,13 +4610,17 @@ nfsrvd_getdevinfo(struct nfsrv_descript *nd, __unused 
 	cnt = fxdr_unsigned(int, *tl);
 	NFSD_DEBUG(4, "getdevinfo ltyp=%d maxcnt=%u bitcnt=%d\n", layouttype,
 	    maxcnt, cnt);
-	if (cnt > NFSV4_NOTIFYBITMAP) {
+	if (cnt > NFSV4_NOTIFYBITMAP || cnt < 0) {
 		nd->nd_repstat = NFSERR_INVAL;
 		goto nfsmout;
 	}
-	NFSM_DISSECT(tl, uint32_t *, cnt * NFSX_UNSIGNED);
-	for (i = 0; i < cnt; i++)
-		notify[i] = fxdr_unsigned(uint32_t, *tl++);
+	if (cnt > 0) {
+		NFSM_DISSECT(tl, uint32_t *, cnt * NFSX_UNSIGNED);
+		for (i = 0; i < cnt; i++)
+			notify[i] = fxdr_unsigned(uint32_t, *tl++);
+	}
+	for (i = cnt; i < NFSV4_NOTIFYBITMAP; i++)
+		notify[i] = 0;
 
 	/*
 	 * Check that the device id is not stale.  Device ids are recreated

Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c	Fri Aug 25 21:42:56 2017	(r322904)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c	Fri Aug 25 21:53:51 2017	(r322905)
@@ -36,7 +36,6 @@ int nfsrv_issuedelegs = 0;
 int nfsrv_dolocallocks = 0;
 struct nfsv4lock nfsv4rootfs_lock;
 time_t nfsdev_time = 0;
-int nfsrv_maxpnfsmirror = 1;
 
 extern int newnfs_numnfsd;
 extern struct nfsstatsv1 nfsstatsv1;
@@ -48,6 +47,7 @@ extern int nfsd_debuglevel;
 extern u_int nfsrv_dsdirsize;
 extern struct nfsdevicehead nfsrv_devidhead;
 extern int nfsrv_doflexfile;
+extern int nfsrv_maxpnfsmirror;
 NFSV4ROOTLOCKMUTEX;
 NFSSTATESPINLOCK;
 
@@ -6369,8 +6369,14 @@ nfsrv_filelayout(struct nfsrv_descript *nd, int iomode
 	return (lyp);
 }
 
+#define	FLEX_OWNERID	"999"
 /*
  * Generate a Flex File Layout.
+ * The FLEX_OWNERID can be any string of 3 decimal digits. Although this
+ * string goes on the wire, it isn't supposed to be used by the client,
+ * since this server uses tight coupling.
+ * The Linux Flexible File Layout client driver doesn't like a Null string
+ * for these.
  */
 static struct nfslayout *
 nfsrv_flexlayout(struct nfsrv_descript *nd, int iomode, int mirrorcnt,
@@ -6411,10 +6417,12 @@ nfsrv_flexlayout(struct nfsrv_descript *nd, int iomode
 		NFSBCOPY(dsfhp, tl, sizeof(*dsfhp));
 		tl += (NFSM_RNDUP(NFSX_V4PNFSFH) / NFSX_UNSIGNED);
 		dsfhp++;
-		*tl++ = 0;				/* Nil Owner. */
-		*tl++ = 0;				/* Nil Owner_group. */
+		*tl++ = txdr_unsigned(strlen(FLEX_OWNERID));	/* Any uid. */
+		NFSBCOPY(FLEX_OWNERID, tl++, NFSX_UNSIGNED);
+		*tl++ = txdr_unsigned(strlen(FLEX_OWNERID));	/* Any gid. */
+		NFSBCOPY(FLEX_OWNERID, tl++, NFSX_UNSIGNED);
 	}
-	*tl++ = txdr_unsigned(NFSFLEXFLAG_NOIO_MDS);	/* ff_flags. */
+	*tl++ = txdr_unsigned(0);		/* ff_flags. */
 	*tl = txdr_unsigned(60);		/* Status interval hint. */
 	lyp->lay_layoutlen = NFSX_V4FLEXLAYOUT(mirrorcnt);
 	return (lyp);
@@ -6598,9 +6606,11 @@ nfsrv_getdevinfo(char *devid, int layouttype, uint32_t
     uint32_t *notify, int *devaddrlen, char **devaddr)
 {
 	struct nfsdevice *ds, *mds;
-	int done, i;
+	int done;
 
-	if (layouttype != NFSLAYOUT_NFSV4_1_FILES)
+	if ((layouttype != NFSLAYOUT_NFSV4_1_FILES && layouttype !=
+	     NFSLAYOUT_FLEXFILE) ||
+	    (nfsrv_maxpnfsmirror > 1 && layouttype == NFSLAYOUT_NFSV4_1_FILES))
 		return (NFSERR_UNKNLAYOUTTYPE);
 
 	/*
@@ -6651,10 +6661,6 @@ nfsrv_getdevinfo(char *devid, int layouttype, uint32_t
 		*maxcnt = NFSM_RNDUP(*devaddrlen) + 3 * NFSX_UNSIGNED;
 		return (NFSERR_TOOSMALL);
 	}
-
-	/* No notifies for now. */
-	for (i = 0; i < NFSV4_NOTIFYBITMAP; i++)
-		*notify++ = 0;
 	return (0);
 }
 
@@ -6912,12 +6918,11 @@ nfsrv_allocdevid(struct nfsdevice *ds, char *addr, cha
 	 * as defined for Flexible File Layout) in XDR.
 	 */
 	addrlen = NFSM_RNDUP(strlen(addr)) + NFSM_RNDUP(strlen(netprot)) +
-	    10 * NFSX_UNSIGNED;
+	    9 * NFSX_UNSIGNED;
 	ds->nfsdev_flexaddrlen = addrlen;
 	tl = malloc(addrlen, M_NFSDSTATE, M_WAITOK | M_ZERO);
 	ds->nfsdev_flexaddr = (char *)tl;
-	*tl++ = txdr_unsigned(1);		/* One multipath list */
-	*tl++ = txdr_unsigned(1);		/* with one entry in it. */
+	*tl++ = txdr_unsigned(1);		/* One multipath entry. */
 	/* The netaddr for this one entry. */
 	*tl++ = txdr_unsigned(strlen(netprot));
 	NFSBCOPY(netprot, tl, strlen(netprot));



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