xref: /netbsd-src/sys/fs/nfs/client/nfs.h (revision 47cc427df8b391aded57c2c99bbf5b0cee1423a5)
1*47cc427dSpgoyette /*	$NetBSD: nfs.h,v 1.2 2016/12/13 22:54:24 pgoyette Exp $	*/
26ca35587Sdholland /*-
36ca35587Sdholland  * Copyright (c) 1989, 1993
46ca35587Sdholland  *	The Regents of the University of California.  All rights reserved.
56ca35587Sdholland  *
66ca35587Sdholland  * This code is derived from software contributed to Berkeley by
76ca35587Sdholland  * Rick Macklem at The University of Guelph.
86ca35587Sdholland  *
96ca35587Sdholland  * Redistribution and use in source and binary forms, with or without
106ca35587Sdholland  * modification, are permitted provided that the following conditions
116ca35587Sdholland  * are met:
126ca35587Sdholland  * 1. Redistributions of source code must retain the above copyright
136ca35587Sdholland  *    notice, this list of conditions and the following disclaimer.
146ca35587Sdholland  * 2. Redistributions in binary form must reproduce the above copyright
156ca35587Sdholland  *    notice, this list of conditions and the following disclaimer in the
166ca35587Sdholland  *    documentation and/or other materials provided with the distribution.
176ca35587Sdholland  * 4. Neither the name of the University nor the names of its contributors
186ca35587Sdholland  *    may be used to endorse or promote products derived from this software
196ca35587Sdholland  *    without specific prior written permission.
206ca35587Sdholland  *
216ca35587Sdholland  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
226ca35587Sdholland  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
236ca35587Sdholland  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
246ca35587Sdholland  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
256ca35587Sdholland  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
266ca35587Sdholland  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
276ca35587Sdholland  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
286ca35587Sdholland  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
296ca35587Sdholland  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
306ca35587Sdholland  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
316ca35587Sdholland  * SUCH DAMAGE.
326ca35587Sdholland  *
33e81f0ea2Spgoyette  * FreeBSD: head/sys/fs/nfsclient/nfs.h 276140 2014-12-23 14:24:36Z rmacklem
34*47cc427dSpgoyette  * $NetBSD: nfs.h,v 1.2 2016/12/13 22:54:24 pgoyette Exp $
356ca35587Sdholland  */
366ca35587Sdholland 
376ca35587Sdholland #ifndef _NFSCLIENT_NFS_H_
386ca35587Sdholland #define	_NFSCLIENT_NFS_H_
396ca35587Sdholland 
406ca35587Sdholland #if defined(_KERNEL)
416ca35587Sdholland 
426ca35587Sdholland #ifndef NFS_TPRINTF_INITIAL_DELAY
436ca35587Sdholland #define	NFS_TPRINTF_INITIAL_DELAY       12
446ca35587Sdholland #endif
456ca35587Sdholland 
466ca35587Sdholland #ifndef NFS_TPRINTF_DELAY
476ca35587Sdholland #define	NFS_TPRINTF_DELAY               30
486ca35587Sdholland #endif
496ca35587Sdholland 
506ca35587Sdholland /*
516ca35587Sdholland  * Nfs version macros.
526ca35587Sdholland  */
536ca35587Sdholland #define	NFS_ISV3(v) \
546ca35587Sdholland 	(VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
556ca35587Sdholland #define	NFS_ISV4(v) \
566ca35587Sdholland 	(VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV4)
576ca35587Sdholland #define	NFS_ISV34(v) \
586ca35587Sdholland 	(VFSTONFS((v)->v_mount)->nm_flag & (NFSMNT_NFSV3 | NFSMNT_NFSV4))
596ca35587Sdholland 
60e81f0ea2Spgoyette #ifdef NFS_DEBUG
61e81f0ea2Spgoyette 
62e81f0ea2Spgoyette extern int nfs_debug;
63e81f0ea2Spgoyette #define	NFS_DEBUG_ASYNCIO	1 /* asynchronous i/o */
64e81f0ea2Spgoyette #define	NFS_DEBUG_WG		2 /* server write gathering */
65e81f0ea2Spgoyette #define	NFS_DEBUG_RC		4 /* server request caching */
66e81f0ea2Spgoyette 
67e81f0ea2Spgoyette #define	NFS_DPF(cat, args)					\
68e81f0ea2Spgoyette 	do {							\
69e81f0ea2Spgoyette 		if (nfs_debug & NFS_DEBUG_##cat) printf args;	\
70e81f0ea2Spgoyette 	} while (0)
71e81f0ea2Spgoyette 
72e81f0ea2Spgoyette #else
73e81f0ea2Spgoyette 
74e81f0ea2Spgoyette #define	NFS_DPF(cat, args)
75e81f0ea2Spgoyette 
76e81f0ea2Spgoyette #endif
77e81f0ea2Spgoyette 
786ca35587Sdholland /*
796ca35587Sdholland  * NFS iod threads can be in one of these three states once spawned.
806ca35587Sdholland  * NFSIOD_NOT_AVAILABLE - Cannot be assigned an I/O operation at this time.
816ca35587Sdholland  * NFSIOD_AVAILABLE - Available to be assigned an I/O operation.
826ca35587Sdholland  * NFSIOD_CREATED_FOR_NFS_ASYNCIO - Newly created for nfs_asyncio() and
836ca35587Sdholland  *	will be used by the thread that called nfs_asyncio().
846ca35587Sdholland  */
856ca35587Sdholland enum nfsiod_state {
866ca35587Sdholland 	NFSIOD_NOT_AVAILABLE = 0,
876ca35587Sdholland 	NFSIOD_AVAILABLE = 1,
886ca35587Sdholland 	NFSIOD_CREATED_FOR_NFS_ASYNCIO = 2,
896ca35587Sdholland };
906ca35587Sdholland 
916ca35587Sdholland /*
926ca35587Sdholland  * Function prototypes.
936ca35587Sdholland  */
94*47cc427dSpgoyette int ncl_meta_setsize(struct vnode *, struct kauth_cred *, struct lwp *,
956ca35587Sdholland     u_quad_t);
966ca35587Sdholland void ncl_doio_directwrite(struct buf *);
97*47cc427dSpgoyette int ncl_bioread(struct vnode *, struct uio *, int, struct kauth_cred *);
98*47cc427dSpgoyette int ncl_biowrite(struct vnode *, struct uio *, int, struct kauth_cred *);
99*47cc427dSpgoyette int ncl_vinvalbuf(struct vnode *, int, struct kauth_cred *, int);
100*47cc427dSpgoyette int ncl_asyncio(struct nfsmount *, struct buf *, struct kauth_cred *,
101*47cc427dSpgoyette     struct lwp *);
102*47cc427dSpgoyette int ncl_doio(struct vnode *, struct buf *, struct kauth_cred *, struct lwp *,
1036ca35587Sdholland     int);
1046ca35587Sdholland void ncl_nhinit(void);
1056ca35587Sdholland void ncl_nhuninit(void);
1066ca35587Sdholland void ncl_nodelock(struct nfsnode *);
1076ca35587Sdholland void ncl_nodeunlock(struct nfsnode *);
1086ca35587Sdholland int ncl_getattrcache(struct vnode *, struct vattr *);
109*47cc427dSpgoyette int ncl_readrpc(struct vnode *, struct uio *, struct kauth_cred *);
110*47cc427dSpgoyette int ncl_writerpc(struct vnode *, struct uio *, struct kauth_cred *, int *,
111*47cc427dSpgoyette     int *, int);
112*47cc427dSpgoyette int ncl_readlinkrpc(struct vnode *, struct uio *, struct kauth_cred *);
113*47cc427dSpgoyette int ncl_readdirrpc(struct vnode *, struct uio *, struct kauth_cred *,
114*47cc427dSpgoyette     struct lwp *);
115*47cc427dSpgoyette int ncl_readdirplusrpc(struct vnode *, struct uio *, struct kauth_cred *,
116*47cc427dSpgoyette     struct lwp *);
117*47cc427dSpgoyette int ncl_writebp(struct buf *, int, struct lwp *);
118*47cc427dSpgoyette int ncl_commit(struct vnode *, u_quad_t, int, struct kauth_cred *,
119*47cc427dSpgoyette     struct lwp *);
1206ca35587Sdholland void ncl_clearcommit(struct mount *);
121*47cc427dSpgoyette int ncl_fsinfo(struct nfsmount *, struct vnode *, struct kauth_cred *,
122*47cc427dSpgoyette     struct lwp *);
1236ca35587Sdholland int ncl_init(struct vfsconf *);
1246ca35587Sdholland int ncl_uninit(struct vfsconf *);
1256ca35587Sdholland void	ncl_nfsiodnew(void);
1266ca35587Sdholland void	ncl_nfsiodnew_tq(__unused void *, int);
1276ca35587Sdholland 
1286ca35587Sdholland #endif	/* _KERNEL */
1296ca35587Sdholland 
1306ca35587Sdholland #endif	/* _NFSCLIENT_NFS_H_ */
131