xref: /freebsd/sys/fs/nfsclient/nfs.h (revision 03a39a17089adc1d0e28076670e664dcdebccf73)
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 
359ec7b004SRick Macklem #ifndef _NFSCLIENT_NFS_H_
369ec7b004SRick Macklem #define	_NFSCLIENT_NFS_H_
379ec7b004SRick Macklem 
389ec7b004SRick Macklem #if defined(_KERNEL)
399ec7b004SRick Macklem 
409ec7b004SRick Macklem #ifndef NFS_TPRINTF_INITIAL_DELAY
419ec7b004SRick Macklem #define	NFS_TPRINTF_INITIAL_DELAY       12
429ec7b004SRick Macklem #endif
439ec7b004SRick Macklem 
449ec7b004SRick Macklem #ifndef NFS_TPRINTF_DELAY
459ec7b004SRick Macklem #define	NFS_TPRINTF_DELAY               30
469ec7b004SRick Macklem #endif
479ec7b004SRick Macklem 
489ec7b004SRick Macklem /*
499ec7b004SRick Macklem  * Nfs version macros.
509ec7b004SRick Macklem  */
519ec7b004SRick Macklem #define	NFS_ISV3(v) \
529ec7b004SRick Macklem 	(VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
539ec7b004SRick Macklem #define	NFS_ISV4(v) \
549ec7b004SRick Macklem 	(VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV4)
559ec7b004SRick Macklem #define	NFS_ISV34(v) \
569ec7b004SRick Macklem 	(VFSTONFS((v)->v_mount)->nm_flag & (NFSMNT_NFSV3 | NFSMNT_NFSV4))
579ec7b004SRick Macklem 
5862c23db9SRick Macklem #ifdef NFS_DEBUG
5962c23db9SRick Macklem 
6062c23db9SRick Macklem extern int nfs_debug;
6162c23db9SRick Macklem #define	NFS_DEBUG_ASYNCIO	1 /* asynchronous i/o */
6262c23db9SRick Macklem #define	NFS_DEBUG_WG		2 /* server write gathering */
6362c23db9SRick Macklem #define	NFS_DEBUG_RC		4 /* server request caching */
6462c23db9SRick Macklem 
6562c23db9SRick Macklem #define	NFS_DPF(cat, args)					\
6662c23db9SRick Macklem 	do {							\
6762c23db9SRick Macklem 		if (nfs_debug & NFS_DEBUG_##cat) printf args;	\
6862c23db9SRick Macklem 	} while (0)
6962c23db9SRick Macklem 
7062c23db9SRick Macklem #else
7162c23db9SRick Macklem 
7262c23db9SRick Macklem #define	NFS_DPF(cat, args)
7362c23db9SRick Macklem 
7462c23db9SRick Macklem #endif
7562c23db9SRick Macklem 
769ec7b004SRick Macklem /*
7780169e41SRick Macklem  * NFS iod threads can be in one of these three states once spawned.
7880169e41SRick Macklem  * NFSIOD_NOT_AVAILABLE - Cannot be assigned an I/O operation at this time.
7980169e41SRick Macklem  * NFSIOD_AVAILABLE - Available to be assigned an I/O operation.
8080169e41SRick Macklem  * NFSIOD_CREATED_FOR_NFS_ASYNCIO - Newly created for nfs_asyncio() and
8180169e41SRick Macklem  *	will be used by the thread that called nfs_asyncio().
8280169e41SRick Macklem  */
8380169e41SRick Macklem enum nfsiod_state {
8480169e41SRick Macklem 	NFSIOD_NOT_AVAILABLE = 0,
8580169e41SRick Macklem 	NFSIOD_AVAILABLE = 1,
8680169e41SRick Macklem 	NFSIOD_CREATED_FOR_NFS_ASYNCIO = 2,
8780169e41SRick Macklem };
8880169e41SRick Macklem 
8980169e41SRick Macklem /*
909ec7b004SRick Macklem  * Function prototypes.
919ec7b004SRick Macklem  */
9265417f5eSAlan Somers int ncl_meta_setsize(struct vnode *, struct thread *, u_quad_t);
939ec7b004SRick Macklem int ncl_bioread(struct vnode *, struct uio *, int, struct ucred *);
949ec7b004SRick Macklem int ncl_biowrite(struct vnode *, struct uio *, int, struct ucred *);
959ec7b004SRick Macklem int ncl_vinvalbuf(struct vnode *, int, struct thread *, int);
969ec7b004SRick Macklem int ncl_asyncio(struct nfsmount *, struct buf *, struct ucred *,
979ec7b004SRick Macklem     struct thread *);
9867c5c2d2SRick Macklem int ncl_doio(struct vnode *, struct buf *, struct ucred *, struct thread *,
9967c5c2d2SRick Macklem     int);
1009ec7b004SRick Macklem void ncl_nhinit(void);
1019ec7b004SRick Macklem void ncl_nhuninit(void);
1029ec7b004SRick Macklem void ncl_nodelock(struct nfsnode *);
1039ec7b004SRick Macklem void ncl_nodeunlock(struct nfsnode *);
1049ec7b004SRick Macklem int ncl_getattrcache(struct vnode *, struct vattr *);
1059ec7b004SRick Macklem int ncl_readrpc(struct vnode *, struct uio *, struct ucred *);
10667c5c2d2SRick Macklem int ncl_writerpc(struct vnode *, struct uio *, struct ucred *, int *, int *,
107*5218d82cSRick Macklem     int, int);
1089ec7b004SRick Macklem int ncl_readlinkrpc(struct vnode *, struct uio *, struct ucred *);
1099ec7b004SRick Macklem int ncl_readdirrpc(struct vnode *, struct uio *, struct ucred *,
1109ec7b004SRick Macklem     struct thread *);
1119ec7b004SRick Macklem int ncl_readdirplusrpc(struct vnode *, struct uio *, struct ucred *,
1129ec7b004SRick Macklem     struct thread *);
1139ec7b004SRick Macklem int ncl_commit(struct vnode *, u_quad_t, int, struct ucred *, struct thread *);
1149ec7b004SRick Macklem void ncl_clearcommit(struct mount *);
1159ec7b004SRick Macklem int ncl_fsinfo(struct nfsmount *, struct vnode *, struct ucred *,
1169ec7b004SRick Macklem     struct thread *);
1179ec7b004SRick Macklem int ncl_init(struct vfsconf *);
1189ec7b004SRick Macklem int ncl_uninit(struct vfsconf *);
1197b8c319bSRick Macklem void	ncl_nfsiodnew(void);
1207b8c319bSRick Macklem void	ncl_nfsiodnew_tq(__unused void *, int);
1219ec7b004SRick Macklem 
1229ec7b004SRick Macklem #endif	/* _KERNEL */
1239ec7b004SRick Macklem 
1249ec7b004SRick Macklem #endif	/* _NFSCLIENT_NFS_H_ */
125