/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2008 Isilon Inc http://www.isilon.com/4* Copyright (c) 2013 Spectra Logic Corporation5*6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _NFS_FHA_NEW_H30#define _NFS_FHA_NEW_H 13132#ifdef _KERNEL3334#define FHANEW_SERVER_NAME "nfsd"3536/* Sysctl defaults. */37#define FHA_DEF_ENABLE 138#define FHA_DEF_READ 139#define FHA_DEF_WRITE 140#define FHA_DEF_BIN_SHIFT 22 /* 4MB */41#define FHA_DEF_MAX_NFSDS_PER_FH 842#define FHA_DEF_MAX_REQS_PER_NFSD 0 /* Unlimited */4344#define FHA_HASH_SIZE 2514546struct fha_ctls {47int enable;48int read;49int write;50uint32_t bin_shift;51uint32_t max_nfsds_per_fh;52uint32_t max_reqs_per_nfsd;53};5455/*56* These are the entries in the filehandle hash. They talk about a specific57* file, requests against which are being handled by one or more nfsds. We58* keep a chain of nfsds against the file. We only have more than one if reads59* are ongoing, and then only if the reads affect disparate regions of the60* file.61*62* In general, we want to assign a new request to an existing nfsd if it is63* going to contend with work happening already on that nfsd, or if the64* operation is a read and the nfsd is already handling a proximate read. We65* do this to avoid jumping around in the read stream unnecessarily, and to66* avoid contention between threads over single files.67*/68struct fha_hash_entry {69struct mtx *mtx;70LIST_ENTRY(fha_hash_entry) link;71u_int64_t fh;72u_int32_t num_rw;73u_int32_t num_exclusive;74u_int8_t num_threads;75struct svcthread_list threads;76};7778LIST_HEAD(fha_hash_entry_list, fha_hash_entry);7980struct fha_hash_slot {81struct fha_hash_entry_list list;82struct mtx mtx;83};8485/* A structure used for passing around data internally. */86struct fha_info {87u_int64_t fh;88off_t offset;89int locktype;90int read;91int write;92};9394struct fha_params {95struct fha_hash_slot fha_hash[FHA_HASH_SIZE];96char server_name[32];97};9899SVCTHREAD *fhanew_assign(SVCTHREAD *this_thread, struct svc_req *req);100void fhanew_nd_complete(SVCTHREAD *, struct svc_req *);101#endif /* _KERNEL */102103#endif /* _NFS_FHA_NEW_H */104105106