nfs_clsubs.c revision 1.1.1.1.10.3 1 1.1.1.1.10.2 tls /* $NetBSD: nfs_clsubs.c,v 1.1.1.1.10.3 2017/12/03 11:38:42 jdolecek Exp $ */
2 1.1.1.1.10.2 tls /*-
3 1.1.1.1.10.2 tls * Copyright (c) 1989, 1993
4 1.1.1.1.10.2 tls * The Regents of the University of California. All rights reserved.
5 1.1.1.1.10.2 tls *
6 1.1.1.1.10.2 tls * This code is derived from software contributed to Berkeley by
7 1.1.1.1.10.2 tls * Rick Macklem at The University of Guelph.
8 1.1.1.1.10.2 tls *
9 1.1.1.1.10.2 tls * Redistribution and use in source and binary forms, with or without
10 1.1.1.1.10.2 tls * modification, are permitted provided that the following conditions
11 1.1.1.1.10.2 tls * are met:
12 1.1.1.1.10.2 tls * 1. Redistributions of source code must retain the above copyright
13 1.1.1.1.10.2 tls * notice, this list of conditions and the following disclaimer.
14 1.1.1.1.10.2 tls * 2. Redistributions in binary form must reproduce the above copyright
15 1.1.1.1.10.2 tls * notice, this list of conditions and the following disclaimer in the
16 1.1.1.1.10.2 tls * documentation and/or other materials provided with the distribution.
17 1.1.1.1.10.2 tls * 4. Neither the name of the University nor the names of its contributors
18 1.1.1.1.10.2 tls * may be used to endorse or promote products derived from this software
19 1.1.1.1.10.2 tls * without specific prior written permission.
20 1.1.1.1.10.2 tls *
21 1.1.1.1.10.2 tls * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1.1.1.10.2 tls * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1.1.1.10.2 tls * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1.1.1.10.2 tls * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1.1.1.10.2 tls * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1.1.1.10.2 tls * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1.1.1.10.2 tls * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1.1.1.10.2 tls * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1.1.1.10.2 tls * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1.1.1.10.2 tls * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1.1.1.10.2 tls * SUCH DAMAGE.
32 1.1.1.1.10.2 tls *
33 1.1.1.1.10.2 tls * from nfs_subs.c 8.8 (Berkeley) 5/22/95
34 1.1.1.1.10.2 tls */
35 1.1.1.1.10.2 tls
36 1.1.1.1.10.2 tls #include <sys/cdefs.h>
37 1.1.1.1.10.3 jdolecek /* __FBSDID("FreeBSD: head/sys/fs/nfsclient/nfs_clsubs.c 304026 2016-08-12 22:44:59Z rmacklem "); */
38 1.1.1.1.10.2 tls __RCSID("$NetBSD: nfs_clsubs.c,v 1.1.1.1.10.3 2017/12/03 11:38:42 jdolecek Exp $");
39 1.1.1.1.10.2 tls
40 1.1.1.1.10.2 tls /*
41 1.1.1.1.10.2 tls * These functions support the macros and help fiddle mbuf chains for
42 1.1.1.1.10.2 tls * the nfs op functions. They do things like create the rpc header and
43 1.1.1.1.10.2 tls * copy data between mbuf chains and uio lists.
44 1.1.1.1.10.2 tls */
45 1.1.1.1.10.2 tls
46 1.1.1.1.10.2 tls #include <sys/param.h>
47 1.1.1.1.10.2 tls #include <sys/systm.h>
48 1.1.1.1.10.2 tls #include <sys/kernel.h>
49 1.1.1.1.10.2 tls #include <sys/bio.h>
50 1.1.1.1.10.2 tls #include <sys/buf.h>
51 1.1.1.1.10.2 tls #include <sys/proc.h>
52 1.1.1.1.10.2 tls #include <sys/mount.h>
53 1.1.1.1.10.2 tls #include <sys/vnode.h>
54 1.1.1.1.10.2 tls #include <sys/namei.h>
55 1.1.1.1.10.2 tls #include <sys/mbuf.h>
56 1.1.1.1.10.2 tls #include <sys/socket.h>
57 1.1.1.1.10.2 tls #include <sys/stat.h>
58 1.1.1.1.10.2 tls #include <sys/malloc.h>
59 1.1.1.1.10.2 tls #include <sys/sysent.h>
60 1.1.1.1.10.2 tls #include <sys/syscall.h>
61 1.1.1.1.10.2 tls #include <sys/sysproto.h>
62 1.1.1.1.10.2 tls #include <sys/taskqueue.h>
63 1.1.1.1.10.2 tls
64 1.1.1.1.10.2 tls #include <vm/vm.h>
65 1.1.1.1.10.2 tls #include <vm/vm_object.h>
66 1.1.1.1.10.2 tls #include <vm/vm_extern.h>
67 1.1.1.1.10.2 tls #include <vm/uma.h>
68 1.1.1.1.10.2 tls
69 1.1.1.1.10.3 jdolecek #include <fs/nfs/common/nfsport.h>
70 1.1.1.1.10.3 jdolecek #include <fs/nfs/client/nfsnode.h>
71 1.1.1.1.10.3 jdolecek #include <fs/nfs/client/nfsmount.h>
72 1.1.1.1.10.3 jdolecek #include <fs/nfs/client/nfs.h>
73 1.1.1.1.10.3 jdolecek #include <fs/nfs/client/nfs_kdtrace.h>
74 1.1.1.1.10.2 tls
75 1.1.1.1.10.2 tls #include <netinet/in.h>
76 1.1.1.1.10.2 tls
77 1.1.1.1.10.2 tls /*
78 1.1.1.1.10.2 tls * Note that stdarg.h and the ANSI style va_start macro is used for both
79 1.1.1.1.10.2 tls * ANSI and traditional C compilers.
80 1.1.1.1.10.2 tls */
81 1.1.1.1.10.2 tls #include <machine/stdarg.h>
82 1.1.1.1.10.2 tls
83 1.1.1.1.10.2 tls extern struct mtx ncl_iod_mutex;
84 1.1.1.1.10.2 tls extern enum nfsiod_state ncl_iodwant[NFS_MAXASYNCDAEMON];
85 1.1.1.1.10.2 tls extern struct nfsmount *ncl_iodmount[NFS_MAXASYNCDAEMON];
86 1.1.1.1.10.2 tls extern int ncl_numasync;
87 1.1.1.1.10.2 tls extern unsigned int ncl_iodmax;
88 1.1.1.1.10.3 jdolecek extern struct nfsstatsv1 nfsstatsv1;
89 1.1.1.1.10.2 tls
90 1.1.1.1.10.2 tls struct task ncl_nfsiodnew_task;
91 1.1.1.1.10.2 tls
92 1.1.1.1.10.2 tls int
93 1.1.1.1.10.2 tls ncl_uninit(struct vfsconf *vfsp)
94 1.1.1.1.10.2 tls {
95 1.1.1.1.10.2 tls /*
96 1.1.1.1.10.2 tls * XXX: Unloading of nfscl module is unsupported.
97 1.1.1.1.10.2 tls */
98 1.1.1.1.10.2 tls #if 0
99 1.1.1.1.10.2 tls int i;
100 1.1.1.1.10.2 tls
101 1.1.1.1.10.2 tls /*
102 1.1.1.1.10.2 tls * Tell all nfsiod processes to exit. Clear ncl_iodmax, and wakeup
103 1.1.1.1.10.2 tls * any sleeping nfsiods so they check ncl_iodmax and exit.
104 1.1.1.1.10.2 tls */
105 1.1.1.1.10.2 tls mtx_lock(&ncl_iod_mutex);
106 1.1.1.1.10.2 tls ncl_iodmax = 0;
107 1.1.1.1.10.2 tls for (i = 0; i < ncl_numasync; i++)
108 1.1.1.1.10.2 tls if (ncl_iodwant[i] == NFSIOD_AVAILABLE)
109 1.1.1.1.10.2 tls wakeup(&ncl_iodwant[i]);
110 1.1.1.1.10.2 tls /* The last nfsiod to exit will wake us up when ncl_numasync hits 0 */
111 1.1.1.1.10.2 tls while (ncl_numasync)
112 1.1.1.1.10.2 tls msleep(&ncl_numasync, &ncl_iod_mutex, PWAIT, "ioddie", 0);
113 1.1.1.1.10.2 tls mtx_unlock(&ncl_iod_mutex);
114 1.1.1.1.10.2 tls ncl_nhuninit();
115 1.1.1.1.10.2 tls return (0);
116 1.1.1.1.10.2 tls #else
117 1.1.1.1.10.2 tls return (EOPNOTSUPP);
118 1.1.1.1.10.2 tls #endif
119 1.1.1.1.10.2 tls }
120 1.1.1.1.10.2 tls
121 1.1.1.1.10.2 tls void
122 1.1.1.1.10.2 tls ncl_dircookie_lock(struct nfsnode *np)
123 1.1.1.1.10.2 tls {
124 1.1.1.1.10.2 tls mtx_lock(&np->n_mtx);
125 1.1.1.1.10.2 tls while (np->n_flag & NDIRCOOKIELK)
126 1.1.1.1.10.2 tls (void) msleep(&np->n_flag, &np->n_mtx, PZERO, "nfsdirlk", 0);
127 1.1.1.1.10.2 tls np->n_flag |= NDIRCOOKIELK;
128 1.1.1.1.10.2 tls mtx_unlock(&np->n_mtx);
129 1.1.1.1.10.2 tls }
130 1.1.1.1.10.2 tls
131 1.1.1.1.10.2 tls void
132 1.1.1.1.10.2 tls ncl_dircookie_unlock(struct nfsnode *np)
133 1.1.1.1.10.2 tls {
134 1.1.1.1.10.2 tls mtx_lock(&np->n_mtx);
135 1.1.1.1.10.2 tls np->n_flag &= ~NDIRCOOKIELK;
136 1.1.1.1.10.2 tls wakeup(&np->n_flag);
137 1.1.1.1.10.2 tls mtx_unlock(&np->n_mtx);
138 1.1.1.1.10.2 tls }
139 1.1.1.1.10.2 tls
140 1.1.1.1.10.2 tls int
141 1.1.1.1.10.2 tls ncl_upgrade_vnlock(struct vnode *vp)
142 1.1.1.1.10.2 tls {
143 1.1.1.1.10.2 tls int old_lock;
144 1.1.1.1.10.2 tls
145 1.1.1.1.10.2 tls ASSERT_VOP_LOCKED(vp, "ncl_upgrade_vnlock");
146 1.1.1.1.10.2 tls old_lock = NFSVOPISLOCKED(vp);
147 1.1.1.1.10.2 tls if (old_lock != LK_EXCLUSIVE) {
148 1.1.1.1.10.2 tls KASSERT(old_lock == LK_SHARED,
149 1.1.1.1.10.2 tls ("ncl_upgrade_vnlock: wrong old_lock %d", old_lock));
150 1.1.1.1.10.2 tls /* Upgrade to exclusive lock, this might block */
151 1.1.1.1.10.2 tls NFSVOPLOCK(vp, LK_UPGRADE | LK_RETRY);
152 1.1.1.1.10.2 tls }
153 1.1.1.1.10.2 tls return (old_lock);
154 1.1.1.1.10.2 tls }
155 1.1.1.1.10.2 tls
156 1.1.1.1.10.2 tls void
157 1.1.1.1.10.2 tls ncl_downgrade_vnlock(struct vnode *vp, int old_lock)
158 1.1.1.1.10.2 tls {
159 1.1.1.1.10.2 tls if (old_lock != LK_EXCLUSIVE) {
160 1.1.1.1.10.2 tls KASSERT(old_lock == LK_SHARED, ("wrong old_lock %d", old_lock));
161 1.1.1.1.10.2 tls /* Downgrade from exclusive lock. */
162 1.1.1.1.10.2 tls NFSVOPLOCK(vp, LK_DOWNGRADE | LK_RETRY);
163 1.1.1.1.10.2 tls }
164 1.1.1.1.10.2 tls }
165 1.1.1.1.10.2 tls
166 1.1.1.1.10.2 tls #ifdef NFS_ACDEBUG
167 1.1.1.1.10.2 tls #include <sys/sysctl.h>
168 1.1.1.1.10.2 tls SYSCTL_DECL(_vfs_nfs);
169 1.1.1.1.10.2 tls static int nfs_acdebug;
170 1.1.1.1.10.2 tls SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, "");
171 1.1.1.1.10.2 tls #endif
172 1.1.1.1.10.2 tls
173 1.1.1.1.10.2 tls /*
174 1.1.1.1.10.2 tls * Check the time stamp
175 1.1.1.1.10.2 tls * If the cache is valid, copy contents to *vap and return 0
176 1.1.1.1.10.2 tls * otherwise return an error
177 1.1.1.1.10.2 tls */
178 1.1.1.1.10.2 tls int
179 1.1.1.1.10.2 tls ncl_getattrcache(struct vnode *vp, struct vattr *vaper)
180 1.1.1.1.10.2 tls {
181 1.1.1.1.10.2 tls struct nfsnode *np;
182 1.1.1.1.10.2 tls struct vattr *vap;
183 1.1.1.1.10.2 tls struct nfsmount *nmp;
184 1.1.1.1.10.2 tls int timeo, mustflush;
185 1.1.1.1.10.2 tls
186 1.1.1.1.10.2 tls np = VTONFS(vp);
187 1.1.1.1.10.2 tls vap = &np->n_vattr.na_vattr;
188 1.1.1.1.10.2 tls nmp = VFSTONFS(vp->v_mount);
189 1.1.1.1.10.2 tls mustflush = nfscl_mustflush(vp); /* must be before mtx_lock() */
190 1.1.1.1.10.2 tls mtx_lock(&np->n_mtx);
191 1.1.1.1.10.2 tls /* XXX n_mtime doesn't seem to be updated on a miss-and-reload */
192 1.1.1.1.10.2 tls timeo = (time_second - np->n_mtime.tv_sec) / 10;
193 1.1.1.1.10.2 tls
194 1.1.1.1.10.2 tls #ifdef NFS_ACDEBUG
195 1.1.1.1.10.2 tls if (nfs_acdebug>1)
196 1.1.1.1.10.3 jdolecek printf("ncl_getattrcache: initial timeo = %d\n", timeo);
197 1.1.1.1.10.2 tls #endif
198 1.1.1.1.10.2 tls
199 1.1.1.1.10.2 tls if (vap->va_type == VDIR) {
200 1.1.1.1.10.2 tls if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acdirmin)
201 1.1.1.1.10.2 tls timeo = nmp->nm_acdirmin;
202 1.1.1.1.10.2 tls else if (timeo > nmp->nm_acdirmax)
203 1.1.1.1.10.2 tls timeo = nmp->nm_acdirmax;
204 1.1.1.1.10.2 tls } else {
205 1.1.1.1.10.2 tls if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acregmin)
206 1.1.1.1.10.2 tls timeo = nmp->nm_acregmin;
207 1.1.1.1.10.2 tls else if (timeo > nmp->nm_acregmax)
208 1.1.1.1.10.2 tls timeo = nmp->nm_acregmax;
209 1.1.1.1.10.2 tls }
210 1.1.1.1.10.2 tls
211 1.1.1.1.10.2 tls #ifdef NFS_ACDEBUG
212 1.1.1.1.10.2 tls if (nfs_acdebug > 2)
213 1.1.1.1.10.3 jdolecek printf("acregmin %d; acregmax %d; acdirmin %d; acdirmax %d\n",
214 1.1.1.1.10.3 jdolecek nmp->nm_acregmin, nmp->nm_acregmax,
215 1.1.1.1.10.3 jdolecek nmp->nm_acdirmin, nmp->nm_acdirmax);
216 1.1.1.1.10.2 tls
217 1.1.1.1.10.2 tls if (nfs_acdebug)
218 1.1.1.1.10.3 jdolecek printf("ncl_getattrcache: age = %d; final timeo = %d\n",
219 1.1.1.1.10.3 jdolecek (time_second - np->n_attrstamp), timeo);
220 1.1.1.1.10.2 tls #endif
221 1.1.1.1.10.2 tls
222 1.1.1.1.10.2 tls if ((time_second - np->n_attrstamp) >= timeo &&
223 1.1.1.1.10.2 tls (mustflush != 0 || np->n_attrstamp == 0)) {
224 1.1.1.1.10.3 jdolecek nfsstatsv1.attrcache_misses++;
225 1.1.1.1.10.2 tls mtx_unlock(&np->n_mtx);
226 1.1.1.1.10.2 tls KDTRACE_NFS_ATTRCACHE_GET_MISS(vp);
227 1.1.1.1.10.2 tls return( ENOENT);
228 1.1.1.1.10.2 tls }
229 1.1.1.1.10.3 jdolecek nfsstatsv1.attrcache_hits++;
230 1.1.1.1.10.2 tls if (vap->va_size != np->n_size) {
231 1.1.1.1.10.2 tls if (vap->va_type == VREG) {
232 1.1.1.1.10.2 tls if (np->n_flag & NMODIFIED) {
233 1.1.1.1.10.2 tls if (vap->va_size < np->n_size)
234 1.1.1.1.10.2 tls vap->va_size = np->n_size;
235 1.1.1.1.10.2 tls else
236 1.1.1.1.10.2 tls np->n_size = vap->va_size;
237 1.1.1.1.10.2 tls } else {
238 1.1.1.1.10.2 tls np->n_size = vap->va_size;
239 1.1.1.1.10.2 tls }
240 1.1.1.1.10.2 tls vnode_pager_setsize(vp, np->n_size);
241 1.1.1.1.10.2 tls } else {
242 1.1.1.1.10.2 tls np->n_size = vap->va_size;
243 1.1.1.1.10.2 tls }
244 1.1.1.1.10.2 tls }
245 1.1.1.1.10.2 tls bcopy((caddr_t)vap, (caddr_t)vaper, sizeof(struct vattr));
246 1.1.1.1.10.2 tls if (np->n_flag & NCHG) {
247 1.1.1.1.10.2 tls if (np->n_flag & NACC)
248 1.1.1.1.10.2 tls vaper->va_atime = np->n_atim;
249 1.1.1.1.10.2 tls if (np->n_flag & NUPD)
250 1.1.1.1.10.2 tls vaper->va_mtime = np->n_mtim;
251 1.1.1.1.10.2 tls }
252 1.1.1.1.10.2 tls mtx_unlock(&np->n_mtx);
253 1.1.1.1.10.2 tls KDTRACE_NFS_ATTRCACHE_GET_HIT(vp, vap);
254 1.1.1.1.10.2 tls return (0);
255 1.1.1.1.10.2 tls }
256 1.1.1.1.10.2 tls
257 1.1.1.1.10.2 tls static nfsuint64 nfs_nullcookie = { { 0, 0 } };
258 1.1.1.1.10.2 tls /*
259 1.1.1.1.10.2 tls * This function finds the directory cookie that corresponds to the
260 1.1.1.1.10.2 tls * logical byte offset given.
261 1.1.1.1.10.2 tls */
262 1.1.1.1.10.2 tls nfsuint64 *
263 1.1.1.1.10.2 tls ncl_getcookie(struct nfsnode *np, off_t off, int add)
264 1.1.1.1.10.2 tls {
265 1.1.1.1.10.2 tls struct nfsdmap *dp, *dp2;
266 1.1.1.1.10.2 tls int pos;
267 1.1.1.1.10.2 tls nfsuint64 *retval = NULL;
268 1.1.1.1.10.2 tls
269 1.1.1.1.10.2 tls pos = (uoff_t)off / NFS_DIRBLKSIZ;
270 1.1.1.1.10.2 tls if (pos == 0 || off < 0) {
271 1.1.1.1.10.2 tls KASSERT(!add, ("nfs getcookie add at <= 0"));
272 1.1.1.1.10.2 tls return (&nfs_nullcookie);
273 1.1.1.1.10.2 tls }
274 1.1.1.1.10.2 tls pos--;
275 1.1.1.1.10.2 tls dp = LIST_FIRST(&np->n_cookies);
276 1.1.1.1.10.2 tls if (!dp) {
277 1.1.1.1.10.2 tls if (add) {
278 1.1.1.1.10.2 tls MALLOC(dp, struct nfsdmap *, sizeof (struct nfsdmap),
279 1.1.1.1.10.2 tls M_NFSDIROFF, M_WAITOK);
280 1.1.1.1.10.2 tls dp->ndm_eocookie = 0;
281 1.1.1.1.10.2 tls LIST_INSERT_HEAD(&np->n_cookies, dp, ndm_list);
282 1.1.1.1.10.2 tls } else
283 1.1.1.1.10.2 tls goto out;
284 1.1.1.1.10.2 tls }
285 1.1.1.1.10.2 tls while (pos >= NFSNUMCOOKIES) {
286 1.1.1.1.10.2 tls pos -= NFSNUMCOOKIES;
287 1.1.1.1.10.2 tls if (LIST_NEXT(dp, ndm_list)) {
288 1.1.1.1.10.2 tls if (!add && dp->ndm_eocookie < NFSNUMCOOKIES &&
289 1.1.1.1.10.2 tls pos >= dp->ndm_eocookie)
290 1.1.1.1.10.2 tls goto out;
291 1.1.1.1.10.2 tls dp = LIST_NEXT(dp, ndm_list);
292 1.1.1.1.10.2 tls } else if (add) {
293 1.1.1.1.10.2 tls MALLOC(dp2, struct nfsdmap *, sizeof (struct nfsdmap),
294 1.1.1.1.10.2 tls M_NFSDIROFF, M_WAITOK);
295 1.1.1.1.10.2 tls dp2->ndm_eocookie = 0;
296 1.1.1.1.10.2 tls LIST_INSERT_AFTER(dp, dp2, ndm_list);
297 1.1.1.1.10.2 tls dp = dp2;
298 1.1.1.1.10.2 tls } else
299 1.1.1.1.10.2 tls goto out;
300 1.1.1.1.10.2 tls }
301 1.1.1.1.10.2 tls if (pos >= dp->ndm_eocookie) {
302 1.1.1.1.10.2 tls if (add)
303 1.1.1.1.10.2 tls dp->ndm_eocookie = pos + 1;
304 1.1.1.1.10.2 tls else
305 1.1.1.1.10.2 tls goto out;
306 1.1.1.1.10.2 tls }
307 1.1.1.1.10.2 tls retval = &dp->ndm_cookies[pos];
308 1.1.1.1.10.2 tls out:
309 1.1.1.1.10.2 tls return (retval);
310 1.1.1.1.10.2 tls }
311 1.1.1.1.10.2 tls
312 1.1.1.1.10.2 tls /*
313 1.1.1.1.10.2 tls * Invalidate cached directory information, except for the actual directory
314 1.1.1.1.10.2 tls * blocks (which are invalidated separately).
315 1.1.1.1.10.2 tls * Done mainly to avoid the use of stale offset cookies.
316 1.1.1.1.10.2 tls */
317 1.1.1.1.10.2 tls void
318 1.1.1.1.10.2 tls ncl_invaldir(struct vnode *vp)
319 1.1.1.1.10.2 tls {
320 1.1.1.1.10.2 tls struct nfsnode *np = VTONFS(vp);
321 1.1.1.1.10.2 tls
322 1.1.1.1.10.2 tls KASSERT(vp->v_type == VDIR, ("nfs: invaldir not dir"));
323 1.1.1.1.10.2 tls ncl_dircookie_lock(np);
324 1.1.1.1.10.2 tls np->n_direofoffset = 0;
325 1.1.1.1.10.2 tls np->n_cookieverf.nfsuquad[0] = 0;
326 1.1.1.1.10.2 tls np->n_cookieverf.nfsuquad[1] = 0;
327 1.1.1.1.10.2 tls if (LIST_FIRST(&np->n_cookies))
328 1.1.1.1.10.2 tls LIST_FIRST(&np->n_cookies)->ndm_eocookie = 0;
329 1.1.1.1.10.2 tls ncl_dircookie_unlock(np);
330 1.1.1.1.10.2 tls }
331 1.1.1.1.10.2 tls
332 1.1.1.1.10.2 tls /*
333 1.1.1.1.10.2 tls * The write verifier has changed (probably due to a server reboot), so all
334 1.1.1.1.10.2 tls * B_NEEDCOMMIT blocks will have to be written again. Since they are on the
335 1.1.1.1.10.2 tls * dirty block list as B_DELWRI, all this takes is clearing the B_NEEDCOMMIT
336 1.1.1.1.10.2 tls * and B_CLUSTEROK flags. Once done the new write verifier can be set for the
337 1.1.1.1.10.2 tls * mount point.
338 1.1.1.1.10.2 tls *
339 1.1.1.1.10.2 tls * B_CLUSTEROK must be cleared along with B_NEEDCOMMIT because stage 1 data
340 1.1.1.1.10.2 tls * writes are not clusterable.
341 1.1.1.1.10.2 tls */
342 1.1.1.1.10.2 tls void
343 1.1.1.1.10.2 tls ncl_clearcommit(struct mount *mp)
344 1.1.1.1.10.2 tls {
345 1.1.1.1.10.2 tls struct vnode *vp, *nvp;
346 1.1.1.1.10.2 tls struct buf *bp, *nbp;
347 1.1.1.1.10.2 tls struct bufobj *bo;
348 1.1.1.1.10.2 tls
349 1.1.1.1.10.2 tls MNT_VNODE_FOREACH_ALL(vp, mp, nvp) {
350 1.1.1.1.10.2 tls bo = &vp->v_bufobj;
351 1.1.1.1.10.2 tls vholdl(vp);
352 1.1.1.1.10.2 tls VI_UNLOCK(vp);
353 1.1.1.1.10.2 tls BO_LOCK(bo);
354 1.1.1.1.10.2 tls TAILQ_FOREACH_SAFE(bp, &bo->bo_dirty.bv_hd, b_bobufs, nbp) {
355 1.1.1.1.10.2 tls if (!BUF_ISLOCKED(bp) &&
356 1.1.1.1.10.2 tls (bp->b_flags & (B_DELWRI | B_NEEDCOMMIT))
357 1.1.1.1.10.2 tls == (B_DELWRI | B_NEEDCOMMIT))
358 1.1.1.1.10.2 tls bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK);
359 1.1.1.1.10.2 tls }
360 1.1.1.1.10.2 tls BO_UNLOCK(bo);
361 1.1.1.1.10.2 tls vdrop(vp);
362 1.1.1.1.10.2 tls }
363 1.1.1.1.10.2 tls }
364 1.1.1.1.10.2 tls
365 1.1.1.1.10.2 tls /*
366 1.1.1.1.10.2 tls * Called once to initialize data structures...
367 1.1.1.1.10.2 tls */
368 1.1.1.1.10.2 tls int
369 1.1.1.1.10.2 tls ncl_init(struct vfsconf *vfsp)
370 1.1.1.1.10.2 tls {
371 1.1.1.1.10.2 tls int i;
372 1.1.1.1.10.2 tls
373 1.1.1.1.10.2 tls /* Ensure async daemons disabled */
374 1.1.1.1.10.2 tls for (i = 0; i < NFS_MAXASYNCDAEMON; i++) {
375 1.1.1.1.10.2 tls ncl_iodwant[i] = NFSIOD_NOT_AVAILABLE;
376 1.1.1.1.10.2 tls ncl_iodmount[i] = NULL;
377 1.1.1.1.10.2 tls }
378 1.1.1.1.10.2 tls TASK_INIT(&ncl_nfsiodnew_task, 0, ncl_nfsiodnew_tq, NULL);
379 1.1.1.1.10.2 tls ncl_nhinit(); /* Init the nfsnode table */
380 1.1.1.1.10.2 tls
381 1.1.1.1.10.2 tls return (0);
382 1.1.1.1.10.2 tls }
383 1.1.1.1.10.2 tls
384