2 * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 /* Sysctl defaults. */
33 #define FHA_DEF_ENABLE 1
34 #define FHA_DEF_READ 1
35 #define FHA_DEF_WRITE 1
36 #define FHA_DEF_BIN_SHIFT 22 /* 4MB */
37 #define FHA_DEF_MAX_NFSDS_PER_FH 8
38 #define FHA_DEF_MAX_REQS_PER_NFSD 0 /* Unlimited */
40 #define FHA_HASH_SIZE 251
47 uint32_t max_nfsds_per_fh;
48 uint32_t max_reqs_per_nfsd;
52 * These are the entries in the filehandle hash. They talk about a specific
53 * file, requests against which are being handled by one or more nfsds. We
54 * keep a chain of nfsds against the file. We only have more than one if reads
55 * are ongoing, and then only if the reads affect disparate regions of the
58 * In general, we want to assign a new request to an existing nfsd if it is
59 * going to contend with work happening already on that nfsd, or if the
60 * operation is a read and the nfsd is already handling a proximate read. We
61 * do this to avoid jumping around in the read stream unnecessarily, and to
62 * avoid contention between threads over single files.
64 struct fha_hash_entry {
66 LIST_ENTRY(fha_hash_entry) link;
69 u_int32_t num_exclusive;
71 struct svcthread_list threads;
74 LIST_HEAD(fha_hash_entry_list, fha_hash_entry);
76 struct fha_hash_slot {
77 struct fha_hash_entry_list list;
81 /* A structure used for passing around data internally. */
90 struct fha_callbacks {
91 rpcproc_t (*get_procnum)(rpcproc_t procnum);
92 int (*realign)(struct mbuf **mb, int malloc_flags);
93 int (*get_fh)(uint64_t *fh, int v3, struct mbuf **md, caddr_t *dpos);
94 int (*is_read)(rpcproc_t procnum);
95 int (*is_write)(rpcproc_t procnum);
96 int (*get_offset)(struct mbuf **md, caddr_t *dpos, int v3, struct
98 int (*no_offset)(rpcproc_t procnum);
99 void (*set_locktype)(rpcproc_t procnum, struct fha_info *info);
100 int (*fhe_stats_sysctl)(SYSCTL_HANDLER_ARGS);
104 struct fha_hash_slot fha_hash[FHA_HASH_SIZE];
105 struct sysctl_ctx_list sysctl_ctx;
106 struct sysctl_oid *sysctl_tree;
107 struct fha_ctls ctls;
108 struct fha_callbacks callbacks;
109 char server_name[32];
113 void fha_nd_complete(SVCTHREAD *, struct svc_req *);
114 SVCTHREAD *fha_assign(SVCTHREAD *, struct svc_req *, struct fha_params *);
115 void fha_init(struct fha_params *softc);
116 void fha_uninit(struct fha_params *softc);
117 int fhe_stats_sysctl(SYSCTL_HANDLER_ARGS, struct fha_params *softc);
120 #endif /* _NFS_FHA_H_ */