svn commit: r319816 - projects/pnfs-planb-server-stable11/sys/fs/nfs
Rick Macklem
rmacklem at FreeBSD.org
Sun Jun 11 00:17:09 UTC 2017
Author: rmacklem
Date: Sun Jun 11 00:17:07 2017
New Revision: 319816
URL: https://svnweb.freebsd.org/changeset/base/319816
Log:
Update some of the NFS .h files for the pNFS server.
Modified:
projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsport.h
projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsproto.h
projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsrvstate.h
Modified: projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsport.h
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsport.h Sun Jun 11 00:16:21 2017 (r319815)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsport.h Sun Jun 11 00:17:07 2017 (r319816)
@@ -707,6 +707,10 @@ void nfsrvd_rcv(struct socket *, void *, int);
#define NFSSESSIONMUTEXPTR(s) (&((s)->mtx))
#define NFSLOCKSESSION(s) mtx_lock(&((s)->mtx))
#define NFSUNLOCKSESSION(s) mtx_unlock(&((s)->mtx))
+#define NFSLOCKLAYOUT(l) mtx_lock(&((l)->mtx))
+#define NFSUNLOCKLAYOUT(l) mtx_unlock(&((l)->mtx))
+#define NFSDDSLOCK() mtx_lock(&nfsrv_dslock_mtx)
+#define NFSDDSUNLOCK() mtx_unlock(&nfsrv_dslock_mtx)
/*
* Use these macros to initialize/free a mutex.
Modified: projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsproto.h
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsproto.h Sun Jun 11 00:16:21 2017 (r319815)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsproto.h Sun Jun 11 00:17:07 2017 (r319816)
@@ -56,8 +56,22 @@
#define NFS_MAXDGRAMDATA 16384
#define NFS_MAXPATHLEN 1024
#define NFS_MAXNAMLEN 255
+/*
+ * Calculating the maximum XDR overhead for an NFS RPC isn't easy.
+ * NFS_MAXPKTHDR is antiquated and assume AUTH_SYS over UDP.
+ * NFS_MAXXDR should be sufficient for all NFS versions over TCP.
+ * It includes:
+ * - Maximum RPC message header. It can include 2 400byte authenticators plus
+ * a machine name of unlimited length, although it is usually relatively
+ * small.
+ * - XDR overheads for the NFSv4 compound. This can include Owner and
+ * Owner_group strings, which are usually fairly small, but are allowed
+ * to be up to 1024 bytes each.
+ * 4096 is overkill, but should always be sufficient.
+ */
#define NFS_MAXPKTHDR 404
-#define NFS_MAXPACKET (NFS_SRVMAXIO + 2048)
+#define NFS_MAXXDR 4096
+#define NFS_MAXPACKET (NFS_SRVMAXIO + NFS_MAXXDR)
#define NFS_MINPACKET 20
#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
#define NFSV4_MINORVERSION 0 /* V4 Minor version */
@@ -244,6 +258,10 @@
#define NFSX_V4SETTIME (NFSX_UNSIGNED + NFSX_V4TIME)
#define NFSX_V4SESSIONID 16
#define NFSX_V4DEVICEID 16
+#define NFSX_V4PNFSFH (sizeof(fhandle_t) + 1)
+#define NFSX_V4FILELAYOUT (4 * NFSX_UNSIGNED + NFSX_V4DEVICEID + \
+ NFSX_HYPER + NFSM_RNDUP(NFSX_V4PNFSFH))
+#define NFSX_V4MAXLAYOUT NFSX_V4FILELAYOUT
/* sizes common to multiple NFS versions */
#define NFSX_FHMAX (NFSX_V4FHMAX)
@@ -633,7 +651,9 @@
/* Flags for File Layout. */
#define NFSFLAYUTIL_DENSE 0x1
#define NFSFLAYUTIL_COMMIT_THRU_MDS 0x2
+#define NFSFLAYUTIL_STRIPE_MASK 0xffffffc0
+#if defined(_KERNEL) || defined(KERNEL)
/* Conversion macros */
#define vtonfsv2_mode(t,m) \
txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
@@ -783,6 +803,7 @@ struct nfsv3_sattr {
u_int32_t sa_mtimetype;
nfstime3 sa_mtime;
};
+#endif /* _KERNEL */
/*
* The attribute bits used for V4.
@@ -1010,7 +1031,8 @@ struct nfsv3_sattr {
NFSATTRBM_MOUNTEDONFILEID | \
NFSATTRBM_QUOTAHARD | \
NFSATTRBM_QUOTASOFT | \
- NFSATTRBM_QUOTAUSED)
+ NFSATTRBM_QUOTAUSED | \
+ NFSATTRBM_FSLAYOUTTYPE)
#ifdef QUOTA
@@ -1026,7 +1048,11 @@ struct nfsv3_sattr {
#define NFSATTRBIT_SUPP1 NFSATTRBIT_S1
#endif
-#define NFSATTRBIT_SUPP2 NFSATTRBM_SUPPATTREXCLCREAT
+#define NFSATTRBIT_SUPP2 \
+ (NFSATTRBM_LAYOUTTYPE | \
+ NFSATTRBM_LAYOUTBLKSIZE | \
+ NFSATTRBM_LAYOUTALIGNMENT | \
+ NFSATTRBM_SUPPATTREXCLCREAT)
/*
* NFSATTRBIT_SUPPSETONLY is the OR of NFSATTRBIT_TIMEACCESSSET and
@@ -1342,5 +1368,15 @@ struct nfsv4stateid {
u_int32_t other[NFSX_STATEIDOTHER / NFSX_UNSIGNED];
};
typedef struct nfsv4stateid nfsv4stateid_t;
+
+/* Notify bits and notify bitmap size. */
+#define NFSV4NOTIFY_CHANGE 1
+#define NFSV4NOTIFY_DELETE 2
+#define NFSV4_NOTIFYBITMAP 1 /* # of 32bit values needed for bits */
+
+/* Layoutreturn kinds. */
+#define NFSV4LAYOUTRET_FILE 1
+#define NFSV4LAYOUTRET_FSID 2
+#define NFSV4LAYOUTRET_ALL 3
#endif /* _NFS_NFSPROTO_H_ */
Modified: projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsrvstate.h
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsrvstate.h Sun Jun 11 00:16:21 2017 (r319815)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsrvstate.h Sun Jun 11 00:17:07 2017 (r319816)
@@ -29,6 +29,7 @@
#ifndef _NFS_NFSRVSTATE_H_
#define _NFS_NFSRVSTATE_H_
+#if defined(_KERNEL) || defined(KERNEL)
/*
* Definitions for NFS V4 server state handling.
*/
@@ -44,6 +45,8 @@ LIST_HEAD(nfslockhead, nfslock);
LIST_HEAD(nfslockhashhead, nfslockfile);
LIST_HEAD(nfssessionhead, nfsdsession);
LIST_HEAD(nfssessionhashhead, nfsdsession);
+LIST_HEAD(nfslayouthead, nfslayout);
+SLIST_HEAD(nfsdsdirhead, nfsdsdir);
/*
* List head for nfsusrgrp.
@@ -72,6 +75,13 @@ struct nfssessionhash {
#define NFSSESSIONHASH(f) \
(&nfssessionhash[nfsrv_hashsessionid(f) % nfsrv_sessionhashsize])
+struct nfslayouthash {
+ struct mtx mtx;
+ struct nfslayouthead list;
+};
+#define NFSLAYOUTHASH(f) \
+ (&nfslayouthash[nfsrv_hashfh(f) % nfsrv_layouthashsize])
+
/*
* Client server structure for V4. It is doubly linked into two lists.
* The first is a hash table based on the clientid and the second is a
@@ -110,6 +120,21 @@ struct nfsclient {
#define CLOPS_RENEWOP 0x0004
/*
+ * Structure for NFSv4.1 Layouts.
+ * Malloc'd to correct size for the lay_xdr.
+ */
+struct nfslayout {
+ LIST_ENTRY(nfslayout) lay_list;
+ nfsv4stateid_t lay_stateid;
+ nfsquad_t lay_clientid;
+ fhandle_t lay_fh;
+ uint16_t lay_layoutlen;
+ uint8_t lay_read;
+ uint8_t lay_rw;
+ char lay_xdr[0];
+};
+
+/*
* Structure for an NFSv4.1 session.
* Locking rules for this structure.
* To add/delete one of these structures from the lists, you must lock
@@ -153,6 +178,7 @@ struct nfsdsession {
* - open file structures chained off an open_owner structure
* - lock_owner structures chained off an open file structure
* - delegated file structures chained off of nfsclient and nfslockfile
+ * - pNFS layouts chained off of nfsclient and nfslockfile
* - the ls_list field is used for the chain it is in
* - the ls_head structure is used to chain off the sibling structure
* (it is a union between an nfsstate and nfslock structure head)
@@ -186,8 +212,9 @@ struct nfsstate {
struct nfslockfile *ls_lfp; /* Back pointer */
struct nfsrvcache *ls_op; /* Op cache reference */
struct nfsclient *ls_clp; /* Back pointer */
- u_short ls_ownerlen; /* Length of ls_owner */
+ u_int32_t ls_ownerlen; /* Length of ls_owner */
u_char ls_owner[1]; /* malloc'd the correct size */
+ /* Must be uint32_t * aligned */
};
#define ls_lock ls_head.lock
#define ls_open ls_head.open
@@ -199,6 +226,8 @@ struct nfsstate {
#define ls_delegtime ls_un.deleg.expiry
#define ls_delegtimelimit ls_un.deleg.limit
#define ls_compref ls_un.deleg.compref
+#define ls_layout ls_owner
+#define ls_layoutlen ls_ownerlen
/*
* Nfs lock structure.
@@ -249,6 +278,7 @@ struct nfsrollback {
struct nfslockfile {
LIST_HEAD(, nfsstate) lf_open; /* Open list */
LIST_HEAD(, nfsstate) lf_deleg; /* Delegation list */
+ LIST_HEAD(, nfsstate) lf_layout; /* Layout list */
LIST_HEAD(, nfslock) lf_lock; /* Lock list */
LIST_HEAD(, nfslock) lf_locallock; /* Local lock list */
LIST_HEAD(, nfsrollback) lf_rollback; /* Local lock rollback list */
@@ -288,9 +318,56 @@ struct nfsf_rec {
u_int32_t numboots; /* Number of boottimes */
};
-#if defined(_KERNEL) || defined(KERNEL)
void nfsrv_cleanclient(struct nfsclient *, NFSPROC_T *);
void nfsrv_freedeleglist(struct nfsstatehead *);
-#endif
+
+/*
+ * This structure is used to create the list of device info entries for
+ * a GetDeviceInfo operation and stores the DS server info.
+ * The nfsdev_addrandhost field has the fully qualified host domain name
+ * followed by the network address in XDR.
+ * It is allocated with nfsrv_dsdirsize nfsdev_dsdir[] entries.
+ */
+struct nfsdevice {
+ TAILQ_ENTRY(nfsdevice) nfsdev_list;
+ vnode_t nfsdev_dvp;
+ struct nfsmount *nfsdev_nmp;
+ char nfsdev_deviceid[NFSX_V4DEVICEID];
+ uint16_t nfsdev_hostnamelen;
+ uint16_t nfsdev_fileaddrlen;
+ char *nfsdev_fileaddr;
+ char *nfsdev_host;
+ uint32_t nfsdev_nextdir;
+ vnode_t nfsdev_dsdir[0];
+};
+TAILQ_HEAD(nfsdevicehead, nfsdevice);
+
+/*
+ * This structure holds the va_size, va_filerev and va_mtime for the DS
+ * file and is stored in the metadata file's extended attribute pnfsd.dsattr.
+ */
+struct pnfsdsattr {
+ uint64_t dsa_filerev;
+ uint64_t dsa_size;
+ struct timespec dsa_mtime;
+};
+
+#endif /* defined(_KERNEL) || defined(KERNEL) */
+
+/*
+ * This structure holds the information about the DS file and is stored
+ * in the metadata file's extended attribute called pnfsd.dsfile.
+ * dsf_nam[0] is defined as the actual length of sa_len for the addr.
+ */
+struct pnfsdsfile {
+ fhandle_t dsf_fh;
+ uint32_t dsf_dir;
+ union {
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
+ } dsf_nam;
+};
+#define dsf_sin dsf_nam.sin
+#define dsf_sin6 dsf_nam.sin6
#endif /* _NFS_NFSRVSTATE_H_ */
More information about the svn-src-projects
mailing list