svn commit: r322127 - in projects/pnfs-planb-server-stable11/sys/fs: nfs nfsserver
Rick Macklem
rmacklem at FreeBSD.org
Mon Aug 7 00:59:49 UTC 2017
Author: rmacklem
Date: Mon Aug 7 00:59:47 2017
New Revision: 322127
URL: https://svnweb.freebsd.org/changeset/base/322127
Log:
Add some code for Flex Files layout. No semantic change.
Modified:
projects/pnfs-planb-server-stable11/sys/fs/nfs/nfs_var.h
projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsproto.h
projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdport.c
projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdstate.c
Modified: projects/pnfs-planb-server-stable11/sys/fs/nfs/nfs_var.h
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfs/nfs_var.h Sun Aug 6 22:14:54 2017 (r322126)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfs/nfs_var.h Mon Aug 7 00:59:47 2017 (r322127)
@@ -686,7 +686,8 @@ int nfsvno_testexp(struct nfsrv_descript *, struct nfs
uint32_t nfsrv_hashfh(fhandle_t *);
uint32_t nfsrv_hashsessionid(uint8_t *);
void nfsrv_backupstable(void);
-int nfsrv_dsgetdevandfh(struct vnode *, NFSPROC_T *, fhandle_t *, char *);
+int nfsrv_dsgetdevandfh(struct vnode *, NFSPROC_T *, int *, fhandle_t *,
+ char *);
int nfsrv_updatemdsattr(struct vnode *, struct nfsvattr *, NFSPROC_T *);
int nfsrv_dssetacl(struct vnode *, struct acl *, struct ucred *, NFSPROC_T *);
Modified: projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsproto.h
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsproto.h Sun Aug 6 22:14:54 2017 (r322126)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsproto.h Mon Aug 7 00:59:47 2017 (r322127)
@@ -658,6 +658,12 @@
#define NFSFLAYUTIL_COMMIT_THRU_MDS 0x2
#define NFSFLAYUTIL_STRIPE_MASK 0xffffffc0
+/* Flags for Flex File Layout. */
+#define NFSFLEXFLAG_NO_LAYOUTCOMMIT 0x00000001
+#define NFSFLEXFLAG_NOIO_MDS 0x00000002
+#define NFSFLEXFLAG_NO_READIO 0x00000004
+#define NFSFLEXFLAG_WRITE_ONEMIRROR 0x00000008
+
#if defined(_KERNEL) || defined(KERNEL)
/* Conversion macros */
#define vtonfsv2_mode(t,m) \
Modified: projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdport.c Sun Aug 6 22:14:54 2017 (r322126)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdport.c Mon Aug 7 00:59:47 2017 (r322127)
@@ -4478,7 +4478,8 @@ nfsrv_getattrdsrpc(fhandle_t *fhp, struct ucred *cred,
* Get the device id and file handle for a DS file.
*/
int
-nfsrv_dsgetdevandfh(struct vnode *vp, NFSPROC_T *p, fhandle_t *fhp, char *devid)
+nfsrv_dsgetdevandfh(struct vnode *vp, NFSPROC_T *p, int *mirrorcntp,
+ fhandle_t *fhp, char *devid)
{
int buflen, error;
char *buf;
@@ -4487,6 +4488,7 @@ nfsrv_dsgetdevandfh(struct vnode *vp, NFSPROC_T *p, fh
buf = malloc(buflen, M_TEMP, M_WAITOK);
error = nfsrv_dsgetsockmnt(vp, 0, buf, buflen, p, NULL, NULL, fhp,
devid, NULL);
+ *mirrorcntp = 1;
free(buf, M_TEMP);
return (error);
}
Modified: projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdstate.c Sun Aug 6 22:14:54 2017 (r322126)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdstate.c Mon Aug 7 00:59:47 2017 (r322127)
@@ -195,6 +195,10 @@ static void nfsrv_freealldevids(void);
static int nfsrv_findlayout(struct nfsrv_descript *nd, fhandle_t *fhp,
int laytype, NFSPROC_T *, struct nfslayout **lypp);
static int nfsrv_fndclid(nfsquad_t *clidvec, nfsquad_t clid, int clidcnt);
+static struct nfslayout *nfsrv_filelayout(struct nfsrv_descript *nd, int iomode,
+ fhandle_t *fhp, fhandle_t *dsfhp, char *devid);
+static struct nfslayout *nfsrv_flexlayout(struct nfsrv_descript *nd, int iomode,
+ int mirrorcnt, fhandle_t *fhp, fhandle_t *dsfhp, char *devid);
/*
* Scan the client list for a match and either return the current one,
@@ -6208,13 +6212,11 @@ nfsrv_layoutget(struct nfsrv_descript *nd, vnode_t vp,
uint64_t minlen, nfsv4stateid_t *stateidp, int maxcnt, int *retonclose,
int *layoutlenp, char *layp, struct ucred *cred, NFSPROC_T *p)
{
- uint32_t *tl;
struct nfslayouthash *lhyp;
struct nfslayout *lyp;
- char devid[NFSX_V4DEVICEID];
- fhandle_t fh, dsfh;
- uint64_t pattern_offset;
- int error;
+ char *devid;
+ fhandle_t fh, *dsfhp;
+ int error, mirrorcnt;
if (layouttype != NFSLAYOUT_NFSV4_1_FILES)
return (NFSERR_UNKNLAYOUTTYPE);
@@ -6283,19 +6285,55 @@ nfsrv_layoutget(struct nfsrv_descript *nd, vnode_t vp,
NFSUNLOCKLAYOUT(lhyp);
/* Find the device id and file handle. */
- error = nfsrv_dsgetdevandfh(vp, p, &dsfh, devid);
+ dsfhp = malloc(sizeof(fhandle_t) * nfsrv_maxpnfsmirror, M_TEMP,
+ M_WAITOK);
+ devid = malloc(NFSX_V4DEVICEID * nfsrv_maxpnfsmirror, M_TEMP, M_WAITOK);
+ 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);
+ }
+ free(dsfhp, M_TEMP);
+ free(devid, M_TEMP);
if (error != 0)
return (error);
+ /*
+ * Now, add this layout to the list.
+ */
+ error = nfsrv_addlayout(nd, &lyp, stateidp, layp, layoutlenp, p);
+ NFSD_DEBUG(4, "layoutget addl=%d\n", error);
+ /*
+ * The lyp will be set to NULL by nfsrv_addlayout() if it
+ * linked the new structure into the lists.
+ */
+ free(lyp, M_NFSDSTATE);
+ return (error);
+}
+
+/*
+ * Generate a File Layout.
+ */
+static struct nfslayout *
+nfsrv_filelayout(struct nfsrv_descript *nd, int iomode, fhandle_t *fhp,
+ fhandle_t *dsfhp, char *devid)
+{
+ uint32_t *tl;
+ struct nfslayout *lyp;
+ uint64_t pattern_offset;
+
lyp = malloc(sizeof(struct nfslayout) + NFSX_V4FILELAYOUT, M_NFSDSTATE,
M_WAITOK | M_ZERO);
- lyp->lay_type = layouttype;
- if (*iomode == NFSLAYOUTIOMODE_RW)
+ lyp->lay_type = NFSLAYOUT_NFSV4_1_FILES;
+ if (iomode == NFSLAYOUTIOMODE_RW)
lyp->lay_rw = 1;
else
lyp->lay_read = 1;
- NFSBCOPY(&fh, &lyp->lay_fh, sizeof(fh));
+ NFSBCOPY(fhp, &lyp->lay_fh, sizeof(*fhp));
lyp->lay_clientid.qval = nd->nd_clientid.qval;
/* Fill in the xdr for the files layout. */
@@ -6316,20 +6354,60 @@ nfsrv_layoutget(struct nfsrv_descript *nd, vnode_t vp,
txdr_hyper(pattern_offset, tl); tl += 2; /* Pattern offset. */
*tl++ = txdr_unsigned(1); /* 1 file handle. */
*tl++ = txdr_unsigned(NFSX_V4PNFSFH);
- NFSBCOPY(&dsfh, tl, sizeof(dsfh));
+ NFSBCOPY(dsfhp, tl, sizeof(*dsfhp));
lyp->lay_layoutlen = NFSX_V4FILELAYOUT;
+ return (lyp);
+}
- /*
- * Now, add this layout to the list.
- */
- error = nfsrv_addlayout(nd, &lyp, stateidp, layp, layoutlenp, p);
- NFSD_DEBUG(4, "layoutget addl=%d\n", error);
- /*
- * The lyp will be set to NULL by nfsrv_addlayout() if it
- * linked the new structure into the lists.
- */
- free(lyp, M_NFSDSTATE);
- return (error);
+/*
+ * Generate a Flex File Layout.
+ */
+static struct nfslayout *
+nfsrv_flexlayout(struct nfsrv_descript *nd, int iomode, int mirrorcnt,
+ fhandle_t *fhp, fhandle_t *dsfhp, char *devid)
+{
+ uint32_t *tl;
+ struct nfslayout *lyp;
+ uint64_t lenval;
+ int i;
+
+ lyp = malloc(sizeof(struct nfslayout) + NFSX_V4FLEXLAYOUT(mirrorcnt),
+ M_NFSDSTATE, M_WAITOK | M_ZERO);
+ lyp->lay_type = NFSLAYOUT_FLEXFILE;
+ if (iomode == NFSLAYOUTIOMODE_RW)
+ lyp->lay_rw = 1;
+ else
+ lyp->lay_read = 1;
+ NFSBCOPY(fhp, &lyp->lay_fh, sizeof(*fhp));
+ lyp->lay_clientid.qval = nd->nd_clientid.qval;
+
+ /* Fill in the xdr for the files layout. */
+ tl = (uint32_t *)lyp->lay_xdr;
+ lenval = 0;
+ txdr_hyper(lenval, tl); tl += 2; /* Stripe unit. */
+ *tl++ = txdr_unsigned(mirrorcnt); /* # of mirrors. */
+ for (i = 0; i < mirrorcnt; i++) {
+ *tl++ = txdr_unsigned(1); /* One stripe. */
+ NFSBCOPY(devid, tl, NFSX_V4DEVICEID); /* Device ID. */
+ tl += (NFSX_V4DEVICEID / NFSX_UNSIGNED);
+ devid += NFSX_V4DEVICEID;
+ *tl++ = txdr_unsigned(1); /* Efficiency. */
+ *tl++ = 0xffffffff; /* Proxy Stateid. */
+ *tl++ = 0x55555555;
+ *tl++ = 0x55555555;
+ *tl++ = 0x55555555;
+ *tl++ = txdr_unsigned(1); /* 1 file handle. */
+ *tl++ = txdr_unsigned(NFSX_V4PNFSFH);
+ 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(NFSFLEXFLAG_NOIO_MDS); /* ff_flags. */
+ *tl = txdr_unsigned(60); /* Status interval hint. */
+ lyp->lay_layoutlen = NFSX_V4FLEXLAYOUT(mirrorcnt);
+ return (lyp);
}
/*
More information about the svn-src-projects
mailing list