1191783Srmacklem/*-
2191783Srmacklem * Copyright (c) 1989, 1993
3191783Srmacklem *	The Regents of the University of California.  All rights reserved.
4191783Srmacklem *
5191783Srmacklem * This code is derived from software contributed to Berkeley by
6191783Srmacklem * Rick Macklem at The University of Guelph.
7191783Srmacklem *
8191783Srmacklem * Redistribution and use in source and binary forms, with or without
9191783Srmacklem * modification, are permitted provided that the following conditions
10191783Srmacklem * are met:
11191783Srmacklem * 1. Redistributions of source code must retain the above copyright
12191783Srmacklem *    notice, this list of conditions and the following disclaimer.
13191783Srmacklem * 2. Redistributions in binary form must reproduce the above copyright
14191783Srmacklem *    notice, this list of conditions and the following disclaimer in the
15191783Srmacklem *    documentation and/or other materials provided with the distribution.
16191783Srmacklem * 4. Neither the name of the University nor the names of its contributors
17191783Srmacklem *    may be used to endorse or promote products derived from this software
18191783Srmacklem *    without specific prior written permission.
19191783Srmacklem *
20191783Srmacklem * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21191783Srmacklem * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22191783Srmacklem * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23191783Srmacklem * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24191783Srmacklem * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25191783Srmacklem * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26191783Srmacklem * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27191783Srmacklem * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28191783Srmacklem * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29191783Srmacklem * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30191783Srmacklem * SUCH DAMAGE.
31191783Srmacklem *
32191783Srmacklem * $FreeBSD: stable/10/sys/fs/nfsclient/nfsmount.h 336899 2018-07-30 12:17:10Z rmacklem $
33191783Srmacklem */
34191783Srmacklem
35191783Srmacklem#ifndef _NFSCLIENT_NFSMOUNT_H_
36191783Srmacklem#define	_NFSCLIENT_NFSMOUNT_H_
37191783Srmacklem
38214048Srmacklem#include <nfs/nfs_mountcommon.h>
39214048Srmacklem
40191783Srmacklem/*
41191783Srmacklem * Mount structure.
42191783Srmacklem * One allocated on every NFS mount.
43191783Srmacklem * Holds NFS specific information for mount.
44191783Srmacklem */
45191783Srmacklemstruct	nfsmount {
46214048Srmacklem	struct	nfsmount_common nm_com;	/* Common fields for nlm */
47191783Srmacklem	int	nm_numgrps;		/* Max. size of groupslist */
48191783Srmacklem	u_char	nm_fh[NFSX_FHMAX];	/* File handle of root dir */
49191783Srmacklem	int	nm_fhsize;		/* Size of root file handle */
50191783Srmacklem	struct	nfssockreq nm_sockreq;	/* Socket Info */
51191783Srmacklem	int	nm_timeouts;		/* Request timeouts */
52191783Srmacklem	int	nm_rsize;		/* Max size of read rpc */
53191783Srmacklem	int	nm_wsize;		/* Max size of write rpc */
54191783Srmacklem	int	nm_readdirsize;		/* Size of a readdir rpc */
55191783Srmacklem	int	nm_readahead;		/* Num. of blocks to readahead */
56191783Srmacklem	int	nm_wcommitsize;		/* Max size of commit for write */
57191783Srmacklem	int	nm_acdirmin;		/* Directory attr cache min lifetime */
58191783Srmacklem	int	nm_acdirmax;		/* Directory attr cache max lifetime */
59191783Srmacklem	int	nm_acregmin;		/* Reg file attr cache min lifetime */
60191783Srmacklem	int	nm_acregmax;		/* Reg file attr cache max lifetime */
61191783Srmacklem	u_char	nm_verf[NFSX_VERF];	/* write verifier */
62191783Srmacklem	TAILQ_HEAD(, buf) nm_bufq;	/* async io buffer queue */
63191783Srmacklem	short	nm_bufqlen;		/* number of buffers in queue */
64191783Srmacklem	short	nm_bufqwant;		/* process wants to add to the queue */
65191783Srmacklem	int	nm_bufqiods;		/* number of iods processing queue */
66191783Srmacklem	u_int64_t nm_maxfilesize;	/* maximum file size */
67191783Srmacklem	int	nm_tprintf_initial_delay; /* initial delay */
68191783Srmacklem	int	nm_tprintf_delay;	/* interval for messages */
69230547Sjhb	int	nm_nametimeo;		/* timeout for +ve entries (sec) */
70203303Srmacklem	int	nm_negnametimeo;	/* timeout for -ve entries (sec) */
71191783Srmacklem
72191783Srmacklem	/* Newnfs additions */
73244042Srmacklem	TAILQ_HEAD(, nfsclds) nm_sess;	/* Session(s) for NFSv4.1. */
74191783Srmacklem	struct	nfsclclient *nm_clp;
75191783Srmacklem	uid_t	nm_uid;			/* Uid for SetClientID etc. */
76191783Srmacklem	u_int64_t nm_clval;		/* identifies which clientid */
77191783Srmacklem	u_int64_t nm_fsid[2];		/* NFSv4 fsid */
78244042Srmacklem	int	nm_minorvers;		/* Minor version # for NFSv4 */
79191783Srmacklem	u_int16_t nm_krbnamelen;	/* Krb5 host principal, if any */
80191783Srmacklem	u_int16_t nm_dirpathlen;	/* and mount dirpath, for V4 */
81191783Srmacklem	u_int16_t nm_srvkrbnamelen;	/* and the server's target name */
82191783Srmacklem	u_char	nm_name[1];	/* malloc'd actual len of krbname + dirpath */
83191783Srmacklem};
84191783Srmacklem
85191783Srmacklem#define	nm_nam		nm_sockreq.nr_nam
86191783Srmacklem#define	nm_sotype	nm_sockreq.nr_sotype
87191783Srmacklem#define	nm_so		nm_sockreq.nr_so
88191783Srmacklem#define	nm_soflags	nm_sockreq.nr_soflags
89191783Srmacklem#define	nm_soproto	nm_sockreq.nr_soproto
90191783Srmacklem#define	nm_client	nm_sockreq.nr_client
91191783Srmacklem#define	nm_krbname	nm_name
92214048Srmacklem#define	nm_mtx		nm_com.nmcom_mtx
93214048Srmacklem#define	nm_flag		nm_com.nmcom_flag
94214048Srmacklem#define	nm_state	nm_com.nmcom_state
95214048Srmacklem#define	nm_mountp	nm_com.nmcom_mountp
96214048Srmacklem#define	nm_timeo	nm_com.nmcom_timeo
97214048Srmacklem#define	nm_retry	nm_com.nmcom_retry
98214048Srmacklem#define	nm_hostname	nm_com.nmcom_hostname
99214048Srmacklem#define	nm_getinfo	nm_com.nmcom_getinfo
100216931Srmacklem#define	nm_vinvalbuf	nm_com.nmcom_vinvalbuf
101191783Srmacklem
102191783Srmacklem#define	NFSMNT_DIRPATH(m)	(&((m)->nm_name[(m)->nm_krbnamelen + 1]))
103191783Srmacklem#define	NFSMNT_SRVKRBNAME(m)						\
104191783Srmacklem	(&((m)->nm_name[(m)->nm_krbnamelen + (m)->nm_dirpathlen + 2]))
105191783Srmacklem
106191783Srmacklem#if defined(_KERNEL)
107191783Srmacklem/*
108191783Srmacklem * Convert mount ptr to nfsmount ptr.
109191783Srmacklem */
110191783Srmacklem#define	VFSTONFS(mp)	((struct nfsmount *)((mp)->mnt_data))
111191783Srmacklem
112244042Srmacklem/*
113244042Srmacklem * Get a pointer to the MDS session, which is always the first element
114244042Srmacklem * in the list.
115317404Srmacklem * This macro can only be safely used when the NFSLOCKMNT() lock is held.
116317404Srmacklem * The inline function can be used when the lock isn't held.
117244042Srmacklem */
118244042Srmacklem#define	NFSMNT_MDSSESSION(m)	(&(TAILQ_FIRST(&((m)->nm_sess))->nfsclds_sess))
119244042Srmacklem
120317404Srmacklemstatic __inline struct nfsclsession *
121317404Srmacklemnfsmnt_mdssession(struct nfsmount *nmp)
122317404Srmacklem{
123317404Srmacklem	struct nfsclsession *tsep;
124317404Srmacklem
125336899Srmacklem	tsep = NULL;
126317404Srmacklem	mtx_lock(&nmp->nm_mtx);
127336899Srmacklem	if (TAILQ_FIRST(&nmp->nm_sess) != NULL)
128336899Srmacklem		tsep = NFSMNT_MDSSESSION(nmp);
129317404Srmacklem	mtx_unlock(&nmp->nm_mtx);
130317404Srmacklem	return (tsep);
131317404Srmacklem}
132317404Srmacklem
133230547Sjhb#ifndef NFS_DEFAULT_NAMETIMEO
134230547Sjhb#define NFS_DEFAULT_NAMETIMEO		60
135230547Sjhb#endif
136230547Sjhb
137203303Srmacklem#ifndef NFS_DEFAULT_NEGNAMETIMEO
138203303Srmacklem#define NFS_DEFAULT_NEGNAMETIMEO	60
139203303Srmacklem#endif
140203303Srmacklem
141191783Srmacklem#endif	/* _KERNEL */
142191783Srmacklem
143191783Srmacklem#endif	/* _NFSCLIENT_NFSMOUNT_H_ */
144