xref: /freebsd/sys/fs/nfsclient/nfsmount.h (revision 08b9cc316a319fba95af8bb13b262fe0d5526ec3)
19ec7b004SRick Macklem /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
49ec7b004SRick Macklem  * Copyright (c) 1989, 1993
59ec7b004SRick Macklem  *	The Regents of the University of California.  All rights reserved.
69ec7b004SRick Macklem  *
79ec7b004SRick Macklem  * This code is derived from software contributed to Berkeley by
89ec7b004SRick Macklem  * Rick Macklem at The University of Guelph.
99ec7b004SRick Macklem  *
109ec7b004SRick Macklem  * Redistribution and use in source and binary forms, with or without
119ec7b004SRick Macklem  * modification, are permitted provided that the following conditions
129ec7b004SRick Macklem  * are met:
139ec7b004SRick Macklem  * 1. Redistributions of source code must retain the above copyright
149ec7b004SRick Macklem  *    notice, this list of conditions and the following disclaimer.
159ec7b004SRick Macklem  * 2. Redistributions in binary form must reproduce the above copyright
169ec7b004SRick Macklem  *    notice, this list of conditions and the following disclaimer in the
179ec7b004SRick Macklem  *    documentation and/or other materials provided with the distribution.
18fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
199ec7b004SRick Macklem  *    may be used to endorse or promote products derived from this software
209ec7b004SRick Macklem  *    without specific prior written permission.
219ec7b004SRick Macklem  *
229ec7b004SRick Macklem  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
239ec7b004SRick Macklem  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
249ec7b004SRick Macklem  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
259ec7b004SRick Macklem  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
269ec7b004SRick Macklem  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
279ec7b004SRick Macklem  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
289ec7b004SRick Macklem  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
299ec7b004SRick Macklem  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
309ec7b004SRick Macklem  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
319ec7b004SRick Macklem  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
329ec7b004SRick Macklem  * SUCH DAMAGE.
339ec7b004SRick Macklem  *
349ec7b004SRick Macklem  * $FreeBSD$
359ec7b004SRick Macklem  */
369ec7b004SRick Macklem 
379ec7b004SRick Macklem #ifndef _NFSCLIENT_NFSMOUNT_H_
389ec7b004SRick Macklem #define	_NFSCLIENT_NFSMOUNT_H_
399ec7b004SRick Macklem 
40ca27c028SRick Macklem #include <nfs/nfs_mountcommon.h>
41ca27c028SRick Macklem 
421e0a518dSRick Macklem /* Maximum value for nm_nconnect. */
431e0a518dSRick Macklem #define	NFS_MAXNCONN	16
441e0a518dSRick Macklem 
459ec7b004SRick Macklem /*
469ec7b004SRick Macklem  * Mount structure.
479ec7b004SRick Macklem  * One allocated on every NFS mount.
489ec7b004SRick Macklem  * Holds NFS specific information for mount.
499ec7b004SRick Macklem  */
509ec7b004SRick Macklem struct	nfsmount {
51ca27c028SRick Macklem 	struct	nfsmount_common nm_com;	/* Common fields for nlm */
5247cbff34SRick Macklem 	uint32_t nm_privflag;		/* Private flags */
536e4b6ff8SRick Macklem 	uint32_t nm_newflag;		/* New mount flags */
549ec7b004SRick Macklem 	int	nm_numgrps;		/* Max. size of groupslist */
559ec7b004SRick Macklem 	u_char	nm_fh[NFSX_FHMAX];	/* File handle of root dir */
569ec7b004SRick Macklem 	int	nm_fhsize;		/* Size of root file handle */
579ec7b004SRick Macklem 	struct	nfssockreq nm_sockreq;	/* Socket Info */
589ec7b004SRick Macklem 	int	nm_timeouts;		/* Request timeouts */
599ec7b004SRick Macklem 	int	nm_rsize;		/* Max size of read rpc */
609ec7b004SRick Macklem 	int	nm_wsize;		/* Max size of write rpc */
619ec7b004SRick Macklem 	int	nm_readdirsize;		/* Size of a readdir rpc */
629ec7b004SRick Macklem 	int	nm_readahead;		/* Num. of blocks to readahead */
639ec7b004SRick Macklem 	int	nm_wcommitsize;		/* Max size of commit for write */
649ec7b004SRick Macklem 	int	nm_acdirmin;		/* Directory attr cache min lifetime */
659ec7b004SRick Macklem 	int	nm_acdirmax;		/* Directory attr cache max lifetime */
669ec7b004SRick Macklem 	int	nm_acregmin;		/* Reg file attr cache min lifetime */
679ec7b004SRick Macklem 	int	nm_acregmax;		/* Reg file attr cache max lifetime */
689ec7b004SRick Macklem 	u_char	nm_verf[NFSX_VERF];	/* write verifier */
699ec7b004SRick Macklem 	TAILQ_HEAD(, buf) nm_bufq;	/* async io buffer queue */
709ec7b004SRick Macklem 	short	nm_bufqlen;		/* number of buffers in queue */
719ec7b004SRick Macklem 	short	nm_bufqwant;		/* process wants to add to the queue */
729ec7b004SRick Macklem 	int	nm_bufqiods;		/* number of iods processing queue */
739ec7b004SRick Macklem 	u_int64_t nm_maxfilesize;	/* maximum file size */
749ec7b004SRick Macklem 	int	nm_tprintf_initial_delay; /* initial delay */
759ec7b004SRick Macklem 	int	nm_tprintf_delay;	/* interval for messages */
760b17c7beSJohn Baldwin 	int	nm_nametimeo;		/* timeout for +ve entries (sec) */
77dd5b5a94SRick Macklem 	int	nm_negnametimeo;	/* timeout for -ve entries (sec) */
789ec7b004SRick Macklem 
799ec7b004SRick Macklem 	/* Newnfs additions */
801f60bfd8SRick Macklem 	TAILQ_HEAD(, nfsclds) nm_sess;	/* Session(s) for NFSv4.1. */
819ec7b004SRick Macklem 	struct	nfsclclient *nm_clp;
82665b1365SRick Macklem 	char	*nm_tlscertname;	/* TLS certificate file name */
839ec7b004SRick Macklem 	uid_t	nm_uid;			/* Uid for SetClientID etc. */
849ec7b004SRick Macklem 	u_int64_t nm_clval;		/* identifies which clientid */
859ec7b004SRick Macklem 	u_int64_t nm_fsid[2];		/* NFSv4 fsid */
861f60bfd8SRick Macklem 	int	nm_minorvers;		/* Minor version # for NFSv4 */
871e0a518dSRick Macklem 	u_int	nm_aconnect;		/* additional TCP connections */
881e0a518dSRick Macklem 	u_int	nm_nextaconn;		/* Next nm_aconn[] to use */
891e0a518dSRick Macklem 					/* unclipped, wraps to 0 */
901e0a518dSRick Macklem 	struct __rpc_client *nm_aconn[NFS_MAXNCONN - 1]; /* Additional nconn */
911e0a518dSRick Macklem 					/* Locked via nm_sockreq.nr_mtx */
929ec7b004SRick Macklem 	u_int16_t nm_krbnamelen;	/* Krb5 host principal, if any */
939ec7b004SRick Macklem 	u_int16_t nm_dirpathlen;	/* and mount dirpath, for V4 */
949ec7b004SRick Macklem 	u_int16_t nm_srvkrbnamelen;	/* and the server's target name */
959ec7b004SRick Macklem 	u_char	nm_name[1];	/* malloc'd actual len of krbname + dirpath */
969ec7b004SRick Macklem };
979ec7b004SRick Macklem 
989ec7b004SRick Macklem #define	nm_nam		nm_sockreq.nr_nam
999ec7b004SRick Macklem #define	nm_sotype	nm_sockreq.nr_sotype
1009ec7b004SRick Macklem #define	nm_so		nm_sockreq.nr_so
1019ec7b004SRick Macklem #define	nm_soflags	nm_sockreq.nr_soflags
1029ec7b004SRick Macklem #define	nm_soproto	nm_sockreq.nr_soproto
1039ec7b004SRick Macklem #define	nm_client	nm_sockreq.nr_client
1049ec7b004SRick Macklem #define	nm_krbname	nm_name
105ca27c028SRick Macklem #define	nm_mtx		nm_com.nmcom_mtx
106ca27c028SRick Macklem #define	nm_flag		nm_com.nmcom_flag
107ca27c028SRick Macklem #define	nm_state	nm_com.nmcom_state
108ca27c028SRick Macklem #define	nm_mountp	nm_com.nmcom_mountp
109ca27c028SRick Macklem #define	nm_timeo	nm_com.nmcom_timeo
110ca27c028SRick Macklem #define	nm_retry	nm_com.nmcom_retry
111ca27c028SRick Macklem #define	nm_hostname	nm_com.nmcom_hostname
112ca27c028SRick Macklem #define	nm_getinfo	nm_com.nmcom_getinfo
11390305aa3SRick Macklem #define	nm_vinvalbuf	nm_com.nmcom_vinvalbuf
1149ec7b004SRick Macklem 
11547cbff34SRick Macklem /* Private flags. */
11647cbff34SRick Macklem #define	NFSMNTP_FORCEDISM	0x00000001
11747cbff34SRick Macklem #define	NFSMNTP_CANCELRPCS	0x00000002
118c057a378SRick Macklem #define	NFSMNTP_IOADVISETHRUMDS	0x00000004
119c057a378SRick Macklem #define	NFSMNTP_NOCOPY		0x00000008
120c057a378SRick Macklem #define	NFSMNTP_NOCONSECUTIVE	0x00000010
121c057a378SRick Macklem #define	NFSMNTP_SEEK		0x00000020
122c057a378SRick Macklem #define	NFSMNTP_SEEKTESTED	0x00000040
123c057a378SRick Macklem #define	NFSMNTP_NOXATTR		0x00000080
124c057a378SRick Macklem #define	NFSMNTP_NOADVISE	0x00000100
125c057a378SRick Macklem #define	NFSMNTP_NOALLOCATE	0x00000200
1265e5ca4c8SRick Macklem #define	NFSMNTP_DELEGISSUED	0x00000400
127*08b9cc31SRick Macklem #define	NFSMNTP_NODEALLOCATE	0x00000800
12847cbff34SRick Macklem 
1296e4b6ff8SRick Macklem /* New mount flags only used by the kernel via nmount(2). */
1306e4b6ff8SRick Macklem #define	NFSMNT_TLS		0x00000001
1316e4b6ff8SRick Macklem 
1329ec7b004SRick Macklem #define	NFSMNT_DIRPATH(m)	(&((m)->nm_name[(m)->nm_krbnamelen + 1]))
1339ec7b004SRick Macklem #define	NFSMNT_SRVKRBNAME(m)						\
1349ec7b004SRick Macklem 	(&((m)->nm_name[(m)->nm_krbnamelen + (m)->nm_dirpathlen + 2]))
1359ec7b004SRick Macklem 
1369ec7b004SRick Macklem #if defined(_KERNEL)
1379ec7b004SRick Macklem /*
1389ec7b004SRick Macklem  * Convert mount ptr to nfsmount ptr.
1399ec7b004SRick Macklem  */
1409ec7b004SRick Macklem #define	VFSTONFS(mp)	((struct nfsmount *)((mp)->mnt_data))
1419ec7b004SRick Macklem 
1420b17c7beSJohn Baldwin #ifndef NFS_DEFAULT_NAMETIMEO
1430b17c7beSJohn Baldwin #define NFS_DEFAULT_NAMETIMEO		60
1440b17c7beSJohn Baldwin #endif
1450b17c7beSJohn Baldwin 
146dd5b5a94SRick Macklem #ifndef NFS_DEFAULT_NEGNAMETIMEO
147dd5b5a94SRick Macklem #define NFS_DEFAULT_NEGNAMETIMEO	60
148dd5b5a94SRick Macklem #endif
149dd5b5a94SRick Macklem 
1509ec7b004SRick Macklem #endif	/* _KERNEL */
1519ec7b004SRick Macklem 
1529ec7b004SRick Macklem #endif	/* _NFSCLIENT_NFSMOUNT_H_ */
153