/* $NetBSD: nfs.h,v 1.81 2024/12/07 02:05:55 riastradh Exp $ */
/*
* Copyright (c) 1989, 1993, 1995
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Rick Macklem at The University of Guelph.
*
* 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)nfs.h 8.4 (Berkeley) 5/1/95
*/
/*
* These can be overridden through <machine/param.h>, included via
* <sys/param.h>. This means that <sys/param.h> should always be
* included before this file.
*/
#ifndef NFS_WSIZE
#define NFS_WSIZE 8192 /* Def. write data size */
#endif
#ifndef NFS_RSIZE
#define NFS_RSIZE 8192 /* Def. read data size */
#endif
#ifndef NFS_READDIRSIZE
#define NFS_READDIRSIZE 8192 /* Def. readdir size */
#endif
/*
* NFS client IO daemon threads. May be overridden by config options.
*/
#ifndef NFS_MAXASYNCDAEMON
#define NFS_MAXASYNCDAEMON 128 /* Max. number async_daemons runnable */
#endif
/*
* NFS client read-ahead. May be overridden by config options.
* Should be no more than NFS_MAXASYNCDAEMON as each read-ahead operation
* requires one IO thread.
*/
#ifndef NFS_MAXRAHEAD
#define NFS_MAXRAHEAD 32 /* Max. read ahead # blocks */
#endif
#define NFS_DEFRAHEAD 2 /* Def. read ahead # blocks */
/*
* NFS_DIRBLKSIZ is the size of buffers in the buffer cache used for
* NFS directory vnodes. NFS_DIRFRAGSIZ is the minimum aligned amount
* of data in those buffers, and thus the minimum amount of data
* that you can request. NFS_DIRFRAGSIZ should be no smaller than
* DIRBLKSIZ.
*/
#define NFS_DIRBLKSIZ 8192 /* Must be a multiple of DIRBLKSIZ */
#define NFS_DIRFRAGSIZ 512 /* Same as DIRBLKSIZ, generally */
/*
* Maximum number of directory entries cached per NFS node, to avoid
* having this grow without bounds on very large directories. The
* minimum size to get reasonable performance for emulated binaries
* is the maximum number of entries that fits in NFS_DIRBLKSIZ.
* For NFS_DIRBLKSIZ = 512, this would be 512 / 14 = 36.
*/
#define NFS_MAXDIRCACHE (NFS_DIRBLKSIZ / 14)
/*
* Use the vm_page flag reserved for pager use to indicate pages
* which have been written to the server but not yet committed.
*/
#define PG_NEEDCOMMIT PG_PAGER1
/*
* The IO_METASYNC flag should be implemented for local file systems.
* (Until then, it is nothin at all.)
*/
#ifndef IO_METASYNC
#define IO_METASYNC 0
#endif
/*
* Export arguments for local filesystem mount calls.
* Keep in mind that changing this structure modifies nfssvc(2)'s ABI (see
* 'struct mountd_exports_list' below).
* When modifying this structure, take care to also edit the
* nfs_update_exports_30 function in nfs_export.c accordingly to convert
* export_args to export_args30.
*/
struct export_args {
int ex_flags; /* export related flags */
uid_t ex_root; /* mapping for root uid */
struct uucred ex_anon; /* mapping for anonymous user */
struct sockaddr *ex_addr; /* net address to which exported */
int ex_addrlen; /* and the net address length */
struct sockaddr *ex_mask; /* mask of valid bits in saddr */
int ex_masklen; /* and the smask length */
char *ex_indexfile; /* index file for WebNFS URLs */
};
/*
* Structures for the nfssvc(2) syscall. Not that anyone but mountd, nfsd and
* mount_nfs should ever try and use it.
*/
struct nfsd_args {
int sock; /* Socket to serve */
void * name; /* Client addr for connection based sockets */
int namelen; /* Length of name */
};
struct nfsd_srvargs {
struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
uid_t nsd_uid; /* Effective uid mapped to cred */
u_int32_t nsd_haddr; /* Ip address of client */
struct uucred nsd_cr; /* Cred. uid maps to */
int nsd_authlen; /* Length of auth string (ret) */
u_char *nsd_authstr; /* Auth string (ret) */
int nsd_verflen; /* and the verfier */
u_char *nsd_verfstr;
struct timeval nsd_timestamp; /* timestamp from verifier */
u_int32_t nsd_ttl; /* credential ttl (sec) */
NFSKERBKEY_T nsd_key; /* Session key */
};
struct nfsd_cargs {
char *ncd_dirp; /* Mount dir path */
uid_t ncd_authuid; /* Effective uid */
int ncd_authtype; /* Type of authenticator */
u_int ncd_authlen; /* Length of authenticator string */
u_char *ncd_authstr; /* Authenticator string */
u_int ncd_verflen; /* and the verifier */
u_char *ncd_verfstr;
NFSKERBKEY_T ncd_key; /* Session key */
};
/*
* try to keep nfsstats, which is exposed to userland via sysctl,
* compatible after NQNFS removal.
* 26 is the old value of NFS_NPROCS, which includes NQNFS procedures.
*/
#define NFSSTATS_NPROCS 26
/*
* The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
* What should be in this set is open to debate, but I believe that since
* I/O system calls on ufs are never interrupted by signals the set should
* be minimal. My reasoning is that many current programs that use signals
* such as SIGALRM will not expect file I/O system calls to be interrupted
* by them and break.
*/
#ifdef _KERNEL
/*
* Socket errors ignored for connectionless sockets??
* For now, ignore them all
*/
#define NFSIGNORE_SOERROR(s, e) \
((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
((s) & PR_CONNREQUIRED) == 0)
/*
* Nfs outstanding request list element
*/
struct nfsreq {
TAILQ_ENTRY(nfsreq) r_chain;
struct mbuf *r_mreq;
struct mbuf *r_mrep;
struct mbuf *r_md;
void * r_dpos;
struct nfsmount *r_nmp;
u_int32_t r_xid;
int r_flags; /* flags on request, see below */
int r_retry; /* max retransmission count */
int r_rexmit; /* current retrans count */
u_int32_t r_procnum; /* NFS procedure number */
int r_rtt; /* RTT for rpc */
struct lwp *r_lwp; /* LWP that did I/O system call */
};
/*
* Queue head for nfsreq's
*/
extern TAILQ_HEAD(nfsreqhead, nfsreq) nfs_reqq;
extern kmutex_t nfs_reqq_lock;
/* Flag values for r_flags */
#define R_TIMING 0x01 /* timing request (in mntp) */
#define R_SENT 0x02 /* request has been sent */
#define R_SOFTTERM 0x04 /* soft mnt, too many retries */
#define R_INTR 0x08 /* intr mnt, signal pending */
#define R_SOCKERR 0x10 /* Fatal error on socket */
#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
#define R_MUSTRESEND 0x40 /* Must resend request */
#define R_REXMITTED 0x100 /* retransmitted after reconnect */
/*
* A list of nfssvc_sock structures is maintained with all the sockets
* that require service by the nfsd.
* The nfsuid structs hang off of the nfssvc_sock structs in both lru
* and uid hash lists.
*/
#ifndef NFS_UIDHASHSIZ
#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
#endif
#define NUIDHASH(sock, uid) \
(&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
#ifndef NFS_WDELAYHASHSIZ
#define NFS_WDELAYHASHSIZ 16 /* and with this */
#endif
#ifndef NFS_MUIDHASHSIZ
#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */
#endif
#define NMUIDHASH(nmp, uid) \
(&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
/*
* One of these structures is allocated for each nfsd.
*/
struct nfsd {
struct rb_node nfsd_node; /* Tree of all nfsd's */
SLIST_ENTRY(nfsd) nfsd_idle; /* List of idle nfsd's */
kcondvar_t nfsd_cv;
int nfsd_flag; /* NFSD_ flags */
struct nfssvc_sock *nfsd_slp; /* Current socket */
int nfsd_authlen; /* Authenticator len */
u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
int nfsd_verflen; /* and the Verifier */
u_char nfsd_verfstr[RPCVERF_MAXSIZ];
struct proc *nfsd_procp; /* Proc ptr */
struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
uint32_t nfsd_cookie; /* Userland cookie, fits 32bit ptr */
};
/*
* Structure holding information for a publicly exported filesystem
* (WebNFS). Currently the specs allow just for one such filesystem.
*/
struct nfs_public {
int np_valid; /* Do we hold valid information */
fhandle_t *np_handle; /* Filehandle for pub fs (internal) */
struct mount *np_mount; /* Mountpoint of exported fs */
char *np_index; /* Index file */
};
#endif /* _KERNEL */