svn commit: r249596 - in head/sys: conf fs/nfsserver modules/nfsd modules/nfsserver nfs nfsserver

Kenneth D. Merry ken at FreeBSD.org
Wed Apr 17 22:42:46 UTC 2013


Author: ken
Date: Wed Apr 17 22:42:43 2013
New Revision: 249596
URL: http://svnweb.freebsd.org/changeset/base/249596

Log:
  Move the NFS FHA (File Handle Affinity) code from sys/nfsserver to
  sys/nfs, since it is now shared by the two NFS servers.
  
  Suggested by:	rmacklem
  Sponsored by:	Spectra Logic
  MFC after:	2 weeks

Added:
  head/sys/nfs/nfs_fha.c
     - copied, changed from r249595, head/sys/nfsserver/nfs_fha.c
  head/sys/nfs/nfs_fha.h
     - copied unchanged from r249595, head/sys/nfsserver/nfs_fha.h
Deleted:
  head/sys/nfsserver/nfs_fha.c
  head/sys/nfsserver/nfs_fha.h
Modified:
  head/sys/conf/files
  head/sys/fs/nfsserver/nfs_fha_new.c
  head/sys/fs/nfsserver/nfs_nfsdkrpc.c
  head/sys/modules/nfsd/Makefile
  head/sys/modules/nfsserver/Makefile
  head/sys/nfsserver/nfs_fha_old.c
  head/sys/nfsserver/nfs_srvkrpc.c

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Wed Apr 17 21:21:27 2013	(r249595)
+++ head/sys/conf/files	Wed Apr 17 22:42:43 2013	(r249596)
@@ -3203,6 +3203,7 @@ nfs/bootp_subr.c		optional bootp nfsclie
 nfs/krpc_subr.c			optional bootp nfsclient | bootp nfscl
 nfs/nfs_common.c		optional nfsclient | nfsserver
 nfs/nfs_diskless.c		optional nfsclient nfs_root | nfscl nfs_root
+nfs/nfs_fha.c			optional nfsserver | nfsd
 nfs/nfs_lock.c			optional nfsclient | nfscl | nfslockd | nfsd
 nfsclient/nfs_bio.c		optional nfsclient
 nfsclient/nfs_node.c		optional nfsclient
@@ -3211,7 +3212,6 @@ nfsclient/nfs_subs.c		optional nfsclient
 nfsclient/nfs_nfsiod.c		optional nfsclient
 nfsclient/nfs_vfsops.c		optional nfsclient
 nfsclient/nfs_vnops.c		optional nfsclient
-nfsserver/nfs_fha.c		optional nfsserver | nfsd
 nfsserver/nfs_fha_old.c		optional nfsserver
 nfsserver/nfs_serv.c		optional nfsserver
 nfsserver/nfs_srvkrpc.c		optional nfsserver

Modified: head/sys/fs/nfsserver/nfs_fha_new.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_fha_new.c	Wed Apr 17 21:21:27 2013	(r249595)
+++ head/sys/fs/nfsserver/nfs_fha_new.c	Wed Apr 17 22:42:43 2013	(r249596)
@@ -30,11 +30,11 @@ __FBSDID("$FreeBSD$");
 #include <fs/nfs/nfsport.h>
 
 #include <rpc/rpc.h>
+#include <nfs/nfs_fha.h>
 #include <fs/nfs/xdr_subs.h>
 #include <fs/nfs/nfs.h>
 #include <fs/nfs/nfsproto.h>
 #include <fs/nfs/nfsm_subs.h>
-#include <nfsserver/nfs_fha.h>
 #include <fs/nfsserver/nfs_fha_new.h>
 
 static void fhanew_init(void *foo);

Modified: head/sys/fs/nfsserver/nfs_nfsdkrpc.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdkrpc.c	Wed Apr 17 21:21:27 2013	(r249595)
+++ head/sys/fs/nfsserver/nfs_nfsdkrpc.c	Wed Apr 17 22:42:43 2013	(r249596)
@@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
 #include <rpc/rpc.h>
 #include <rpc/rpcsec_gss.h>
 
-#include <nfsserver/nfs_fha.h>
+#include <nfs/nfs_fha.h>
 #include <fs/nfsserver/nfs_fha_new.h>
 
 #include <security/mac/mac_framework.h>

Modified: head/sys/modules/nfsd/Makefile
==============================================================================
--- head/sys/modules/nfsd/Makefile	Wed Apr 17 21:21:27 2013	(r249595)
+++ head/sys/modules/nfsd/Makefile	Wed Apr 17 22:42:43 2013	(r249596)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-.PATH: ${.CURDIR}/../../fs/nfsserver ${.CURDIR}/../../nfsserver
+.PATH: ${.CURDIR}/../../fs/nfsserver ${.CURDIR}/../../nfs
 KMOD=	nfsd
 SRCS=	vnode_if.h \
 	nfs_fha.c \

Modified: head/sys/modules/nfsserver/Makefile
==============================================================================
--- head/sys/modules/nfsserver/Makefile	Wed Apr 17 21:21:27 2013	(r249595)
+++ head/sys/modules/nfsserver/Makefile	Wed Apr 17 22:42:43 2013	(r249596)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-.PATH: ${.CURDIR}/../../nfsserver
+.PATH: ${.CURDIR}/../../nfsserver ${.CURDIR}/../../nfs
 KMOD=	nfsserver
 SRCS=	vnode_if.h \
 	nfs_fha.c nfs_fha_old.c nfs_serv.c nfs_srvkrpc.c nfs_srvsubs.c \

Copied and modified: head/sys/nfs/nfs_fha.c (from r249595, head/sys/nfsserver/nfs_fha.c)
==============================================================================
--- head/sys/nfsserver/nfs_fha.c	Wed Apr 17 21:21:27 2013	(r249595, copy source)
+++ head/sys/nfs/nfs_fha.c	Wed Apr 17 22:42:43 2013	(r249596)
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sbuf.h>
 
 #include <rpc/rpc.h>
-#include <nfsserver/nfs_fha.h>
+#include <nfs/nfs_fha.h>
 
 static MALLOC_DEFINE(M_NFS_FHA, "NFS FHA", "NFS FHA");
 

Copied: head/sys/nfs/nfs_fha.h (from r249595, head/sys/nfsserver/nfs_fha.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/nfs/nfs_fha.h	Wed Apr 17 22:42:43 2013	(r249596, copy of r249595, head/sys/nfsserver/nfs_fha.h)
@@ -0,0 +1,112 @@
+/*-
+ * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/* $FreeBSD$ */
+
+#ifndef	_NFS_FHA_H
+#define	_NFS_FHA_H 1
+
+#ifdef	_KERNEL
+
+/* Sysctl defaults. */
+#define FHA_DEF_ENABLE			1
+#define FHA_DEF_BIN_SHIFT		22 /* 4MB */
+#define FHA_DEF_MAX_NFSDS_PER_FH	8
+#define FHA_DEF_MAX_REQS_PER_NFSD	0  /* Unlimited */
+
+/* This is the global structure that represents the state of the fha system. */
+struct fha_global {
+	struct fha_hash_entry_list *hashtable;
+	u_long hashmask;
+};
+
+struct fha_ctls {
+	int	 enable;
+	uint32_t bin_shift;
+	uint32_t max_nfsds_per_fh;
+	uint32_t max_reqs_per_nfsd;
+};
+
+/*
+ * These are the entries in the filehandle hash.  They talk about a specific
+ * file, requests against which are being handled by one or more nfsds.  We
+ * keep a chain of nfsds against the file. We only have more than one if reads
+ * are ongoing, and then only if the reads affect disparate regions of the
+ * file.
+ *
+ * In general, we want to assign a new request to an existing nfsd if it is
+ * going to contend with work happening already on that nfsd, or if the
+ * operation is a read and the nfsd is already handling a proximate read.  We
+ * do this to avoid jumping around in the read stream unnecessarily, and to
+ * avoid contention between threads over single files.
+ */
+struct fha_hash_entry {
+	LIST_ENTRY(fha_hash_entry) link;
+	u_int64_t fh;
+	u_int32_t num_rw;
+	u_int32_t num_exclusive;
+	u_int8_t num_threads;
+	struct svcthread_list threads;
+};
+
+LIST_HEAD(fha_hash_entry_list, fha_hash_entry);
+
+/* A structure used for passing around data internally. */
+struct fha_info {
+	u_int64_t fh;
+	off_t offset;
+	int locktype;
+};
+
+struct fha_callbacks {
+	rpcproc_t (*get_procnum)(rpcproc_t procnum);
+	int (*realign)(struct mbuf **mb, int malloc_flags);
+	int (*get_fh)(fhandle_t *fh, int v3, struct mbuf **md, caddr_t *dpos);
+	int (*is_read)(rpcproc_t procnum);
+	int (*is_write)(rpcproc_t procnum);
+	int (*get_offset)(struct mbuf **md, caddr_t *dpos, int v3, struct
+			  fha_info *info);
+	int (*no_offset)(rpcproc_t procnum);
+	void (*set_locktype)(rpcproc_t procnum, struct fha_info *info);
+	int (*fhe_stats_sysctl)(SYSCTL_HANDLER_ARGS);
+};
+
+struct fha_params {
+	struct fha_global g_fha; 
+	struct sysctl_ctx_list sysctl_ctx;
+	struct sysctl_oid *sysctl_tree;
+	struct fha_ctls ctls;
+	struct fha_callbacks callbacks;
+	char server_name[32];
+	SVCPOOL **pool;
+};
+
+void fha_nd_complete(SVCTHREAD *, struct svc_req *);
+SVCTHREAD *fha_assign(SVCTHREAD *, struct svc_req *, struct fha_params *);
+void fha_init(struct fha_params *softc);
+void fha_uninit(struct fha_params *softc);
+int fhe_stats_sysctl(SYSCTL_HANDLER_ARGS, struct fha_params *softc);
+
+#endif /* _KERNEL */
+#endif /* _NFS_FHA_H_ */

Modified: head/sys/nfsserver/nfs_fha_old.c
==============================================================================
--- head/sys/nfsserver/nfs_fha_old.c	Wed Apr 17 21:21:27 2013	(r249595)
+++ head/sys/nfsserver/nfs_fha_old.c	Wed Apr 17 22:42:43 2013	(r249596)
@@ -40,9 +40,9 @@ __FBSDID("$FreeBSD$");
 #include <rpc/rpc.h>
 #include <nfs/xdr_subs.h>
 #include <nfs/nfsproto.h>
+#include <nfs/nfs_fha.h>
 #include <nfsserver/nfs.h>
 #include <nfsserver/nfsm_subs.h>
-#include <nfsserver/nfs_fha.h>
 #include <nfsserver/nfs_fha_old.h>
 
 static void fhaold_init(void *foo);

Modified: head/sys/nfsserver/nfs_srvkrpc.c
==============================================================================
--- head/sys/nfsserver/nfs_srvkrpc.c	Wed Apr 17 21:21:27 2013	(r249595)
+++ head/sys/nfsserver/nfs_srvkrpc.c	Wed Apr 17 22:42:43 2013	(r249596)
@@ -77,10 +77,10 @@ __FBSDID("$FreeBSD$");
 
 #include <nfs/xdr_subs.h>
 #include <nfs/nfsproto.h>
+#include <nfs/nfs_fha.h>
 #include <nfsserver/nfs.h>
 #include <nfsserver/nfsm_subs.h>
 #include <nfsserver/nfsrvcache.h>
-#include <nfsserver/nfs_fha.h>
 #include <nfsserver/nfs_fha_old.h>
 
 #include <security/mac/mac_framework.h>


More information about the svn-src-head mailing list