1 1.3 pgoyette /* $NetBSD: nfs_fha.h,v 1.3 2016/11/18 08:31:30 pgoyette 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.3 pgoyette /* FreeBSD: head/sys/nfs/nfs_fha.h 260097 2013-12-30 20:23:15Z mav */ 27 1.3 pgoyette /* $NetBSD: nfs_fha.h,v 1.3 2016/11/18 08:31:30 pgoyette 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.3 pgoyette #define FHA_HASH_SIZE 251 41 1.1 dholland 42 1.1 dholland struct fha_ctls { 43 1.1 dholland int enable; 44 1.1 dholland uint32_t bin_shift; 45 1.1 dholland uint32_t max_nfsds_per_fh; 46 1.1 dholland uint32_t max_reqs_per_nfsd; 47 1.1 dholland }; 48 1.1 dholland 49 1.1 dholland /* 50 1.1 dholland * These are the entries in the filehandle hash. They talk about a specific 51 1.1 dholland * file, requests against which are being handled by one or more nfsds. We 52 1.1 dholland * keep a chain of nfsds against the file. We only have more than one if reads 53 1.1 dholland * are ongoing, and then only if the reads affect disparate regions of the 54 1.1 dholland * file. 55 1.1 dholland * 56 1.1 dholland * In general, we want to assign a new request to an existing nfsd if it is 57 1.1 dholland * going to contend with work happening already on that nfsd, or if the 58 1.1 dholland * operation is a read and the nfsd is already handling a proximate read. We 59 1.1 dholland * do this to avoid jumping around in the read stream unnecessarily, and to 60 1.1 dholland * avoid contention between threads over single files. 61 1.1 dholland */ 62 1.1 dholland struct fha_hash_entry { 63 1.3 pgoyette struct mtx *mtx; 64 1.1 dholland LIST_ENTRY(fha_hash_entry) link; 65 1.1 dholland u_int64_t fh; 66 1.1 dholland u_int32_t num_rw; 67 1.1 dholland u_int32_t num_exclusive; 68 1.1 dholland u_int8_t num_threads; 69 1.1 dholland struct svcthread_list threads; 70 1.1 dholland }; 71 1.1 dholland 72 1.1 dholland LIST_HEAD(fha_hash_entry_list, fha_hash_entry); 73 1.1 dholland 74 1.3 pgoyette struct fha_hash_slot { 75 1.3 pgoyette struct fha_hash_entry_list list; 76 1.3 pgoyette struct mtx mtx; 77 1.3 pgoyette }; 78 1.3 pgoyette 79 1.1 dholland /* A structure used for passing around data internally. */ 80 1.1 dholland struct fha_info { 81 1.1 dholland u_int64_t fh; 82 1.1 dholland off_t offset; 83 1.1 dholland int locktype; 84 1.1 dholland }; 85 1.1 dholland 86 1.1 dholland struct fha_callbacks { 87 1.1 dholland rpcproc_t (*get_procnum)(rpcproc_t procnum); 88 1.1 dholland int (*realign)(struct mbuf **mb, int malloc_flags); 89 1.3 pgoyette int (*get_fh)(uint64_t *fh, int v3, struct mbuf **md, caddr_t *dpos); 90 1.1 dholland int (*is_read)(rpcproc_t procnum); 91 1.1 dholland int (*is_write)(rpcproc_t procnum); 92 1.1 dholland int (*get_offset)(struct mbuf **md, caddr_t *dpos, int v3, struct 93 1.1 dholland fha_info *info); 94 1.1 dholland int (*no_offset)(rpcproc_t procnum); 95 1.1 dholland void (*set_locktype)(rpcproc_t procnum, struct fha_info *info); 96 1.1 dholland int (*fhe_stats_sysctl)(SYSCTL_HANDLER_ARGS); 97 1.1 dholland }; 98 1.1 dholland 99 1.1 dholland struct fha_params { 100 1.3 pgoyette struct fha_hash_slot fha_hash[FHA_HASH_SIZE]; 101 1.1 dholland struct sysctl_ctx_list sysctl_ctx; 102 1.1 dholland struct sysctl_oid *sysctl_tree; 103 1.1 dholland struct fha_ctls ctls; 104 1.1 dholland struct fha_callbacks callbacks; 105 1.1 dholland char server_name[32]; 106 1.1 dholland SVCPOOL **pool; 107 1.1 dholland }; 108 1.1 dholland 109 1.1 dholland void fha_nd_complete(SVCTHREAD *, struct svc_req *); 110 1.1 dholland SVCTHREAD *fha_assign(SVCTHREAD *, struct svc_req *, struct fha_params *); 111 1.1 dholland void fha_init(struct fha_params *softc); 112 1.1 dholland void fha_uninit(struct fha_params *softc); 113 1.1 dholland int fhe_stats_sysctl(SYSCTL_HANDLER_ARGS, struct fha_params *softc); 114 1.1 dholland 115 1.1 dholland #endif /* _KERNEL */ 116 1.1 dholland #endif /* _NFS_FHA_H_ */ 117