Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Apr 2018 22:28:41 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r332797 - projects/pnfs-planb-server/sys/fs/nfs
Message-ID:  <201804192228.w3JMSfC6075082@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Thu Apr 19 22:28:41 2018
New Revision: 332797
URL: https://svnweb.freebsd.org/changeset/base/332797

Log:
  Update three more files for mirrored DS recovery.

Modified:
  projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c
  projects/pnfs-planb-server/sys/fs/nfs/nfs_var.h
  projects/pnfs-planb-server/sys/fs/nfs/nfsrvstate.h

Modified: projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c	Thu Apr 19 21:53:57 2018	(r332796)
+++ projects/pnfs-planb-server/sys/fs/nfs/nfs_commonsubs.c	Thu Apr 19 22:28:41 2018	(r332797)
@@ -77,6 +77,8 @@ NFSNAMEIDMUTEX;
 NFSSOCKMUTEX;
 extern int nfsrv_lughashsize;
 extern struct mtx nfsrv_dslock_mtx;
+extern volatile int nfsrv_devidcnt;
+extern int nfscl_debuglevel;
 extern struct nfsdevicehead nfsrv_devidhead;
 
 SYSCTL_DECL(_vfs_nfs);
@@ -491,7 +493,7 @@ nfsm_fhtom(struct nfsrv_descript *nd, u_int8_t *fhp, i
 {
 	u_int32_t *tl;
 	u_int8_t *cp;
-	int fullsiz, bytesize = 0;
+	int fullsiz, rem, bytesize = 0;
 
 	if (size == 0)
 		size = NFSX_MYFH;
@@ -508,6 +510,7 @@ nfsm_fhtom(struct nfsrv_descript *nd, u_int8_t *fhp, i
 	case ND_NFSV3:
 	case ND_NFSV4:
 		fullsiz = NFSM_RNDUP(size);
+		rem = fullsiz - size;
 		if (set_true) {
 		    bytesize = 2 * NFSX_UNSIGNED + fullsiz;
 		    NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
@@ -1790,15 +1793,13 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
 				     j != NFSLAYOUT_NFSV4_1_FILES)))
 					*retcmpp = NFSERR_NOTSAME;
 			}
-			NFSDDSLOCK();
-			if (TAILQ_EMPTY(&nfsrv_devidhead)) {
+			if (nfsrv_devidcnt == 0) {
 				if (compare && !(*retcmpp) && i > 0)
 					*retcmpp = NFSERR_NOTSAME;
 			} else {
 				if (compare && !(*retcmpp) && i != 1)
 					*retcmpp = NFSERR_NOTSAME;
 			}
-			NFSDDSUNLOCK();
 			break;
 		case NFSATTRBIT_LAYOUTALIGNMENT:
 		case NFSATTRBIT_LAYOUTBLKSIZE:
@@ -2556,12 +2557,10 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount
 			break;
 		case NFSATTRBIT_FSLAYOUTTYPE:
 		case NFSATTRBIT_LAYOUTTYPE:
-			NFSDDSLOCK();
-			if (TAILQ_EMPTY(&nfsrv_devidhead))
+			if (nfsrv_devidcnt == 0)
 				siz = 1;
 			else
 				siz = 2;
-			NFSDDSUNLOCK();
 			if (siz == 2) {
 				NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
 				*tl++ = txdr_unsigned(1);	/* One entry. */
@@ -4307,5 +4306,51 @@ nfsv4_freeslot(struct nfsclsession *sep, int slot)
 	sep->nfsess_slots &= ~bitval;
 	wakeup(&sep->nfsess_slots);
 	mtx_unlock(&sep->nfsess_mtx);
+}
+
+/*
+ * Search for a matching pnfsd mirror device structure, base on the nmp arg.
+ * Return one if found, NULL otherwise.
+ */
+struct nfsdevice *
+nfsv4_findmirror(struct nfsmount *nmp, struct nfsdevice **fndpardsp)
+{
+	struct nfsdevice *ds, *mds, *fndds;
+
+	mtx_assert(NFSDDSMUTEXPTR, MA_OWNED);
+	/*
+	 * Search the DS server list for a match with dvp.
+	 * Remove the DS entry if found and there is a mirror.
+	 */
+	fndds = NULL;
+	if (fndpardsp != NULL)
+		*fndpardsp = NULL;
+	if (nfsrv_devidcnt == 0)
+		return (fndds);
+	TAILQ_FOREACH(ds, &nfsrv_devidhead, nfsdev_list) {
+		if (fndds != NULL)
+			break;
+		if (ds->nfsdev_nmp == nmp) {
+			/* If there are no mirrors, return error. */
+			if (TAILQ_EMPTY(&ds->nfsdev_mirrors)) {
+				NFSCL_DEBUG(4, "no mirror for DS\n");
+				return (NULL);
+			}
+			NFSCL_DEBUG(4, "fnd main ds\n");
+			fndds = ds;
+			break;
+		} else {
+			TAILQ_FOREACH(mds, &ds->nfsdev_mirrors, nfsdev_list) {
+				if (mds->nfsdev_nmp == nmp) {
+					NFSCL_DEBUG(4, "fnd mirror ds\n");
+					fndds = mds;
+					if (fndpardsp != NULL)
+						*fndpardsp = ds;
+					break;
+				}
+			}
+		}
+	}
+	return (fndds);
 }
 

Modified: projects/pnfs-planb-server/sys/fs/nfs/nfs_var.h
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfs/nfs_var.h	Thu Apr 19 21:53:57 2018	(r332796)
+++ projects/pnfs-planb-server/sys/fs/nfs/nfs_var.h	Thu Apr 19 22:28:41 2018	(r332797)
@@ -83,6 +83,9 @@ struct nfsv4lock;
 struct nfsvattr;
 struct nfs_vattr;
 struct NFSSVCARGS;
+struct nfsdevice;
+struct pnfsdsfile;
+struct pnfsdsattr;
 #ifdef __FreeBSD__
 NFS_ACCESS_ARGS;
 NFS_OPEN_ARGS;
@@ -145,13 +148,23 @@ int nfsrv_layoutcommit(struct nfsrv_descript *, vnode_
 int nfsrv_layoutget(struct nfsrv_descript *, vnode_t, struct nfsexstuff *,
     int, int *, uint64_t *, uint64_t *, uint64_t, nfsv4stateid_t *, int, int *,
     int *, char *, struct ucred *, NFSPROC_T *);
+void nfsrv_flexmirrordel(char *, NFSPROC_T *);
 int nfsrv_layoutreturn(struct nfsrv_descript *, vnode_t, int, int, uint64_t,
-    uint64_t, int, int, nfsv4stateid_t *, int, char *, int *, struct ucred *,
-    NFSPROC_T *);
+    uint64_t, int, int, nfsv4stateid_t *, int, uint32_t *, int *,
+    struct ucred *, NFSPROC_T *);
 int nfsrv_getdevinfo(char *, int, uint32_t *, uint32_t *, int *, char **);
+void nfsrv_freeonedevid(struct nfsdevice *);
 void nfsrv_freealllayoutsanddevids(void);
+int nfsrv_deldsserver(char *, NFSPROC_T *);
+struct nfsdevice *nfsrv_deldsnmp(struct nfsmount *, NFSPROC_T *);
 int nfsrv_createdevids(struct nfsd_nfsd_args *, NFSPROC_T *);
 int nfsrv_checkdsattr(struct nfsrv_descript *, vnode_t, NFSPROC_T *);
+int nfsrv_copymr(vnode_t, vnode_t, vnode_t, struct nfsdevice *,
+    struct pnfsdsfile *, struct pnfsdsfile *, int, struct ucred *,
+    NFSPROC_T *);
+int nfsrv_mdscopymr(char *, char *, char *, char *, int *, NFSPROC_T *,
+    struct vnode **, struct vnode **, struct pnfsdsfile **,
+    struct nfsdevice **);
 
 /* nfs_nfsdserv.c */
 int nfsrvd_access(struct nfsrv_descript *, int,
@@ -324,6 +337,7 @@ int nfsv4_sequencelookup(struct nfsmount *, struct nfs
     int *, uint32_t *, uint8_t *);
 void nfsv4_freeslot(struct nfsclsession *, int);
 struct ucred *nfsrv_getgrpscred(struct ucred *);
+struct nfsdevice *nfsv4_findmirror(struct nfsmount *, struct nfsdevice **);
 
 /* nfs_clcomsubs.c */
 void nfsm_uiombuf(struct nfsrv_descript *, struct uio *, int);
@@ -687,8 +701,16 @@ uint32_t nfsrv_hashsessionid(uint8_t *);
 void nfsrv_backupstable(void);
 int nfsrv_dsgetdevandfh(struct vnode *, NFSPROC_T *, int *, fhandle_t *,
     char *);
+int nfsrv_dsgetsockmnt(struct vnode *, int, char *, int *, int *,
+    NFSPROC_T *, struct vnode **, struct nfsmount **, fhandle_t *, char *,
+    char *, struct vnode **, struct nfsmount *, struct nfsmount *, int *,
+    int *);
+int nfsrv_dscreate(struct vnode *, struct vattr *, struct vattr *,
+    fhandle_t *, struct pnfsdsfile *, struct pnfsdsattr *, char *,
+    struct ucred *, NFSPROC_T *, struct vnode **);
 int nfsrv_updatemdsattr(struct vnode *, struct nfsvattr *, NFSPROC_T *);
 int nfsrv_dssetacl(struct vnode *, struct acl *, struct ucred *, NFSPROC_T *);
+void nfsrv_killrpcs(struct nfsmount *);
 
 /* nfs_commonkrpc.c */
 int newnfs_nmcancelreqs(struct nfsmount *);

Modified: projects/pnfs-planb-server/sys/fs/nfs/nfsrvstate.h
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfs/nfsrvstate.h	Thu Apr 19 21:53:57 2018	(r332796)
+++ projects/pnfs-planb-server/sys/fs/nfs/nfsrvstate.h	Thu Apr 19 22:28:41 2018	(r332797)
@@ -50,6 +50,7 @@ LIST_HEAD(nfssessionhashhead, nfsdsession);
 LIST_HEAD(nfslayouthead, nfslayout);
 SLIST_HEAD(nfsdsdirhead, nfsdsdir);
 TAILQ_HEAD(nfsdevicehead, nfsdevice);
+LIST_HEAD(nfsdontlisthead, nfsdontlist);
 
 /*
  * List head for nfsusrgrp.
@@ -132,12 +133,18 @@ struct nfslayout {
 	nfsquad_t		lay_clientid;
 	fhandle_t		lay_fh;
 	uint32_t		lay_layoutlen;
+	uint32_t		lay_mirrorcnt;
 	uint16_t		lay_type;
-	uint8_t			lay_read;
-	uint8_t			lay_rw;
-	char			lay_xdr[0];
+	uint16_t		lay_flags;
+	uint32_t		lay_xdr[0];
 };
 
+/* Flags for lay_flags. */
+#define	NFSLAY_READ	0x0001
+#define	NFSLAY_RW	0x0002
+#define	NFSLAY_RECALL	0x0004
+#define	NFSLAY_RETURNED	0x0008
+
 /*
  * Structure for an NFSv4.1 session.
  * Locking rules for this structure.
@@ -359,6 +366,19 @@ struct pnfsdsattr {
 	struct timespec	dsa_atime;
 	struct timespec	dsa_mtime;
 };
+
+/*
+ * This structure is a list element for a list the pNFS server uses to
+ * mark that the recovery of a mirror file is in progress.
+ */
+struct nfsdontlist {
+	LIST_ENTRY(nfsdontlist)	nfsmr_list;
+	uint32_t		nfsmr_flags;
+	fhandle_t		nfsmr_fh;
+};
+
+/* nfsmr_flags bits. */
+#define	NFSMR_DONTLAYOUT	0x00000001
 
 #endif	/* defined(_KERNEL) || defined(KERNEL) */
 



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