freebsd-dev/sys/fs/nfsserver/nfs_fha_new.h
Rick Macklem 9897e357de Re-organize the NFS file handle affinity code for the NFS server.
The file handle affinity code was configured to be used by both the
old and new NFS servers. This no longer makes sense, since there is
only one NFS server.
This patch copies a majority of the code in sys/nfs/nfs_fha.c and
sys/nfs/nfs_fha.h into sys/fs/nfsserver/nfs_fha_new.c and
sys/fs/nfsserver/nfs_fha_new.h, so that the files in sys/nfs can be
deleted. The code is simplified by deleting the function callback pointers
used to call functions in either the old or new NFS server and they were
replaced by calls to the functions.

As well as a cleanup, this re-organization simplifies the changes
required for handling of external page mbufs, which is required for KERN_TLS.

This patch should not result in a semantic change to file handle affinity.
2020-04-14 00:01:26 +00:00

110 lines
3.4 KiB
C

/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2008 Isilon Inc http://www.isilon.com/
* Copyright (c) 2013 Spectra Logic Corporation
*
*
* 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_NEW_H
#define _NFS_FHA_NEW_H 1
#ifdef _KERNEL
#define FHANEW_SERVER_NAME "nfsd"
/* Sysctl defaults. */
#define FHA_DEF_ENABLE 1
#define FHA_DEF_READ 1
#define FHA_DEF_WRITE 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 */
#define FHA_HASH_SIZE 251
struct fha_ctls {
int enable;
int read;
int write;
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 {
struct mtx *mtx;
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);
struct fha_hash_slot {
struct fha_hash_entry_list list;
struct mtx mtx;
};
/* A structure used for passing around data internally. */
struct fha_info {
u_int64_t fh;
off_t offset;
int locktype;
int read;
int write;
};
struct fha_params {
struct fha_hash_slot fha_hash[FHA_HASH_SIZE];
struct sysctl_ctx_list sysctl_ctx;
struct sysctl_oid *sysctl_tree;
struct fha_ctls ctls;
char server_name[32];
SVCPOOL **pool;
};
SVCTHREAD *fhanew_assign(SVCTHREAD *this_thread, struct svc_req *req);
void fhanew_nd_complete(SVCTHREAD *, struct svc_req *);
#endif /* _KERNEL */
#endif /* _NFS_FHA_NEW_H */