svn commit: r322195 - in projects/pnfs-planb-server/sys/fs: nfs nfsserver
Rick Macklem
rmacklem at FreeBSD.org
Mon Aug 7 19:56:10 UTC 2017
Author: rmacklem
Date: Mon Aug 7 19:56:09 2017
New Revision: 322195
URL: https://svnweb.freebsd.org/changeset/base/322195
Log:
Add some code for Flex Files layout. No semantic change.
Modified:
projects/pnfs-planb-server/sys/fs/nfs/nfsrvstate.h
projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c
Modified: projects/pnfs-planb-server/sys/fs/nfs/nfsrvstate.h
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfs/nfsrvstate.h Mon Aug 7 19:52:15 2017 (r322194)
+++ projects/pnfs-planb-server/sys/fs/nfs/nfsrvstate.h Mon Aug 7 19:56:09 2017 (r322195)
@@ -336,7 +336,9 @@ struct nfsdevice {
char nfsdev_deviceid[NFSX_V4DEVICEID];
uint16_t nfsdev_hostnamelen;
uint16_t nfsdev_fileaddrlen;
+ uint16_t nfsdev_flexaddrlen;
char *nfsdev_fileaddr;
+ char *nfsdev_flexaddr;
char *nfsdev_host;
uint32_t nfsdev_nextdir;
vnode_t nfsdev_dsdir[0];
Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c Mon Aug 7 19:52:15 2017 (r322194)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c Mon Aug 7 19:56:09 2017 (r322195)
@@ -6608,25 +6608,29 @@ nfsrv_getdevinfo(char *devid, int layouttype, uint32_t
return (NFSERR_NOENT);
/* If the correct nfsdev_XXXXaddrlen is > 0, we have the device info. */
- if (layouttype == NFSLAYOUT_NFSV4_1_FILES &&
- ds->nfsdev_fileaddrlen > 0) {
- /*
- * The XDR overhead is 3 unsigned values: layout_type,
- * length_of_address and notify bitmap.
- * If the notify array is changed to not all zeros, the
- * count of unsigned values must be increased.
- */
- if (*maxcnt > 0 && *maxcnt <
- NFSM_RNDUP(ds->nfsdev_fileaddrlen) + 3 * NFSX_UNSIGNED) {
- *maxcnt = NFSM_RNDUP(ds->nfsdev_fileaddrlen) +
- 3 * NFSX_UNSIGNED;
- return (NFSERR_TOOSMALL);
- }
+ *devaddrlen = 0;
+ if (layouttype == NFSLAYOUT_NFSV4_1_FILES) {
*devaddrlen = ds->nfsdev_fileaddrlen;
*devaddr = ds->nfsdev_fileaddr;
- } else
+ } else if (layouttype == NFSLAYOUT_FLEXFILE) {
+ *devaddrlen = ds->nfsdev_flexaddrlen;
+ *devaddr = ds->nfsdev_flexaddr;
+ }
+ if (*devaddrlen == 0)
return (NFSERR_UNKNLAYOUTTYPE);
+ /*
+ * The XDR overhead is 3 unsigned values: layout_type,
+ * length_of_address and notify bitmap.
+ * If the notify array is changed to not all zeros, the
+ * count of unsigned values must be increased.
+ */
+ if (*maxcnt > 0 && *maxcnt < NFSM_RNDUP(*devaddrlen) +
+ 3 * NFSX_UNSIGNED) {
+ *maxcnt = NFSM_RNDUP(*devaddrlen) + 3 * NFSX_UNSIGNED;
+ return (NFSERR_TOOSMALL);
+ }
+
/* No notifies for now. */
for (i = 0; i < NFSV4_NOTIFYBITMAP; i++)
*notify++ = 0;
@@ -6682,6 +6686,7 @@ nfsrv_freedevid(struct nfsdevice *ds)
if (ds->nfsdev_dsdir[i] != NULL)
vrele(ds->nfsdev_dsdir[i]);
free(ds->nfsdev_fileaddr, M_NFSDSTATE);
+ free(ds->nfsdev_flexaddr, M_NFSDSTATE);
free(ds->nfsdev_host, M_NFSDSTATE);
free(ds, M_NFSDSTATE);
}
@@ -6845,6 +6850,31 @@ nfsrv_allocdevid(struct nfsdevice *ds, char *addr, cha
tl += (NFSM_RNDUP(strlen(netprot)) / NFSX_UNSIGNED);
*tl++ = txdr_unsigned(strlen(addr));
NFSBCOPY(addr, tl, strlen(addr));
+
+ /*
+ * Fill in the flex file addr (actually the ff_device_addr4
+ * as defined for Flexible File Layout) in XDR.
+ */
+ addrlen = NFSM_RNDUP(strlen(addr)) + NFSM_RNDUP(strlen(netprot)) +
+ 10 * 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. */
+ /* The netaddr for this one entry. */
+ *tl++ = txdr_unsigned(strlen(netprot));
+ NFSBCOPY(netprot, tl, strlen(netprot));
+ tl += (NFSM_RNDUP(strlen(netprot)) / NFSX_UNSIGNED);
+ *tl++ = txdr_unsigned(strlen(addr));
+ NFSBCOPY(addr, tl, strlen(addr));
+ tl += (NFSM_RNDUP(strlen(addr)) / NFSX_UNSIGNED);
+ *tl++ = txdr_unsigned(1); /* One NFS Version. */
+ *tl++ = txdr_unsigned(NFS_VER4); /* NFSv4. */
+ *tl++ = txdr_unsigned(NFSV41_MINORVERSION); /* Minor version 1. */
+ *tl++ = txdr_unsigned(NFS_SRVMAXIO); /* DS max rsize. */
+ *tl++ = txdr_unsigned(NFS_SRVMAXIO); /* DS max wsize. */
+ *tl = newnfs_true; /* Tightly coupled. */
ds->nfsdev_hostnamelen = strlen(dnshost);
ds->nfsdev_host = malloc(ds->nfsdev_hostnamelen, M_NFSDSTATE,
More information about the svn-src-projects
mailing list