]> git.saurik.com Git - apple/xnu.git/blame - bsd/nfs/nfsnode.h
xnu-6153.101.6.tar.gz
[apple/xnu.git] / bsd / nfs / nfsnode.h
CommitLineData
1c79356b 1/*
cb323159 2 * Copyright (c) 2000-2019 Apple Inc. All rights reserved.
5d5c5d0d 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
2d21ac55
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
0a7de745 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
2d21ac55
A
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
0a7de745 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
29/*
30 * Copyright (c) 1989, 1993
31 * The Regents of the University of California. All rights reserved.
32 *
33 * This code is derived from software contributed to Berkeley by
34 * Rick Macklem at The University of Guelph.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed by the University of
47 * California, Berkeley and its contributors.
48 * 4. Neither the name of the University nor the names of its contributors
49 * may be used to endorse or promote products derived from this software
50 * without specific prior written permission.
51 *
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62 * SUCH DAMAGE.
63 *
64 * @(#)nfsnode.h 8.9 (Berkeley) 5/14/95
65 * FreeBSD-Id: nfsnode.h,v 1.24 1997/10/28 14:06:25 bde Exp $
66 */
67
68
69#ifndef _NFS_NFSNODE_H_
70#define _NFS_NFSNODE_H_
71
9bccf70c
A
72#include <sys/appleapiopts.h>
73
74#ifdef __APPLE_API_PRIVATE
1c79356b
A
75#ifndef _NFS_NFS_H_
76#include <nfs/nfs.h>
77#endif
6d2010ae 78#include <sys/kauth.h>
0a7de745 79#include <os/refcnt.h>
1c79356b
A
80
81/*
82 * Silly rename structure that hangs off the nfsnode until the name
2d21ac55 83 * can be removed by nfs_vnop_inactive()
1c79356b 84 */
2d21ac55 85struct nfs_sillyrename {
0a7de745
A
86 kauth_cred_t nsr_cred;
87 struct nfsnode *nsr_dnp;
88 int nsr_namlen;
89 char nsr_name[20];
1c79356b
A
90};
91
55e303ae
A
92/*
93 * The nfsbuf is the nfs equivalent to a struct buf.
94 */
95struct nfsbuf {
0a7de745
A
96 LIST_ENTRY(nfsbuf) nb_hash; /* hash chain */
97 LIST_ENTRY(nfsbuf) nb_vnbufs; /* nfsnode's nfsbuf chain */
98 TAILQ_ENTRY(nfsbuf) nb_free; /* free list position if not active. */
99 volatile uint32_t nb_flags; /* NB_* flags. */
100 volatile uint32_t nb_lflags; /* NBL_* flags. */
cb323159 101 os_refcnt_t nb_refs; /* outstanding references. */
0a7de745
A
102 uint32_t nb_bufsize; /* buffer size */
103 daddr64_t nb_lblkno; /* logical block number. */
104 uint64_t nb_verf; /* V3 write verifier */
105 int nb_commitlevel; /* lowest write commit level */
106 time_t nb_timestamp; /* buffer timestamp */
107 int nb_error; /* errno value. */
108 u_int32_t nb_valid; /* valid pages in buf */
109 u_int32_t nb_dirty; /* dirty pages in buf */
110 int nb_validoff; /* offset in buffer of valid region. */
111 int nb_validend; /* offset of end of valid region. */
112 int nb_dirtyoff; /* offset in buffer of dirty region. */
113 int nb_dirtyend; /* offset of end of dirty region. */
114 int nb_offio; /* offset in buffer of I/O region. */
115 int nb_endio; /* offset of end of I/O region. */
116 int nb_rpcs; /* Count of RPCs remaining for this buffer. */
117 caddr_t nb_data; /* mapped buffer */
118 nfsnode_t nb_np; /* nfsnode buffer belongs to */
119 kauth_cred_t nb_rcred; /* read credentials reference */
120 kauth_cred_t nb_wcred; /* write credentials reference */
121 void * nb_pagelist; /* upl */
55e303ae
A
122};
123
0a7de745 124#define NFS_MAXBSIZE (32 * PAGE_SIZE) /* valid/dirty page masks limit buffer size */
0c530ab8 125
0a7de745
A
126#define NFS_A_LOT_OF_NEEDCOMMITS 256 /* max# uncommitted buffers for a node */
127#define NFS_A_LOT_OF_DELAYED_WRITES MAX(nfsbufcnt/8,512) /* max# "delwri" buffers in system */
2d21ac55 128
91447636 129/*
2d21ac55 130 * These flags are kept in b_lflags...
91447636
A
131 * nfs_buf_mutex must be held before examining/updating
132 */
0a7de745
A
133#define NBL_BUSY 0x00000001 /* I/O in progress. */
134#define NBL_WANTED 0x00000002 /* Process wants this buffer. */
91447636 135
55e303ae
A
136/*
137 * These flags are kept in nb_flags and they're (purposefully)
138 * very similar to the B_* flags for struct buf.
91447636 139 * nfs_buf_mutex is not needed to examine/update these.
55e303ae 140 */
0a7de745
A
141#define NB_STALEWVERF 0x00000001 /* write verifier changed on us */
142#define NB_NEEDCOMMIT 0x00000002 /* buffer needs to be committed */
143#define NB_ASYNC 0x00000004 /* Start I/O, do not wait. */
144#define NB_CACHE 0x00000020 /* buffer data found in the cache */
145#define NB_STABLE 0x00000040 /* write FILESYNC not UNSTABLE */
146#define NB_DELWRI 0x00000080 /* delayed write: dirty range needs to be written */
147#define NB_DONE 0x00000200 /* I/O completed. */
148#define NB_EINTR 0x00000400 /* I/O was interrupted */
149#define NB_ERROR 0x00000800 /* I/O error occurred. */
150#define NB_INVAL 0x00002000 /* Does not contain valid info. */
151#define NB_NCRDAHEAD 0x00004000 /* "nocache readahead" data */
152#define NB_NOCACHE 0x00008000 /* Do not cache block after use. */
153#define NB_WRITE 0x00000000 /* Write buffer (pseudo flag). */
154#define NB_READ 0x00100000 /* Read buffer. */
155#define NB_MULTASYNCRPC 0x00200000 /* multiple async RPCs issued for buffer */
156#define NB_PAGELIST 0x00400000 /* Buffer describes pagelist I/O. */
157#define NB_WRITEINPROG 0x01000000 /* Write in progress. */
158#define NB_META 0x40000000 /* buffer contains meta-data. */
55e303ae 159
91447636 160/* Flags for operation type in nfs_buf_get() */
0a7de745
A
161#define NBLK_READ 0x00000001 /* buffer for read */
162#define NBLK_WRITE 0x00000002 /* buffer for write */
163#define NBLK_META 0x00000004 /* buffer for metadata */
164#define NBLK_OPMASK 0x00000007 /* operation mask */
91447636 165/* modifiers for above flags... */
0a7de745
A
166#define NBLK_NOWAIT 0x40000000 /* don't wait on busy buffer */
167#define NBLK_ONLYVALID 0x80000000 /* only return cached buffer */
91447636
A
168
169/* These flags are used for nfsbuf iterating */
0a7de745
A
170#define NBI_ITER 0x01 /* iteration in progress */
171#define NBI_ITERWANT 0x02 /* waiting to iterate */
172#define NBI_CLEAN 0x04 /* requesting clean buffers */
173#define NBI_DIRTY 0x08 /* requesting dirty buffers */
174#define NBI_NOWAIT 0x10 /* don't block on NBI_ITER */
91447636
A
175
176/* Flags for nfs_buf_acquire */
0a7de745
A
177#define NBAC_NOWAIT 0x01 /* Don't wait if buffer is busy */
178#define NBAC_REMOVE 0x02 /* Remove from free list once buffer is acquired */
91447636
A
179
180/* some convenience macros... */
0a7de745
A
181#define NBOFF(BP) ((off_t)(BP)->nb_lblkno * (off_t)(BP)->nb_bufsize)
182#define NBPGVALID(BP, P) (((BP)->nb_valid >> (P)) & 0x1)
183#define NBPGDIRTY(BP, P) (((BP)->nb_dirty >> (P)) & 0x1)
184#define NBPGVALID_SET(BP, P) ((BP)->nb_valid |= (1 << (P)))
185#define NBPGDIRTY_SET(BP, P) ((BP)->nb_dirty |= (1 << (P)))
55e303ae 186
0a7de745
A
187#define NBUFSTAMPVALID(BP) ((BP)->nb_timestamp != ~0)
188#define NBUFSTAMPINVALIDATE(BP) ((BP)->nb_timestamp = ~0)
91447636 189
55e303ae
A
190#define NFS_BUF_MAP(BP) \
191 do { \
0a7de745
A
192 if (!(BP)->nb_data && nfs_buf_map(BP)) \
193 panic("nfs_buf_map failed"); \
55e303ae
A
194 } while (0)
195
196LIST_HEAD(nfsbuflists, nfsbuf);
197TAILQ_HEAD(nfsbuffreehead, nfsbuf);
198
39236c6e
A
199extern lck_mtx_t *nfs_buf_mutex;
200extern int nfsbufcnt, nfsbufmin, nfsbufmax, nfsbufmetacnt, nfsbufmetamax;
201extern int nfsbuffreecnt, nfsbuffreemetacnt, nfsbufdelwricnt, nfsneedbuffer;
202extern int nfs_nbdwrite;
203extern struct nfsbuffreehead nfsbuffree, nfsbufdelwri;
55e303ae 204
2d21ac55
A
205#ifdef NFSBUFDEBUG
206#define NFSBUFCNTCHK() \
55e303ae
A
207 do { \
208 if ( (nfsbufcnt < 0) || \
0a7de745
A
209 (nfsbufcnt > nfsbufmax) || \
210 (nfsbufmetacnt < 0) || \
211 (nfsbufmetacnt > nfsbufmetamax) || \
212 (nfsbufmetacnt > nfsbufcnt) || \
213 (nfsbuffreecnt < 0) || \
214 (nfsbuffreecnt > nfsbufmax) || \
215 (nfsbuffreecnt > nfsbufcnt) || \
216 (nfsbuffreemetacnt < 0) || \
217 (nfsbuffreemetacnt > nfsbufmax) || \
218 (nfsbuffreemetacnt > nfsbufcnt) || \
219 (nfsbuffreemetacnt > nfsbufmetamax) || \
220 (nfsbuffreemetacnt > nfsbufmetacnt) || \
221 (nfsbufdelwricnt < 0) || \
222 (nfsbufdelwricnt > nfsbufmax) || \
223 (nfsbufdelwricnt > nfsbufcnt) || \
224 (nfs_nbdwrite < 0) || \
225 (nfs_nbdwrite > nfsbufcnt) || \
226 0) \
227 panic("nfsbuf count error: max %d meta %d cnt %d meta %d free %d meta %d delwr %d bdw %d\n", \
228 nfsbufmax, nfsbufmetamax, nfsbufcnt, nfsbufmetacnt, nfsbuffreecnt, nfsbuffreemetacnt, \
229 nfsbufdelwricnt, nfs_nbdwrite); \
2d21ac55
A
230 } while (0)
231#else
232#define NFSBUFCNTCHK()
233#endif
234
b0d623f7
A
235/*
236 * NFS directory buffer
237 *
238 * Each buffer for a directory consists of:
239 *
240 * - a small header
241 * - a packed list of direntry structures
242 * (if RDIRPLUS is enabled, a file handle and attrstamp are
243 * packed after the direntry name.)
244 * - free/unused space
245 * - if RDIRPLUS is enabled, an array of attributes
246 * that is indexed backwards from the end of the buffer.
247 */
248struct nfs_dir_buf_header {
0a7de745
A
249 uint16_t ndbh_flags; /* flags (see below) */
250 uint16_t ndbh_count; /* # of entries */
251 uint32_t ndbh_entry_end; /* end offset of direntry data */
252 uint32_t ndbh_ncgen; /* name cache generation# */
253 uint32_t ndbh_pad; /* reserved */
b0d623f7
A
254};
255/* ndbh_flags */
0a7de745
A
256#define NDB_FULL 0x0001 /* buffer has been filled */
257#define NDB_EOF 0x0002 /* buffer contains EOF */
258#define NDB_PLUS 0x0004 /* buffer contains RDIRPLUS data */
b0d623f7
A
259
260#define NFS_DIR_BUF_FIRST_DIRENTRY(BP) \
261 ((struct direntry*)((char*)((BP)->nb_data) + sizeof(*ndbhp)))
262#define NFS_DIR_BUF_NVATTR(BP, IDX) \
263 (&((struct nfs_vattr*)((char*)((BP)->nb_data) + (BP)->nb_bufsize))[-((IDX)+1)])
264#define NFS_DIRENTRY_LEN(namlen) \
265 ((sizeof(struct direntry) + (namlen) - (MAXPATHLEN-1) + 7) & ~7)
266#define NFS_DIRENT_LEN(namlen) \
267 ((sizeof(struct dirent) - (NAME_MAX+1)) + (((namlen) + 1 + 3) &~ 3))
268#define NFS_DIRENTRY_NEXT(DP) \
269 ((struct direntry*)((char*)(DP) + (DP)->d_reclen))
270#define NFS_DIR_COOKIE_POTENTIALLY_TRUNCATED(C) \
271 ((C) && ((((C) >> 32) == 0) || (((C) & 0x80000000ULL) && (((C) >> 32) == 0xffffffff))))
272#define NFS_DIR_COOKIE_SAME32(C1, C2) \
273 (((C1) & 0xffffffffULL) == ((C2) & 0xffffffffULL))
274
275/*
276 * NFS directory cookie cache
277 *
278 * This structure is used to cache cookie-to-buffer mappings for
279 * cookies recently returned from READDIR. The entries are kept in an
280 * array. The most-recently-used (MRU) list is headed by the entry at
281 * index "mru". The index of the next entry in the list is kept in the
282 * "next" array. (An index value of -1 marks an invalid entry.)
283 */
0a7de745 284#define NFSNUMCOOKIES 14
b0d623f7 285struct nfsdmap {
0a7de745
A
286 int8_t free; /* next unused slot */
287 int8_t mru; /* head of MRU list */
288 int8_t next[NFSNUMCOOKIES]; /* MRU list links */
b0d623f7 289 struct {
0a7de745
A
290 uint64_t key; /* cookie */
291 uint64_t lbn; /* lbn of buffer */
292 } cookies[NFSNUMCOOKIES]; /* MRU list entries */
b0d623f7
A
293};
294
2d21ac55
A
295/*
296 * NFS vnode attribute structure
297 */
0a7de745
A
298#define NFSTIME_ACCESS 0 /* time of last access */
299#define NFSTIME_MODIFY 1 /* time of last modification */
300#define NFSTIME_CHANGE 2 /* time file changed */
301#define NFSTIME_CREATE 3 /* time file created */
302#define NFSTIME_BACKUP 4 /* time of last backup */
cb323159
A
303#define NFSTIME_ADDED 5 /* time added (FPnfs only) */
304#define NFSTIME_COUNT 6
2d21ac55
A
305
306#define NFS_COMPARE_MTIME(TVP, NVAP, CMP) \
0a7de745
A
307 (((TVP)->tv_sec == (NVAP)->nva_timesec[NFSTIME_MODIFY]) ? \
308 ((TVP)->tv_nsec CMP (NVAP)->nva_timensec[NFSTIME_MODIFY]) : \
2d21ac55
A
309 ((TVP)->tv_sec CMP (NVAP)->nva_timesec[NFSTIME_MODIFY]))
310#define NFS_COPY_TIME(TVP, NVAP, WHICH) \
311 do { \
312 (TVP)->tv_sec = (NVAP)->nva_timesec[NFSTIME_##WHICH]; \
313 (TVP)->tv_nsec = (NVAP)->nva_timensec[NFSTIME_##WHICH]; \
55e303ae
A
314 } while (0)
315
91447636 316struct nfs_vattr {
0a7de745
A
317 enum vtype nva_type; /* vnode type (for create) */
318 uint32_t nva_mode; /* file's access mode (and type) */
319 uid_t nva_uid; /* owner user id */
320 gid_t nva_gid; /* owner group id */
321 guid_t nva_uuuid; /* owner user UUID */
322 guid_t nva_guuid; /* owner group UUID */
323 kauth_acl_t nva_acl; /* access control list */
324 nfs_specdata nva_rawdev; /* device the special file represents */
325 uint32_t nva_flags; /* file flags (see below) */
326 uint32_t nva_maxlink; /* maximum # of links (v4) */
327 uint64_t nva_nlink; /* number of references to file */
328 uint64_t nva_fileid; /* file id */
329 nfs_fsid nva_fsid; /* file system id */
330 uint64_t nva_size; /* file size in bytes */
331 uint64_t nva_bytes; /* bytes of disk space held by file */
332 uint64_t nva_change; /* change attribute */
333 int64_t nva_timesec[NFSTIME_COUNT];
334 int32_t nva_timensec[NFSTIME_COUNT];
335 uint32_t nva_bitmap[NFS_ATTR_BITMAP_LEN]; /* attributes that are valid */
cb323159
A
336
337 /* FPnfs only. */
338 uint32_t nva_bsd_flags; /* BSD flags */
339 uint64_t nva_parentid; /* parent file id */
340 uint64_t nva_allocsize; /* size allocated on disk */
91447636
A
341};
342
6d2010ae 343/* nva_flags */
0a7de745
A
344#define NFS_FFLAG_ARCHIVED 0x0001
345#define NFS_FFLAG_HIDDEN 0x0002
346#define NFS_FFLAG_HAS_NAMED_ATTRS 0x0004 /* file has named attributes */
347#define NFS_FFLAG_TRIGGER 0x0008 /* node is a trigger/mirror mount point */
348#define NFS_FFLAG_TRIGGER_REFERRAL 0x0010 /* trigger is a referral */
349#define NFS_FFLAG_IS_ATTR 0x8000 /* file is a named attribute file/directory */
cb323159
A
350/* FPnfs only */
351#define NFS_FFLAG_FPNFS_BSD_FLAGS 0x01000000
352#define NFS_FFLAG_FPNFS_PARENTID 0x02000000
353#define NFS_FFLAG_FPNFS_ADDEDTIME 0x04000000
2d21ac55 354
b0d623f7 355/* flags for nfs_getattr() */
0a7de745
A
356#define NGA_CACHED 0x0001 /* use cached attributes (if still valid) */
357#define NGA_UNCACHED 0x0002 /* fetch new attributes */
358#define NGA_ACL 0x0004 /* fetch ACL */
359#define NGA_MONITOR 0x0008 /* vnode monitor attr update poll */
360#define NGA_SOFT 0x0010 /* use cached attributes if ETIMEOUT */
6d2010ae
A
361
362/* macros for initting/cleaning up nfs_vattr structures */
0a7de745 363#define NVATTR_INIT(NVAP) \
6d2010ae 364 do { \
0a7de745
A
365 NFS_CLEAR_ATTRIBUTES((NVAP)->nva_bitmap); \
366 (NVAP)->nva_flags = 0; \
367 (NVAP)->nva_acl = NULL; \
6d2010ae 368 } while (0)
0a7de745 369#define NVATTR_CLEANUP(NVAP) \
6d2010ae 370 do { \
0a7de745
A
371 NFS_CLEAR_ATTRIBUTES((NVAP)->nva_bitmap); \
372 if ((NVAP)->nva_acl) { \
373 kauth_acl_free((NVAP)->nva_acl); \
374 (NVAP)->nva_acl = NULL; \
375 } \
6d2010ae 376 } while (0)
b0d623f7 377
2d21ac55
A
378/*
379 * macros for detecting node changes
380 *
381 * These macros help us determine if a file has been changed on the server and
382 * thus whether or not we need to invalidate any cached data.
383 *
384 * For NFSv2/v3, the modification time is used.
385 * For NFSv4, the change attribute is used.
386 */
387#define NFS_CHANGED(VERS, NP, NVAP) \
0a7de745
A
388 (((VERS) >= NFS_VER4) ? \
389 ((NP)->n_change != (NVAP)->nva_change) : \
390 NFS_COMPARE_MTIME(&(NP)->n_mtime, (NVAP), !=))
2d21ac55 391#define NFS_CHANGED_NC(VERS, NP, NVAP) \
0a7de745
A
392 (((VERS) >= NFS_VER4) ? \
393 ((NP)->n_ncchange != (NVAP)->nva_change) : \
394 NFS_COMPARE_MTIME(&(NP)->n_ncmtime, (NVAP), !=))
2d21ac55
A
395#define NFS_CHANGED_UPDATE(VERS, NP, NVAP) \
396 do { \
0a7de745
A
397 if ((VERS) >= NFS_VER4) \
398 (NP)->n_change = (NVAP)->nva_change; \
399 else \
400 NFS_COPY_TIME(&(NP)->n_mtime, (NVAP), MODIFY); \
2d21ac55
A
401 } while (0)
402#define NFS_CHANGED_UPDATE_NC(VERS, NP, NVAP) \
403 do { \
0a7de745
A
404 if ((VERS) >= NFS_VER4) \
405 (NP)->n_ncchange = (NVAP)->nva_change; \
406 else \
407 NFS_COPY_TIME(&(NP)->n_ncmtime, (NVAP), MODIFY); \
2d21ac55
A
408 } while (0)
409
b0d623f7 410
39236c6e
A
411extern lck_grp_t *nfs_open_grp;
412extern uint32_t nfs_open_owner_seqnum, nfs_lock_owner_seqnum;
b0d623f7
A
413
414/*
415 * NFSv4 open owner structure - one per cred per mount
416 */
417struct nfs_open_owner {
0a7de745
A
418 TAILQ_ENTRY(nfs_open_owner) noo_link; /* List of open owners (on mount) */
419 lck_mtx_t noo_lock; /* owner mutex */
420 struct nfsmount * noo_mount; /* NFS mount */
421 os_refcnt_t noo_refcnt; /* # outstanding references */
422 uint32_t noo_flags; /* see below */
423 kauth_cred_t noo_cred; /* credentials of open owner */
424 uint32_t noo_name; /* unique name used otw */
425 uint32_t noo_seqid; /* client-side sequence ID */
426 TAILQ_HEAD(, nfs_open_file) noo_opens; /* list of open files */
b0d623f7
A
427};
428/* noo_flags */
0a7de745
A
429#define NFS_OPEN_OWNER_LINK 0x1 /* linked into mount's open owner list */
430#define NFS_OPEN_OWNER_BUSY 0x2 /* open state-modifying operation in progress */
431#define NFS_OPEN_OWNER_WANT 0x4 /* someone else wants to mark busy */
b0d623f7
A
432
433/*
434 * NFS open file structure - one per open owner per nfsnode
435 */
436struct nfs_open_file {
0a7de745
A
437 lck_mtx_t nof_lock; /* open file mutex */
438 TAILQ_ENTRY(nfs_open_file) nof_link; /* list of open files */
439 TAILQ_ENTRY(nfs_open_file) nof_oolink; /* list of open owner's open files */
440 struct nfs_open_owner * nof_owner; /* open owner */
441 nfsnode_t nof_np; /* nfsnode this open is for */
442 nfs_stateid nof_stateid; /* open stateid */
443 thread_t nof_creator; /* thread that created file */
444 uint32_t nof_opencnt; /* open file count */
445 uint16_t nof_flags; /* see below */
446 uint8_t nof_access:4; /* access mode for this open */
447 uint8_t nof_deny:4; /* deny mode for this open */
448 uint8_t nof_mmap_access:4; /* mmap open access mode */
449 uint8_t nof_mmap_deny:4; /* mmap open deny mode */
b0d623f7 450 /* counts of access/deny mode open combinations */
0a7de745
A
451 uint32_t nof_r; /* read opens (deny none) */
452 uint32_t nof_w; /* write opens (deny none) */
453 uint32_t nof_rw; /* read/write opens (deny none) */
454 uint32_t nof_r_dw; /* read deny-write opens */
b0d623f7 455 /* the rest of the counts have a max of 2 (1 for open + 1 for mmap) */
0a7de745
A
456 uint32_t nof_w_dw:2; /* write deny-write opens (max 2) */
457 uint32_t nof_rw_dw:2; /* read/write deny-write opens (max 2) */
458 uint32_t nof_r_drw:2; /* read deny-read/write opens (max 2) */
459 uint32_t nof_w_drw:2; /* write deny-read/write opens (max 2) */
460 uint32_t nof_rw_drw:2; /* read/write deny-read/write opens (max 2) */
6d2010ae 461 /* counts of DELEGATED access/deny mode open combinations */
0a7de745
A
462 uint32_t nof_d_w_dw:2; /* write deny-write opens (max 2) */
463 uint32_t nof_d_rw_dw:2; /* read/write deny-write opens (max 2) */
464 uint32_t nof_d_r_drw:2; /* read deny-read/write opens (max 2) */
465 uint32_t nof_d_w_drw:2; /* write deny-read/write opens (max 2) */
466 uint32_t nof_d_rw_drw:2; /* read/write deny-read/write opens (max 2) */
467 uint32_t nof_d_r; /* read opens (deny none) */
468 uint32_t nof_d_w; /* write opens (deny none) */
469 uint32_t nof_d_rw; /* read/write opens (deny none) */
470 uint32_t nof_d_r_dw; /* read deny-write opens */
b0d623f7
A
471};
472/* nof_flags */
0a7de745
A
473#define NFS_OPEN_FILE_BUSY 0x0001 /* open state-modifying operation in progress */
474#define NFS_OPEN_FILE_WANT 0x0002 /* someone else wants to mark busy */
475#define NFS_OPEN_FILE_CREATE 0x0004 /* has an open(RW) from a "CREATE" call */
476#define NFS_OPEN_FILE_NEEDCLOSE 0x0008 /* has an open(R) from an (unopen) VNOP_READ or VNOP_MMAP call */
477#define NFS_OPEN_FILE_SETATTR 0x0020 /* has an open(W) to perform a SETATTR(size) */
478#define NFS_OPEN_FILE_POSIXLOCK 0x0040 /* server supports POSIX locking semantics */
479#define NFS_OPEN_FILE_LOST 0x0080 /* open state has been lost */
480#define NFS_OPEN_FILE_REOPEN 0x0100 /* file needs to be reopened */
481#define NFS_OPEN_FILE_REOPENING 0x0200 /* file is being reopened */
b0d623f7
A
482
483struct nfs_lock_owner;
484/*
485 * NFS file lock
486 *
487 * Each lock request (pending or granted) has an
488 * nfs_file_lock structure representing its state.
489 */
490struct nfs_file_lock {
0a7de745
A
491 TAILQ_ENTRY(nfs_file_lock) nfl_link; /* List of locks on nfsnode */
492 TAILQ_ENTRY(nfs_file_lock) nfl_lolink; /* List of locks held by locker */
493 struct nfs_lock_owner * nfl_owner; /* lock owner that holds this lock */
494 uint64_t nfl_start; /* starting offset */
495 uint64_t nfl_end; /* ending offset (inclusive) */
496 uint32_t nfl_blockcnt; /* # locks blocked on this lock */
497 uint16_t nfl_flags; /* see below */
498 uint8_t nfl_type; /* lock type: read/write */
b0d623f7
A
499};
500/* nfl_flags */
0a7de745
A
501#define NFS_FILE_LOCK_ALLOC 0x01 /* lock was allocated */
502#define NFS_FILE_LOCK_STYLE_POSIX 0x02 /* POSIX-style fcntl() lock */
503#define NFS_FILE_LOCK_STYLE_FLOCK 0x04 /* flock(2)-style lock */
504#define NFS_FILE_LOCK_STYLE_MASK 0x06 /* lock style mask */
505#define NFS_FILE_LOCK_WAIT 0x08 /* may block on conflicting locks */
506#define NFS_FILE_LOCK_BLOCKED 0x10 /* request is blocked */
507#define NFS_FILE_LOCK_DEAD 0x20 /* lock (request) no longer exists */
508#define NFS_FILE_LOCK_DELEGATED 0x40 /* lock acquired via delegation */
b0d623f7
A
509
510TAILQ_HEAD(nfs_file_lock_queue, nfs_file_lock);
511
512/*
513 * Calculate length of lock range given the endpoints.
514 * Note that struct flock has "to EOF" reported as 0 but
515 * the NFSv4 protocol has "to EOF" reported as UINT64_MAX.
516 */
0a7de745
A
517#define NFS_FLOCK_LENGTH(S, E) (((E) == UINT64_MAX) ? 0 : ((E) - (S) + 1))
518#define NFS_LOCK_LENGTH(S, E) (((E) == UINT64_MAX) ? UINT64_MAX : ((E) - (S) + 1))
b0d623f7
A
519
520/*
521 * NFSv4 lock owner structure - per open owner per process per nfsnode
522 *
523 * A lock owner is a process + an nfsnode.
524 *
525 * Note that flock(2) locks technically should have the lock owner be
526 * an fglob pointer instead of a process. However, implementing that
527 * correctly would not be trivial. So, for now, flock(2) locks are
528 * essentially treated like whole-file POSIX locks.
529 */
530struct nfs_lock_owner {
0a7de745
A
531 lck_mtx_t nlo_lock; /* owner mutex */
532 TAILQ_ENTRY(nfs_lock_owner) nlo_link; /* List of lock owners (on nfsnode) */
533 struct nfs_open_owner * nlo_open_owner; /* corresponding open owner */
534 struct nfs_file_lock_queue nlo_locks; /* list of locks held */
535 struct nfs_file_lock nlo_alock; /* most lockers will only ever have one */
536 struct timeval nlo_pid_start; /* Start time of process id */
537 pid_t nlo_pid; /* lock-owning process ID */
538 os_refcnt_t nlo_refcnt; /* # outstanding references */
539 uint32_t nlo_flags; /* see below */
540 uint32_t nlo_name; /* unique name used otw */
541 uint32_t nlo_seqid; /* client-side sequence ID */
542 uint32_t nlo_stategenid; /* mount state generation ID */
543 nfs_stateid nlo_stateid; /* lock stateid */
b0d623f7
A
544};
545/* nlo_flags */
0a7de745
A
546#define NFS_LOCK_OWNER_LINK 0x1 /* linked into mount's lock owner list */
547#define NFS_LOCK_OWNER_BUSY 0x2 /* lock state-modifying operation in progress */
548#define NFS_LOCK_OWNER_WANT 0x4 /* someone else wants to mark busy */
b0d623f7 549
1c79356b 550/*
2d21ac55
A
551 * The nfsnode is the NFS equivalent of an inode.
552 * There is a unique nfsnode for each NFS vnode.
1c79356b 553 * An nfsnode is 'named' by its file handle. (nget/nfs_node.c)
1c79356b
A
554 * NB: Hopefully the current order of the fields is such that everything will
555 * be well aligned and, therefore, tightly packed.
556 */
2d21ac55 557
0a7de745 558#define NFS_ACCESS_CACHE_SIZE 3
2d21ac55 559
1c79356b 560struct nfsnode {
0a7de745
A
561 lck_mtx_t n_lock; /* nfs node lock */
562 lck_rw_t n_datalock; /* nfs node data lock */
563 void *n_datalockowner;/* nfs node data lock owner (exclusive) */
564 LIST_ENTRY(nfsnode) n_hash; /* Hash chain */
565 LIST_ENTRY(nfsnode) n_monlink; /* list of monitored nodes */
566 u_quad_t n_size; /* Current size of file */
567 u_quad_t n_newsize; /* new size of file (pending update) */
568 u_int64_t n_xid; /* last xid to loadattr */
569 struct nfs_vattr n_vattr; /* Vnode attribute cache */
570 time_t n_attrstamp; /* Attr. cache timestamp */
571 time_t n_aclstamp; /* ACL cache timestamp */
572 time_t n_evtstamp; /* last vnode event timestamp */
573 uint32_t n_events; /* pending vnode events */
574 u_int8_t n_access[NFS_ACCESS_CACHE_SIZE + 1]; /* ACCESS cache */
575 uid_t n_accessuid[NFS_ACCESS_CACHE_SIZE]; /* credentials having access */
576 time_t n_accessstamp[NFS_ACCESS_CACHE_SIZE]; /* access cache timestamp */
ea3f0419
A
577 time_t n_rdirplusstamp_sof; /* Readdirplus sof timestamp */
578 time_t n_rdirplusstamp_eof; /* Readdirplus eof timestamp */
55e303ae 579 union {
0a7de745
A
580 struct {
581 struct timespec n3_mtime; /* Prev modify time. */
582 struct timespec n3_ncmtime; /* namecache modify time. */
583 } v3;
584 struct {
585 uint64_t n4_change;/* prev change attribute */
586 uint64_t n4_ncchange;/* namecache change attribute */
587 u_char *n4_attrdirfh;/* associated attr directory fh */
588 struct timeval n4_lastio;/* time of most recent I/O on attr */
589 } v4;
2d21ac55 590 } n_un4;
0a7de745
A
591 vnode_t n_parent; /* this node's parent */
592 u_char *n_fhp; /* NFS File Handle */
593 vnode_t n_vnode; /* associated vnode */
594 mount_t n_mount; /* associated mount (NHINIT) */
595 int n_error; /* Save write error value */
1c79356b 596 union {
0a7de745
A
597 struct timespec ns_atim; /* Special file times */
598 struct timespec nl_rltim; /* Time of last readlink */
599 daddr64_t nf_lastread; /* last block# read from (for readahead) */
600 uint64_t nd_cookieverf; /* Cookie verifier (dir only) */
1c79356b
A
601 } n_un1;
602 union {
0a7de745
A
603 struct timespec ns_mtim; /* Special file times */
604 daddr64_t nf_lastrahead; /* last block# read ahead */
605 uint64_t nd_eofcookie; /* Dir. EOF cookie cache */
1c79356b
A
606 } n_un2;
607 union {
2d21ac55 608 struct nfs_sillyrename *nf_silly;/* Ptr to silly rename struct */
b0d623f7 609 struct nfsdmap *nd_cookiecache; /* dir cookie cache */
1c79356b 610 } n_un3;
0a7de745
A
611 uint32_t n_flag; /* node flags */
612 u_short n_fhsize; /* size in bytes, of fh */
613 u_short n_hflag; /* node hash flags */
614 u_short n_bflag; /* node buffer flags */
615 u_short n_mflag; /* node mount flags */
616 u_char n_fh[NFS_SMALLFH];/* Small File Handle */
617 uint32_t n_auth; /* security flavor used for this node */
618 struct nfsbuflists n_cleanblkhd; /* clean blocklist head */
619 struct nfsbuflists n_dirtyblkhd; /* dirty blocklist head */
b0d623f7 620 union {
0a7de745
A
621 int nf_wrbusy; /* # threads in write/fsync */
622 uint32_t nd_ncgen; /* dir name cache generation# */
b0d623f7
A
623 } n_un5;
624 union {
0a7de745
A
625 int nf_needcommitcnt;/* # bufs that need committing */
626 daddr64_t nd_lastdbl; /* last dir buf lookup block# */
b0d623f7 627 } n_un6;
0a7de745 628 int n_bufiterflags; /* buf iterator flags */
6d2010ae 629 union {
0a7de745
A
630 int nf_numoutput; /* write I/Os in progress */
631 int nd_trigseq; /* vnode trigger seq# */
6d2010ae 632 } n_un7;
b0d623f7 633 /* open state */
0a7de745
A
634 lck_mtx_t n_openlock; /* nfs node open lock */
635 uint32_t n_openflags; /* open state flags */
636 uint32_t n_openrefcnt; /* # non-file opens */
637 TAILQ_HEAD(, nfs_open_file) n_opens; /* list of open files */
b0d623f7
A
638 /* lock state */
639 TAILQ_HEAD(, nfs_lock_owner) n_lock_owners; /* list of lock owners */
0a7de745 640 struct nfs_file_lock_queue n_locks; /* list of locks */
b0d623f7 641 /* delegation state */
0a7de745
A
642 nfs_stateid n_dstateid; /* delegation stateid */
643 TAILQ_ENTRY(nfsnode) n_dlink; /* delegation list link */
644 TAILQ_ENTRY(nfsnode) n_dreturn; /* delegation return list link */
645 struct kauth_ace n_dace; /* delegation ACE */
1c79356b
A
646};
647
0a7de745
A
648#define NFS_DATA_LOCK_SHARED 1
649#define NFS_DATA_LOCK_EXCLUSIVE 2
2d21ac55 650
0a7de745
A
651#define nfstimespeccmp(tvp, uvp, cmp) \
652 (((tvp)->tv_sec == (uvp)->tv_sec) ? \
653 ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
91447636
A
654 ((tvp)->tv_sec cmp (uvp)->tv_sec))
655
55e303ae
A
656#define CHECK_NEEDCOMMITCNT(np) \
657 do { \
0a7de745
A
658 if ((np)->n_needcommitcnt < 0) { \
659 printf("nfs: n_needcommitcnt negative\n"); \
660 (np)->n_needcommitcnt = 0; \
661 } \
55e303ae
A
662 } while (0)
663
0a7de745
A
664#define n_atim n_un1.ns_atim
665#define n_mtim n_un2.ns_mtim
666#define n_rltim n_un1.nl_rltim
667#define n_lastread n_un1.nf_lastread
668#define n_lastrahead n_un2.nf_lastrahead
669#define n_sillyrename n_un3.nf_silly
670#define n_wrbusy n_un5.nf_wrbusy
671#define n_needcommitcnt n_un6.nf_needcommitcnt
672#define n_numoutput n_un7.nf_numoutput
673#define n_cookieverf n_un1.nd_cookieverf
674#define n_eofcookie n_un2.nd_eofcookie
675#define n_cookiecache n_un3.nd_cookiecache
676#define n_ncgen n_un5.nd_ncgen
677#define n_lastdbl n_un6.nd_lastdbl
678#define n_trigseq n_un7.nd_trigseq
679#define n_mtime n_un4.v3.n3_mtime
680#define n_ncmtime n_un4.v3.n3_ncmtime
681#define n_change n_un4.v4.n4_change
682#define n_ncchange n_un4.v4.n4_ncchange
683#define n_attrdirfh n_un4.v4.n4_attrdirfh
684#define n_lastio n_un4.v4.n4_lastio
1c79356b
A
685
686/*
687 * Flags for n_flag
688 */
0a7de745
A
689#define NUPDATESIZE 0x00001 /* size of file needs updating */
690#define NREVOKE 0x00002 /* node revoked */
691#define NMODIFIED 0x00004 /* Might have a modified buffer in bio */
692#define NWRITEERR 0x00008 /* Flag write errors so close will know */
693#define NNEEDINVALIDATE 0x00010 /* need to call vinvalbuf() */
694#define NGETATTRINPROG 0x00020 /* GETATTR RPC in progress */
695#define NGETATTRWANT 0x00040 /* waiting for GETATTR RPC */
696#define NACC 0x00100 /* Special file accessed */
697#define NUPD 0x00200 /* Special file updated */
698#define NCHG 0x00400 /* Special file times changed */
699#define NNEGNCENTRIES 0x00800 /* directory has negative name cache entries */
700#define NBUSY 0x01000 /* node is busy */
701#define NBUSYWANT 0x02000 /* waiting on busy node */
702#define NISDOTZFS 0x04000 /* a ".zfs" directory */
703#define NISDOTZFSCHILD 0x08000 /* a child of a ".zfs" directory */
704#define NISMAPPED 0x10000 /* node is mmapped */
705#define NREFRESH 0x20000 /* node's fh needs to be refreshed */
706#define NREFRESHWANT 0x40000 /* Waiting for fh to be refreshed */
cb323159 707#define NDISARMTRIGGER 0x80000 /* Ignore node's mirror mount trigger */
1c79356b 708
2d21ac55
A
709/*
710 * Flags for n_hflag
711 * Note: protected by nfs_node_hash_mutex
712 */
0a7de745
A
713#define NHHASHED 0x0001 /* node is in hash table */
714#define NHINIT 0x0002 /* node is being initialized */
715#define NHLOCKED 0x0004 /* node is locked (initting or deleting) */
716#define NHLOCKWANT 0x0008 /* someone wants to lock */
2d21ac55
A
717
718/*
719 * Flags for n_bflag
720 * Note: protected by nfs_buf_mutex
721 */
0a7de745
A
722#define NBFLUSHINPROG 0x0001 /* Avoid multiple calls to nfs_flush() */
723#define NBFLUSHWANT 0x0002 /* waiting for nfs_flush() to complete */
724#define NBINVALINPROG 0x0004 /* Avoid multiple calls to nfs_vinvalbuf() */
725#define NBINVALWANT 0x0008 /* waiting for nfs_vinvalbuf() to complete */
2d21ac55 726
6d2010ae
A
727/*
728 * Flags for n_mflag
729 * Note: protected by nfsmount's nm_lock
730 */
0a7de745
A
731#define NMMONSCANINPROG 0x0001 /* monitored node is currently updating attributes */
732#define NMMONSCANWANT 0x0002 /* waiting for attribute update to complete */
6d2010ae 733
b0d623f7
A
734/*
735 * n_openflags
736 * Note: protected by n_openlock
737 */
0a7de745
A
738#define N_OPENBUSY 0x0001 /* open state is busy - being updated */
739#define N_OPENWANT 0x0002 /* someone wants to mark busy */
740#define N_DELEG_READ 0x0004 /* we have a read delegation */
741#define N_DELEG_WRITE 0x0008 /* we have a write delegation */
742#define N_DELEG_MASK 0x000c /* delegation mask */
743#define N_DELEG_RETURN 0x0010 /* delegation queued for return */
744#define N_DELEG_RETURNING 0x0020 /* delegation being returned */
b0d623f7 745
6d2010ae 746/* attr/access/ACL cache timestamp macros */
0a7de745
A
747#define NATTRVALID(np) ((np)->n_attrstamp != ~0)
748#define NATTRINVALIDATE(np) ((np)->n_attrstamp = ~0)
749#define NACCESSVALID(np, slot) (((slot) >= 0) && ((slot) < NFS_ACCESS_CACHE_SIZE) && ((np)->n_accessstamp[(slot)] != ~0))
6d2010ae 750#define NACCESSINVALIDATE(np) \
2d21ac55 751 do { \
0a7de745
A
752 int __i; \
753 for (__i=0; __i < NFS_ACCESS_CACHE_SIZE; __i++) \
754 (np)->n_accessstamp[__i] = ~0; \
755 (np)->n_access[NFS_ACCESS_CACHE_SIZE] = 0; \
2d21ac55 756 } while (0)
0a7de745
A
757#define NACLVALID(np) ((np)->n_aclstamp != ~0)
758#define NACLINVALIDATE(np) ((np)->n_aclstamp = ~0)
91447636
A
759
760/*
761 * NFS-specific flags for nfs_vinvalbuf/nfs_flush
762 */
0a7de745 763#define V_IGNORE_WRITEERR 0x8000
91447636
A
764
765/*
766 * Flags for nfs_nget()
767 */
0a7de745
A
768#define NG_MARKROOT 0x0001 /* mark vnode as root of FS */
769#define NG_MAKEENTRY 0x0002 /* add name cache entry for vnode */
770#define NG_NOCREATE 0x0004 /* don't create a new node, return existing one */
91447636 771
1c79356b
A
772/*
773 * Convert between nfsnode pointers and vnode pointers
774 */
0a7de745
A
775#define VTONFS(vp) ((nfsnode_t)vnode_fsnode(vp))
776#define NFSTOV(np) ((np)->n_vnode)
91447636
A
777
778/* nfsnode hash table mutex */
39236c6e 779extern lck_mtx_t *nfs_node_hash_mutex;
1c79356b 780
6d2010ae
A
781/*
782 * printf-like helper macro that also outputs node name.
783 */
784#define NP(NP, FMT, ...) \
785 do { \
0a7de745
A
786 const char *__vname = (NP) ? vnode_getname(NFSTOV(NP)) : NULL; \
787 printf(FMT " %s\n", ##__VA_ARGS__, __vname ? __vname : "???"); \
788 if (__vname) vnode_putname(__vname); \
6d2010ae
A
789 } while (0)
790
1c79356b 791/*
91447636 792 * nfsiod structures
1c79356b 793 */
2d21ac55 794struct nfsiod {
0a7de745
A
795 TAILQ_ENTRY(nfsiod) niod_link; /* List of nfsiods */
796 struct nfsmount * niod_nmp; /* mount point for this nfsiod */
2d21ac55
A
797};
798TAILQ_HEAD(nfsiodlist, nfsiod);
799TAILQ_HEAD(nfsiodmountlist, nfsmount);
39236c6e
A
800extern struct nfsiodlist nfsiodfree, nfsiodwork;
801extern struct nfsiodmountlist nfsiodmounts;
802extern lck_mtx_t *nfsiod_mutex;
1c79356b
A
803
804#if defined(KERNEL)
fa4905b1 805
91447636 806typedef int vnop_t(void *);
0a7de745
A
807extern vnop_t **fifo_nfsv2nodeop_p;
808extern vnop_t **nfsv2_vnodeop_p;
cb323159 809extern vnop_t **fpnfs_vnodeop_p;
0a7de745 810extern vnop_t **spec_nfsv2nodeop_p;
cb323159 811#if CONFIG_NFS4
0a7de745
A
812extern vnop_t **fifo_nfsv4nodeop_p;
813extern vnop_t **nfsv4_vnodeop_p;
814extern vnop_t **spec_nfsv4nodeop_p;
cb323159 815#endif
1c79356b
A
816/*
817 * Prototypes for NFS vnode operations
818 */
2d21ac55 819#define nfs_vnop_revoke nop_revoke
0a7de745
A
820int nfs_vnop_inactive(struct vnop_inactive_args *);
821int nfs_vnop_reclaim(struct vnop_reclaim_args *);
2d21ac55 822
b0d623f7
A
823int nfs_node_lock(nfsnode_t);
824int nfs_node_lock_internal(nfsnode_t, int);
825void nfs_node_lock_force(nfsnode_t);
826void nfs_node_unlock(nfsnode_t);
827int nfs_node_lock2(nfsnode_t, nfsnode_t);
828void nfs_node_unlock2(nfsnode_t, nfsnode_t);
829int nfs_node_set_busy(nfsnode_t, thread_t);
830int nfs_node_set_busy2(nfsnode_t, nfsnode_t, thread_t);
831int nfs_node_set_busy4(nfsnode_t, nfsnode_t, nfsnode_t, nfsnode_t, thread_t);
832void nfs_node_clear_busy(nfsnode_t);
833void nfs_node_clear_busy2(nfsnode_t, nfsnode_t);
834void nfs_node_clear_busy4(nfsnode_t, nfsnode_t, nfsnode_t, nfsnode_t);
2d21ac55 835void nfs_data_lock(nfsnode_t, int);
b0d623f7
A
836void nfs_data_lock_noupdate(nfsnode_t, int);
837void nfs_data_lock_internal(nfsnode_t, int, int);
2d21ac55 838void nfs_data_unlock(nfsnode_t);
b0d623f7
A
839void nfs_data_unlock_noupdate(nfsnode_t);
840void nfs_data_unlock_internal(nfsnode_t, int);
2d21ac55 841void nfs_data_update_size(nfsnode_t, int);
1c79356b 842
91447636 843/* other stuff */
2d21ac55 844int nfs_removeit(struct nfs_sillyrename *);
0a7de745 845int nfs_nget(mount_t, nfsnode_t, struct componentname *, u_char *, int, struct nfs_vattr *, u_int64_t *, uint32_t, int, nfsnode_t*);
316670eb 846int nfs_mount_is_dirty(mount_t);
b0d623f7
A
847void nfs_dir_cookie_cache(nfsnode_t, uint64_t, uint64_t);
848int nfs_dir_cookie_to_lbn(nfsnode_t, uint64_t, int *, uint64_t *);
2d21ac55 849void nfs_invaldir(nfsnode_t);
b0d623f7 850uint32_t nfs_dir_buf_freespace(struct nfsbuf *, int);
1c79356b 851
55e303ae
A
852/* nfsbuf functions */
853void nfs_nbinit(void);
2d21ac55 854void nfs_buf_timer(void *, void *);
55e303ae 855void nfs_buf_remfree(struct nfsbuf *);
2d21ac55
A
856boolean_t nfs_buf_is_incore(nfsnode_t, daddr64_t);
857struct nfsbuf * nfs_buf_incore(nfsnode_t, daddr64_t);
b0d623f7 858int nfs_buf_get(nfsnode_t, daddr64_t, uint32_t, thread_t, int, struct nfsbuf **);
55e303ae
A
859int nfs_buf_upl_setup(struct nfsbuf *bp);
860void nfs_buf_upl_check(struct nfsbuf *bp);
2d21ac55
A
861void nfs_buf_normalize_valid_range(nfsnode_t, struct nfsbuf *);
862int nfs_buf_map(struct nfsbuf *);
483a1d10 863void nfs_buf_release(struct nfsbuf *, int);
55e303ae
A
864int nfs_buf_iowait(struct nfsbuf *);
865void nfs_buf_iodone(struct nfsbuf *);
2d21ac55
A
866void nfs_buf_write_delayed(struct nfsbuf *);
867void nfs_buf_check_write_verifier(nfsnode_t, struct nfsbuf *);
483a1d10 868void nfs_buf_freeup(int);
91447636
A
869void nfs_buf_refget(struct nfsbuf *bp);
870void nfs_buf_refrele(struct nfsbuf *bp);
871void nfs_buf_drop(struct nfsbuf *);
872errno_t nfs_buf_acquire(struct nfsbuf *, int, int, int);
2d21ac55
A
873int nfs_buf_iterprepare(nfsnode_t, struct nfsbuflists *, int);
874void nfs_buf_itercomplete(nfsnode_t, struct nfsbuflists *, int);
875
b0d623f7
A
876int nfs_bioread(nfsnode_t, uio_t, int, vfs_context_t);
877int nfs_buf_readahead(nfsnode_t, int, daddr64_t *, daddr64_t, thread_t, kauth_cred_t);
2d21ac55
A
878int nfs_buf_readdir(struct nfsbuf *, vfs_context_t);
879int nfs_buf_read(struct nfsbuf *);
880void nfs_buf_read_finish(struct nfsbuf *);
881int nfs_buf_read_rpc(struct nfsbuf *, thread_t, kauth_cred_t);
882void nfs_buf_read_rpc_finish(struct nfsreq *);
883int nfs_buf_write(struct nfsbuf *);
884void nfs_buf_write_finish(struct nfsbuf *, thread_t, kauth_cred_t);
885int nfs_buf_write_rpc(struct nfsbuf *, int, thread_t, kauth_cred_t);
886void nfs_buf_write_rpc_finish(struct nfsreq *);
887int nfs_buf_write_dirty_pages(struct nfsbuf *, thread_t, kauth_cred_t);
888
889int nfs_flushcommits(nfsnode_t, int);
890int nfs_flush(nfsnode_t, int, thread_t, int);
b0d623f7
A
891void nfs_buf_delwri_push(int);
892void nfs_buf_delwri_service(void);
cb323159 893void nfs_buf_delwri_thread(void *, wait_result_t);
2d21ac55
A
894
895int nfsiod_start(void);
b0d623f7
A
896void nfsiod_terminate(struct nfsiod *);
897void nfsiod_thread(void);
898int nfsiod_continue(int);
2d21ac55
A
899void nfs_asyncio_finish(struct nfsreq *);
900void nfs_asyncio_resend(struct nfsreq *);
b0d623f7
A
901int nfs_async_write_start(struct nfsmount *);
902void nfs_async_write_done(struct nfsmount *);
55e303ae 903
1c79356b
A
904#endif /* KERNEL */
905
9bccf70c
A
906#endif /* __APPLE_API_PRIVATE */
907#endif /* _NFS_NFSNODE_H_ */