nfs_fha.h revision 1.1 1 1.1 dholland /* $NetBSD: nfs_fha.h,v 1.1 2013/09/30 07:19:33 dholland Exp $ */
2 1.1 dholland /*-
3 1.1 dholland * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
4 1.1 dholland *
5 1.1 dholland * Redistribution and use in source and binary forms, with or without
6 1.1 dholland * modification, are permitted provided that the following conditions
7 1.1 dholland * are met:
8 1.1 dholland * 1. Redistributions of source code must retain the above copyright
9 1.1 dholland * notice, this list of conditions and the following disclaimer.
10 1.1 dholland * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 dholland * notice, this list of conditions and the following disclaimer in the
12 1.1 dholland * documentation and/or other materials provided with the distribution.
13 1.1 dholland *
14 1.1 dholland * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 1.1 dholland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 1.1 dholland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 1.1 dholland * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 1.1 dholland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 1.1 dholland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 1.1 dholland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 1.1 dholland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 1.1 dholland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 1.1 dholland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 1.1 dholland * SUCH DAMAGE.
25 1.1 dholland */
26 1.1 dholland /* FreeBSD: head/sys/nfs/nfs_fha.h 249596 2013-04-17 22:42:43Z ken */
27 1.1 dholland /* $NetBSD: nfs_fha.h,v 1.1 2013/09/30 07:19:33 dholland Exp $ */
28 1.1 dholland
29 1.1 dholland #ifndef _NFS_FHA_H
30 1.1 dholland #define _NFS_FHA_H 1
31 1.1 dholland
32 1.1 dholland #ifdef _KERNEL
33 1.1 dholland
34 1.1 dholland /* Sysctl defaults. */
35 1.1 dholland #define FHA_DEF_ENABLE 1
36 1.1 dholland #define FHA_DEF_BIN_SHIFT 22 /* 4MB */
37 1.1 dholland #define FHA_DEF_MAX_NFSDS_PER_FH 8
38 1.1 dholland #define FHA_DEF_MAX_REQS_PER_NFSD 0 /* Unlimited */
39 1.1 dholland
40 1.1 dholland /* This is the global structure that represents the state of the fha system. */
41 1.1 dholland struct fha_global {
42 1.1 dholland struct fha_hash_entry_list *hashtable;
43 1.1 dholland u_long hashmask;
44 1.1 dholland };
45 1.1 dholland
46 1.1 dholland struct fha_ctls {
47 1.1 dholland int enable;
48 1.1 dholland uint32_t bin_shift;
49 1.1 dholland uint32_t max_nfsds_per_fh;
50 1.1 dholland uint32_t max_reqs_per_nfsd;
51 1.1 dholland };
52 1.1 dholland
53 1.1 dholland /*
54 1.1 dholland * These are the entries in the filehandle hash. They talk about a specific
55 1.1 dholland * file, requests against which are being handled by one or more nfsds. We
56 1.1 dholland * keep a chain of nfsds against the file. We only have more than one if reads
57 1.1 dholland * are ongoing, and then only if the reads affect disparate regions of the
58 1.1 dholland * file.
59 1.1 dholland *
60 1.1 dholland * In general, we want to assign a new request to an existing nfsd if it is
61 1.1 dholland * going to contend with work happening already on that nfsd, or if the
62 1.1 dholland * operation is a read and the nfsd is already handling a proximate read. We
63 1.1 dholland * do this to avoid jumping around in the read stream unnecessarily, and to
64 1.1 dholland * avoid contention between threads over single files.
65 1.1 dholland */
66 1.1 dholland struct fha_hash_entry {
67 1.1 dholland LIST_ENTRY(fha_hash_entry) link;
68 1.1 dholland u_int64_t fh;
69 1.1 dholland u_int32_t num_rw;
70 1.1 dholland u_int32_t num_exclusive;
71 1.1 dholland u_int8_t num_threads;
72 1.1 dholland struct svcthread_list threads;
73 1.1 dholland };
74 1.1 dholland
75 1.1 dholland LIST_HEAD(fha_hash_entry_list, fha_hash_entry);
76 1.1 dholland
77 1.1 dholland /* A structure used for passing around data internally. */
78 1.1 dholland struct fha_info {
79 1.1 dholland u_int64_t fh;
80 1.1 dholland off_t offset;
81 1.1 dholland int locktype;
82 1.1 dholland };
83 1.1 dholland
84 1.1 dholland struct fha_callbacks {
85 1.1 dholland rpcproc_t (*get_procnum)(rpcproc_t procnum);
86 1.1 dholland int (*realign)(struct mbuf **mb, int malloc_flags);
87 1.1 dholland int (*get_fh)(fhandle_t *fh, int v3, struct mbuf **md, caddr_t *dpos);
88 1.1 dholland int (*is_read)(rpcproc_t procnum);
89 1.1 dholland int (*is_write)(rpcproc_t procnum);
90 1.1 dholland int (*get_offset)(struct mbuf **md, caddr_t *dpos, int v3, struct
91 1.1 dholland fha_info *info);
92 1.1 dholland int (*no_offset)(rpcproc_t procnum);
93 1.1 dholland void (*set_locktype)(rpcproc_t procnum, struct fha_info *info);
94 1.1 dholland int (*fhe_stats_sysctl)(SYSCTL_HANDLER_ARGS);
95 1.1 dholland };
96 1.1 dholland
97 1.1 dholland struct fha_params {
98 1.1 dholland struct fha_global g_fha;
99 1.1 dholland struct sysctl_ctx_list sysctl_ctx;
100 1.1 dholland struct sysctl_oid *sysctl_tree;
101 1.1 dholland struct fha_ctls ctls;
102 1.1 dholland struct fha_callbacks callbacks;
103 1.1 dholland char server_name[32];
104 1.1 dholland SVCPOOL **pool;
105 1.1 dholland };
106 1.1 dholland
107 1.1 dholland void fha_nd_complete(SVCTHREAD *, struct svc_req *);
108 1.1 dholland SVCTHREAD *fha_assign(SVCTHREAD *, struct svc_req *, struct fha_params *);
109 1.1 dholland void fha_init(struct fha_params *softc);
110 1.1 dholland void fha_uninit(struct fha_params *softc);
111 1.1 dholland int fhe_stats_sysctl(SYSCTL_HANDLER_ARGS, struct fha_params *softc);
112 1.1 dholland
113 1.1 dholland #endif /* _KERNEL */
114 1.1 dholland #endif /* _NFS_FHA_H_ */
115