Date: Mon, 7 Aug 2017 23:32:00 +0000 (UTC) From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r322208 - in projects/pnfs-planb-server/sys/fs: nfs nfsserver Message-ID: <201708072332.v77NW0MF056282@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rmacklem Date: Mon Aug 7 23:32:00 2017 New Revision: 322208 URL: https://svnweb.freebsd.org/changeset/base/322208 Log: Add some code for Flex Files layout. No semantic change. Configures the pNFS server to only do one layout type, which is required by Linux. Modified: projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c 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 Mon Aug 7 23:23:27 2017 (r322207) +++ projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c Mon Aug 7 23:32:00 2017 (r322208) @@ -68,6 +68,7 @@ gid_t nfsrv_defaultgid = GID_NOGROUP; int nfsrv_lease = NFSRV_LEASE; int ncl_mbuf_mlen = MLEN; int nfsd_enable_stringtouid = 0; +int nfsrv_doflexfile = 0; static int nfs_enable_uidtostring = 0; NFSNAMEIDMUTEX; NFSSOCKMUTEX; @@ -1775,13 +1776,16 @@ 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 != NFSLAYOUT_NFSV4_1_FILES) + if (compare && !(*retcmpp) && k != m) *retcmpp = NFSERR_NOTSAME; } } @@ -2560,7 +2564,11 @@ 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. */ - *tl = txdr_unsigned(NFSLAYOUT_NFSV4_1_FILES); + if (nfsrv_doflexfile != 0) + *tl = txdr_unsigned(NFSLAYOUT_FLEXFILE); + else + *tl = txdr_unsigned( + NFSLAYOUT_NFSV4_1_FILES); } else { NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); *tl = 0; Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdserv.c Mon Aug 7 23:23:27 2017 (r322207) +++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdserv.c Mon Aug 7 23:32:00 2017 (r322208) @@ -67,6 +67,9 @@ static int nfs_async = 0; 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"); /* * This list defines the GSS mechanisms supported. @@ -4370,9 +4373,9 @@ nfsrvd_layoutget(struct nfsrv_descript *nd, __unused i } layp = NULL; - if (layouttype == NFSLAYOUT_NFSV4_1_FILES) + if (layouttype == NFSLAYOUT_NFSV4_1_FILES && nfsrv_doflexfile == 0) layp = malloc(NFSX_V4FILELAYOUT, M_TEMP, M_WAITOK); - else if (layouttype == NFSLAYOUT_FLEXFILE) + else if (layouttype == NFSLAYOUT_FLEXFILE && nfsrv_doflexfile != 0) layp = malloc(NFSX_V4FLEXLAYOUT(nfsrv_maxpnfsmirror), M_TEMP, M_WAITOK); else Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c ============================================================================== --- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c Mon Aug 7 23:23:27 2017 (r322207) +++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c Mon Aug 7 23:32:00 2017 (r322208) @@ -6218,10 +6218,6 @@ nfsrv_layoutget(struct nfsrv_descript *nd, vnode_t vp, fhandle_t fh, *dsfhp; int error, mirrorcnt; - if (layouttype != NFSLAYOUT_NFSV4_1_FILES) - return (NFSERR_UNKNLAYOUTTYPE); - if (maxcnt < NFSX_V4FILELAYOUT) - return (NFSERR_TOOSMALL); NFSDDSLOCK(); if (TAILQ_EMPTY(&nfsrv_devidhead)) { NFSDDSUNLOCK(); @@ -6269,6 +6265,11 @@ nfsrv_layoutget(struct nfsrv_descript *nd, vnode_t vp, NFSD_DEBUG(1, "ret bad stateid\n"); return (NFSERR_BADSTATEID); } + if (lyp->lay_layoutlen > maxcnt) { + NFSUNLOCKLAYOUT(lhyp); + NFSD_DEBUG(1, "ret layout too small\n"); + return (NFSERR_TOOSMALL); + } if (*iomode == NFSLAYOUTIOMODE_RW) lyp->lay_rw = 1; else @@ -6291,11 +6292,19 @@ nfsrv_layoutget(struct nfsrv_descript *nd, vnode_t vp, error = nfsrv_dsgetdevandfh(vp, p, &mirrorcnt, dsfhp, devid); NFSD_DEBUG(4, "layoutget devandfh=%d\n", error); if (error == 0) { - if (layouttype == NFSLAYOUT_NFSV4_1_FILES) - lyp = nfsrv_filelayout(nd, *iomode, &fh, dsfhp, devid); - else - lyp = nfsrv_flexlayout(nd, *iomode, mirrorcnt, &fh, - dsfhp, devid); + if (layouttype == NFSLAYOUT_NFSV4_1_FILES) { + if (NFSX_V4FILELAYOUT > maxcnt) + error = NFSERR_TOOSMALL; + else + lyp = nfsrv_filelayout(nd, *iomode, &fh, dsfhp, + devid); + } else { + if (NFSX_V4FLEXLAYOUT(mirrorcnt) > maxcnt) + error = NFSERR_TOOSMALL; + else + lyp = nfsrv_flexlayout(nd, *iomode, mirrorcnt, + &fh, dsfhp, devid); + } } free(dsfhp, M_TEMP); free(devid, M_TEMP);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708072332.v77NW0MF056282>