Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Apr 2017 22:38:15 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r317612 - in projects/pnfs-planb-server/sys/fs: nfs nfsserver
Message-ID:  <201704302238.v3UMcFkr004843@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Sun Apr 30 22:38:15 2017
New Revision: 317612
URL: https://svnweb.freebsd.org/changeset/base/317612

Log:
  Two changes:
  - Add support for the FS_LAYOUTTYPES attribute.
  - Change the size of a stripe to an exact multiple of 64K.
  These two changes are needed to get the Linux client to do pNFS.
  
  There still appear to be some issues w.r.t. file size for the Linux client.

Modified:
  projects/pnfs-planb-server/sys/fs/nfs/nfs_commonport.c
  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_nfsdport.c
  projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c

Modified: projects/pnfs-planb-server/sys/fs/nfs/nfs_commonport.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfs/nfs_commonport.c	Sun Apr 30 19:37:45 2017	(r317611)
+++ projects/pnfs-planb-server/sys/fs/nfs/nfs_commonport.c	Sun Apr 30 22:38:15 2017	(r317612)
@@ -64,6 +64,8 @@ int nfscl_debuglevel = 0;
 char nfsv4_callbackaddr[INET6_ADDRSTRLEN];
 struct callout newnfsd_callout;
 int nfsrv_lughashsize = 100;
+struct mtx nfsrv_dslock_mtx;
+struct nfsdevicehead nfsrv_devidhead;
 void (*nfsd_call_servertimer)(void) = NULL;
 void (*ncl_call_invalcaches)(struct vnode *) = NULL;
 
@@ -693,6 +695,8 @@ nfscommon_modevent(module_t mod, int typ
 		mtx_init(&nfs_req_mutex, "nfs_req_mutex", NULL, MTX_DEF);
 		mtx_init(&nfsrv_nfsuserdsock.nr_mtx, "nfsuserd", NULL,
 		    MTX_DEF);
+		mtx_init(&nfsrv_dslock_mtx, "nfs4ds", NULL, MTX_DEF);
+		TAILQ_INIT(&nfsrv_devidhead);
 		callout_init(&newnfsd_callout, 1);
 		newnfs_init();
 		nfsd_call_nfscommon = nfssvc_nfscommon;
@@ -719,6 +723,7 @@ nfscommon_modevent(module_t mod, int typ
 		mtx_destroy(&nfs_slock_mutex);
 		mtx_destroy(&nfs_req_mutex);
 		mtx_destroy(&nfsrv_nfsuserdsock.nr_mtx);
+		mtx_destroy(&nfsrv_dslock_mtx);
 		loaded = 0;
 		break;
 	default:

Modified: projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c	Sun Apr 30 19:37:45 2017	(r317611)
+++ projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c	Sun Apr 30 22:38:15 2017	(r317612)
@@ -71,6 +71,8 @@ int nfsd_enable_stringtouid = 0;
 NFSNAMEIDMUTEX;
 NFSSOCKMUTEX;
 extern int nfsrv_lughashsize;
+extern struct mtx nfsrv_dslock_mtx;
+extern struct nfsdevicehead nfsrv_devidhead;
 
 /*
  * This array of structures indicates, for V4:
@@ -2535,6 +2537,23 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 			NFSCLRBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEACCESSSET);
 			retnum += nfsrv_putattrbit(nd, &attrbits);
 			break;
+		case NFSATTRBIT_FSLAYOUTTYPE:
+			NFSDDSLOCK();
+			if (TAILQ_EMPTY(&nfsrv_devidhead))
+				siz = 1;
+			else
+				siz = 2;
+			NFSDDSUNLOCK();
+			if (siz == 2) {
+				NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
+				*tl++ = txdr_unsigned(1);
+				*tl = txdr_unsigned(NFSLAYOUT_NFSV4_1_FILES);
+			} else {
+				NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
+				*tl = txdr_unsigned(0);
+			}
+			retnum += siz * NFSX_UNSIGNED;
+			break;
 		default:
 			printf("EEK! Bad V4 attribute bitpos=%d\n", bitpos);
 		}

Modified: projects/pnfs-planb-server/sys/fs/nfs/nfsproto.h
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfs/nfsproto.h	Sun Apr 30 19:37:45 2017	(r317611)
+++ projects/pnfs-planb-server/sys/fs/nfs/nfsproto.h	Sun Apr 30 22:38:15 2017	(r317612)
@@ -1031,7 +1031,8 @@ struct nfsv3_sattr {
  	NFSATTRBM_MOUNTEDONFILEID |					\
 	NFSATTRBM_QUOTAHARD |                        			\
     	NFSATTRBM_QUOTASOFT |                        			\
-    	NFSATTRBM_QUOTAUSED)
+    	NFSATTRBM_QUOTAUSED |						\
+	NFSATTRBM_FSLAYOUTTYPE)
 
 
 #ifdef QUOTA

Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c	Sun Apr 30 19:37:45 2017	(r317611)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c	Sun Apr 30 22:38:15 2017	(r317612)
@@ -66,6 +66,7 @@ extern int nfsrv_sessionhashsize;
 extern struct nfsstatsv1 nfsstatsv1;
 extern struct nfslayouthash *nfslayouthash;
 extern int nfsrv_layouthashsize;
+extern struct mtx nfsrv_dslock_mtx;
 struct vfsoptlist nfsv4root_opt, nfsv4root_newopt;
 NFSDLOCKMUTEX;
 NFSSTATESPINLOCK;
@@ -74,7 +75,6 @@ struct nfsrchash_bucket nfsrcahash_table
 struct mtx nfsrc_udpmtx;
 struct mtx nfs_v4root_mutex;
 struct nfsrvfh nfs_rootfh, nfs_pubfh;
-struct mtx nfsrv_dslock_mtx;
 int nfs_pubfhset = 0, nfs_rootfhset = 0;
 struct proc *nfsd_master_proc = NULL;
 int nfsd_debuglevel = 0;
@@ -4465,8 +4465,6 @@ nfsd_modevent(module_t mod, int type, vo
 		mtx_init(&nfs_v4root_mutex, "nfs4rt", NULL, MTX_DEF);
 		mtx_init(&nfsv4root_mnt.mnt_mtx, "nfs4mnt", NULL, MTX_DEF);
 		lockinit(&nfsv4root_mnt.mnt_explock, PVFS, "explock", 0, 0);
-		mtx_init(&nfsrv_dslock_mtx, "nfs4ds", NULL, MTX_DEF);
-		TAILQ_INIT(&nfsrv_devidhead);
 		nfsrvd_initcache();
 		nfsd_init();
 		NFSD_LOCK();
@@ -4518,7 +4516,6 @@ nfsd_modevent(module_t mod, int type, vo
 		for (i = 0; i < nfsrv_layouthashsize; i++)
 			mtx_destroy(&nfslayouthash[i].mtx);
 		lockdestroy(&nfsv4root_mnt.mnt_explock);
-		mtx_destroy(&nfsrv_dslock_mtx);
 		free(nfsclienthash, M_NFSDCLIENT);
 		free(nfslockhash, M_NFSDLOCKFILE);
 		free(nfssessionhash, M_NFSDSESSION);

Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c	Sun Apr 30 19:37:45 2017	(r317611)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c	Sun Apr 30 22:38:15 2017	(r317612)
@@ -35,7 +35,6 @@ struct nfsrv_stablefirst nfsrv_stablefir
 int nfsrv_issuedelegs = 0;
 int nfsrv_dolocallocks = 0;
 struct nfsv4lock nfsv4rootfs_lock;
-struct nfsdevicehead nfsrv_devidhead;
 time_t nfsdev_time = 0;
 
 extern int newnfs_numnfsd;
@@ -46,6 +45,7 @@ extern u_int32_t newnfs_true, newnfs_fal
 extern struct mtx nfsrv_dslock_mtx;
 extern int nfsd_debuglevel;
 extern u_int nfsrv_dsdirsize;
+extern struct nfsdevicehead nfsrv_devidhead;
 NFSV4ROOTLOCKMUTEX;
 NFSSTATESPINLOCK;
 
@@ -6201,7 +6201,7 @@ nfsrv_layoutget(struct nfsrv_descript *n
 	NFSDDSLOCK();
 	if (TAILQ_EMPTY(&nfsrv_devidhead)) {
 		NFSDDSUNLOCK();
-		return (NFSERR_LAYOUTTRYLATER);
+		return (NFSERR_UNKNLAYOUTTYPE);
 	}
 	NFSDDSUNLOCK();
 
@@ -6272,7 +6272,16 @@ nfsrv_layoutget(struct nfsrv_descript *n
 	tl = (uint32_t *)lyp->lay_xdr;
 	NFSBCOPY(devid, tl, NFSX_V4DEVICEID);		/* Device ID. */
 	tl += (NFSX_V4DEVICEID / NFSX_UNSIGNED);
-	*tl++ = txdr_unsigned(NFSFLAYUTIL_STRIPE_MASK);	/* Max stripe size. */
+
+	/*
+	 * Make the stripe size as many 64K blocks as will fit in the stripe
+	 * mask. Since there is only one stripe, the stripe size doesn't really
+	 * matter, except that the Linux client will only handle an exact
+	 * multiple of their PAGE_SIZE (usually 4K).  I chose 64K as a value
+	 * that should cover most/all arches w.r.t. PAGE_SIZE.
+	 */
+	*tl++ = txdr_unsigned(NFSFLAYUTIL_STRIPE_MASK & ~0xffff);
+
 	*tl++ = 0;					/* 1st stripe index. */
 	pattern_offset = 0;
 	txdr_hyper(pattern_offset, tl); tl += 2;	/* Pattern offset. */



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