nfs_clnode.c revision 1.1.1.1.10.3 1 1.1.1.1.10.2 tls /* $NetBSD: nfs_clnode.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_node.c 8.6 (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_clnode.c 302210 2016-06-26 14:18:28Z kib "); */
38 1.1.1.1.10.2 tls __RCSID("$NetBSD: nfs_clnode.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 #include <sys/param.h>
41 1.1.1.1.10.2 tls #include <sys/systm.h>
42 1.1.1.1.10.2 tls #include <sys/fcntl.h>
43 1.1.1.1.10.2 tls #include <sys/lock.h>
44 1.1.1.1.10.2 tls #include <sys/malloc.h>
45 1.1.1.1.10.2 tls #include <sys/mount.h>
46 1.1.1.1.10.2 tls #include <sys/namei.h>
47 1.1.1.1.10.2 tls #include <sys/proc.h>
48 1.1.1.1.10.2 tls #include <sys/socket.h>
49 1.1.1.1.10.2 tls #include <sys/sysctl.h>
50 1.1.1.1.10.2 tls #include <sys/taskqueue.h>
51 1.1.1.1.10.2 tls #include <sys/vnode.h>
52 1.1.1.1.10.2 tls
53 1.1.1.1.10.2 tls #include <vm/uma.h>
54 1.1.1.1.10.2 tls
55 1.1.1.1.10.3 jdolecek #include <fs/nfs/common/nfsport.h>
56 1.1.1.1.10.3 jdolecek #include <fs/nfs/client/nfsnode.h>
57 1.1.1.1.10.3 jdolecek #include <fs/nfs/client/nfsmount.h>
58 1.1.1.1.10.3 jdolecek #include <fs/nfs/client/nfs.h>
59 1.1.1.1.10.3 jdolecek #include <fs/nfs/client/nfs_kdtrace.h>
60 1.1.1.1.10.2 tls
61 1.1.1.1.10.3 jdolecek #include <fs/nfs/common/nfs_lock.h>
62 1.1.1.1.10.2 tls
63 1.1.1.1.10.2 tls extern struct vop_vector newnfs_vnodeops;
64 1.1.1.1.10.2 tls extern struct buf_ops buf_ops_newnfs;
65 1.1.1.1.10.2 tls MALLOC_DECLARE(M_NEWNFSREQ);
66 1.1.1.1.10.2 tls
67 1.1.1.1.10.2 tls uma_zone_t newnfsnode_zone;
68 1.1.1.1.10.2 tls
69 1.1.1.1.10.3 jdolecek const char nfs_vnode_tag[] = "nfs";
70 1.1.1.1.10.3 jdolecek
71 1.1.1.1.10.3 jdolecek static void nfs_freesillyrename(void *arg);
72 1.1.1.1.10.2 tls
73 1.1.1.1.10.2 tls void
74 1.1.1.1.10.2 tls ncl_nhinit(void)
75 1.1.1.1.10.2 tls {
76 1.1.1.1.10.2 tls
77 1.1.1.1.10.2 tls newnfsnode_zone = uma_zcreate("NCLNODE", sizeof(struct nfsnode), NULL,
78 1.1.1.1.10.2 tls NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
79 1.1.1.1.10.2 tls }
80 1.1.1.1.10.2 tls
81 1.1.1.1.10.2 tls void
82 1.1.1.1.10.2 tls ncl_nhuninit(void)
83 1.1.1.1.10.2 tls {
84 1.1.1.1.10.2 tls uma_zdestroy(newnfsnode_zone);
85 1.1.1.1.10.2 tls }
86 1.1.1.1.10.2 tls
87 1.1.1.1.10.2 tls /*
88 1.1.1.1.10.2 tls * ONLY USED FOR THE ROOT DIRECTORY. nfscl_nget() does the rest. If this
89 1.1.1.1.10.2 tls * function is going to be used to get Regular Files, code must be added
90 1.1.1.1.10.2 tls * to fill in the "struct nfsv4node".
91 1.1.1.1.10.2 tls * Look up a vnode/nfsnode by file handle.
92 1.1.1.1.10.2 tls * Callers must check for mount points!!
93 1.1.1.1.10.2 tls * In all cases, a pointer to a
94 1.1.1.1.10.2 tls * nfsnode structure is returned.
95 1.1.1.1.10.2 tls */
96 1.1.1.1.10.2 tls int
97 1.1.1.1.10.2 tls ncl_nget(struct mount *mntp, u_int8_t *fhp, int fhsize, struct nfsnode **npp,
98 1.1.1.1.10.2 tls int lkflags)
99 1.1.1.1.10.2 tls {
100 1.1.1.1.10.2 tls struct thread *td = curthread; /* XXX */
101 1.1.1.1.10.2 tls struct nfsnode *np;
102 1.1.1.1.10.2 tls struct vnode *vp;
103 1.1.1.1.10.2 tls struct vnode *nvp;
104 1.1.1.1.10.2 tls int error;
105 1.1.1.1.10.2 tls u_int hash;
106 1.1.1.1.10.2 tls struct nfsmount *nmp;
107 1.1.1.1.10.2 tls struct nfsfh *nfhp;
108 1.1.1.1.10.2 tls
109 1.1.1.1.10.2 tls nmp = VFSTONFS(mntp);
110 1.1.1.1.10.2 tls *npp = NULL;
111 1.1.1.1.10.2 tls
112 1.1.1.1.10.2 tls hash = fnv_32_buf(fhp, fhsize, FNV1_32_INIT);
113 1.1.1.1.10.2 tls
114 1.1.1.1.10.2 tls MALLOC(nfhp, struct nfsfh *, sizeof (struct nfsfh) + fhsize,
115 1.1.1.1.10.2 tls M_NFSFH, M_WAITOK);
116 1.1.1.1.10.2 tls bcopy(fhp, &nfhp->nfh_fh[0], fhsize);
117 1.1.1.1.10.2 tls nfhp->nfh_len = fhsize;
118 1.1.1.1.10.2 tls error = vfs_hash_get(mntp, hash, lkflags,
119 1.1.1.1.10.2 tls td, &nvp, newnfs_vncmpf, nfhp);
120 1.1.1.1.10.2 tls FREE(nfhp, M_NFSFH);
121 1.1.1.1.10.2 tls if (error)
122 1.1.1.1.10.2 tls return (error);
123 1.1.1.1.10.2 tls if (nvp != NULL) {
124 1.1.1.1.10.2 tls *npp = VTONFS(nvp);
125 1.1.1.1.10.2 tls return (0);
126 1.1.1.1.10.2 tls }
127 1.1.1.1.10.2 tls np = uma_zalloc(newnfsnode_zone, M_WAITOK | M_ZERO);
128 1.1.1.1.10.2 tls
129 1.1.1.1.10.3 jdolecek error = getnewvnode(nfs_vnode_tag, mntp, &newnfs_vnodeops, &nvp);
130 1.1.1.1.10.2 tls if (error) {
131 1.1.1.1.10.2 tls uma_zfree(newnfsnode_zone, np);
132 1.1.1.1.10.2 tls return (error);
133 1.1.1.1.10.2 tls }
134 1.1.1.1.10.2 tls vp = nvp;
135 1.1.1.1.10.2 tls KASSERT(vp->v_bufobj.bo_bsize != 0, ("ncl_nget: bo_bsize == 0"));
136 1.1.1.1.10.2 tls vp->v_bufobj.bo_ops = &buf_ops_newnfs;
137 1.1.1.1.10.2 tls vp->v_data = np;
138 1.1.1.1.10.2 tls np->n_vnode = vp;
139 1.1.1.1.10.2 tls /*
140 1.1.1.1.10.2 tls * Initialize the mutex even if the vnode is going to be a loser.
141 1.1.1.1.10.2 tls * This simplifies the logic in reclaim, which can then unconditionally
142 1.1.1.1.10.2 tls * destroy the mutex (in the case of the loser, or if hash_insert
143 1.1.1.1.10.2 tls * happened to return an error no special casing is needed).
144 1.1.1.1.10.2 tls */
145 1.1.1.1.10.2 tls mtx_init(&np->n_mtx, "NEWNFSnode lock", NULL, MTX_DEF | MTX_DUPOK);
146 1.1.1.1.10.2 tls /*
147 1.1.1.1.10.2 tls * NFS supports recursive and shared locking.
148 1.1.1.1.10.2 tls */
149 1.1.1.1.10.2 tls lockmgr(vp->v_vnlock, LK_EXCLUSIVE | LK_NOWITNESS, NULL);
150 1.1.1.1.10.2 tls VN_LOCK_AREC(vp);
151 1.1.1.1.10.2 tls VN_LOCK_ASHARE(vp);
152 1.1.1.1.10.2 tls /*
153 1.1.1.1.10.2 tls * Are we getting the root? If so, make sure the vnode flags
154 1.1.1.1.10.2 tls * are correct
155 1.1.1.1.10.2 tls */
156 1.1.1.1.10.2 tls if ((fhsize == nmp->nm_fhsize) &&
157 1.1.1.1.10.2 tls !bcmp(fhp, nmp->nm_fh, fhsize)) {
158 1.1.1.1.10.2 tls if (vp->v_type == VNON)
159 1.1.1.1.10.2 tls vp->v_type = VDIR;
160 1.1.1.1.10.2 tls vp->v_vflag |= VV_ROOT;
161 1.1.1.1.10.2 tls }
162 1.1.1.1.10.2 tls
163 1.1.1.1.10.2 tls MALLOC(np->n_fhp, struct nfsfh *, sizeof (struct nfsfh) + fhsize,
164 1.1.1.1.10.2 tls M_NFSFH, M_WAITOK);
165 1.1.1.1.10.2 tls bcopy(fhp, np->n_fhp->nfh_fh, fhsize);
166 1.1.1.1.10.2 tls np->n_fhp->nfh_len = fhsize;
167 1.1.1.1.10.2 tls error = insmntque(vp, mntp);
168 1.1.1.1.10.2 tls if (error != 0) {
169 1.1.1.1.10.2 tls *npp = NULL;
170 1.1.1.1.10.2 tls FREE((caddr_t)np->n_fhp, M_NFSFH);
171 1.1.1.1.10.2 tls mtx_destroy(&np->n_mtx);
172 1.1.1.1.10.2 tls uma_zfree(newnfsnode_zone, np);
173 1.1.1.1.10.2 tls return (error);
174 1.1.1.1.10.2 tls }
175 1.1.1.1.10.2 tls error = vfs_hash_insert(vp, hash, lkflags,
176 1.1.1.1.10.2 tls td, &nvp, newnfs_vncmpf, np->n_fhp);
177 1.1.1.1.10.2 tls if (error)
178 1.1.1.1.10.2 tls return (error);
179 1.1.1.1.10.2 tls if (nvp != NULL) {
180 1.1.1.1.10.2 tls *npp = VTONFS(nvp);
181 1.1.1.1.10.2 tls /* vfs_hash_insert() vput()'s the losing vnode */
182 1.1.1.1.10.2 tls return (0);
183 1.1.1.1.10.2 tls }
184 1.1.1.1.10.2 tls *npp = np;
185 1.1.1.1.10.2 tls
186 1.1.1.1.10.2 tls return (0);
187 1.1.1.1.10.2 tls }
188 1.1.1.1.10.2 tls
189 1.1.1.1.10.2 tls /*
190 1.1.1.1.10.2 tls * Do the vrele(sp->s_dvp) as a separate task in order to avoid a
191 1.1.1.1.10.2 tls * deadlock because of a LOR when vrele() locks the directory vnode.
192 1.1.1.1.10.2 tls */
193 1.1.1.1.10.2 tls static void
194 1.1.1.1.10.3 jdolecek nfs_freesillyrename(void *arg)
195 1.1.1.1.10.2 tls {
196 1.1.1.1.10.2 tls struct sillyrename *sp;
197 1.1.1.1.10.2 tls
198 1.1.1.1.10.2 tls sp = arg;
199 1.1.1.1.10.2 tls vrele(sp->s_dvp);
200 1.1.1.1.10.2 tls free(sp, M_NEWNFSREQ);
201 1.1.1.1.10.2 tls }
202 1.1.1.1.10.2 tls
203 1.1.1.1.10.3 jdolecek static void
204 1.1.1.1.10.3 jdolecek ncl_releasesillyrename(struct vnode *vp, struct thread *td)
205 1.1.1.1.10.2 tls {
206 1.1.1.1.10.2 tls struct nfsnode *np;
207 1.1.1.1.10.2 tls struct sillyrename *sp;
208 1.1.1.1.10.2 tls
209 1.1.1.1.10.3 jdolecek ASSERT_VOP_ELOCKED(vp, "releasesillyrename");
210 1.1.1.1.10.2 tls np = VTONFS(vp);
211 1.1.1.1.10.3 jdolecek mtx_assert(&np->n_mtx, MA_OWNED);
212 1.1.1.1.10.3 jdolecek if (vp->v_type != VDIR) {
213 1.1.1.1.10.3 jdolecek sp = np->n_sillyrename;
214 1.1.1.1.10.3 jdolecek np->n_sillyrename = NULL;
215 1.1.1.1.10.3 jdolecek } else
216 1.1.1.1.10.3 jdolecek sp = NULL;
217 1.1.1.1.10.3 jdolecek if (sp != NULL) {
218 1.1.1.1.10.3 jdolecek mtx_unlock(&np->n_mtx);
219 1.1.1.1.10.3 jdolecek (void) ncl_vinvalbuf(vp, 0, td, 1);
220 1.1.1.1.10.3 jdolecek /*
221 1.1.1.1.10.3 jdolecek * Remove the silly file that was rename'd earlier
222 1.1.1.1.10.3 jdolecek */
223 1.1.1.1.10.3 jdolecek ncl_removeit(sp, vp);
224 1.1.1.1.10.3 jdolecek crfree(sp->s_cred);
225 1.1.1.1.10.3 jdolecek sysmon_task_queue_sched(0, nfs_freesillyrename, sp);
226 1.1.1.1.10.3 jdolecek mtx_lock(&np->n_mtx);
227 1.1.1.1.10.3 jdolecek }
228 1.1.1.1.10.3 jdolecek }
229 1.1.1.1.10.3 jdolecek
230 1.1.1.1.10.3 jdolecek int
231 1.1.1.1.10.3 jdolecek ncl_inactive(struct vop_inactive_args *ap)
232 1.1.1.1.10.3 jdolecek {
233 1.1.1.1.10.3 jdolecek struct vnode *vp = ap->a_vp;
234 1.1.1.1.10.3 jdolecek struct nfsnode *np;
235 1.1.1.1.10.3 jdolecek boolean_t retv;
236 1.1.1.1.10.2 tls
237 1.1.1.1.10.2 tls if (NFS_ISV4(vp) && vp->v_type == VREG) {
238 1.1.1.1.10.2 tls /*
239 1.1.1.1.10.2 tls * Since mmap()'d files do I/O after VOP_CLOSE(), the NFSv4
240 1.1.1.1.10.2 tls * Close operations are delayed until now. Any dirty
241 1.1.1.1.10.2 tls * buffers/pages must be flushed before the close, so that the
242 1.1.1.1.10.2 tls * stateid is available for the writes.
243 1.1.1.1.10.2 tls */
244 1.1.1.1.10.2 tls if (vp->v_object != NULL) {
245 1.1.1.1.10.2 tls VM_OBJECT_WLOCK(vp->v_object);
246 1.1.1.1.10.2 tls retv = vm_object_page_clean(vp->v_object, 0, 0,
247 1.1.1.1.10.2 tls OBJPC_SYNC);
248 1.1.1.1.10.2 tls VM_OBJECT_WUNLOCK(vp->v_object);
249 1.1.1.1.10.2 tls } else
250 1.1.1.1.10.2 tls retv = TRUE;
251 1.1.1.1.10.2 tls if (retv == TRUE) {
252 1.1.1.1.10.2 tls (void)ncl_flush(vp, MNT_WAIT, NULL, ap->a_td, 1, 0);
253 1.1.1.1.10.2 tls (void)nfsrpc_close(vp, 1, ap->a_td);
254 1.1.1.1.10.2 tls }
255 1.1.1.1.10.2 tls }
256 1.1.1.1.10.2 tls
257 1.1.1.1.10.3 jdolecek np = VTONFS(vp);
258 1.1.1.1.10.2 tls mtx_lock(&np->n_mtx);
259 1.1.1.1.10.3 jdolecek ncl_releasesillyrename(vp, ap->a_td);
260 1.1.1.1.10.3 jdolecek
261 1.1.1.1.10.3 jdolecek /*
262 1.1.1.1.10.3 jdolecek * NMODIFIED means that there might be dirty/stale buffers
263 1.1.1.1.10.3 jdolecek * associated with the NFS vnode. None of the other flags are
264 1.1.1.1.10.3 jdolecek * meaningful after the vnode is unused.
265 1.1.1.1.10.3 jdolecek */
266 1.1.1.1.10.2 tls np->n_flag &= NMODIFIED;
267 1.1.1.1.10.2 tls mtx_unlock(&np->n_mtx);
268 1.1.1.1.10.2 tls return (0);
269 1.1.1.1.10.2 tls }
270 1.1.1.1.10.2 tls
271 1.1.1.1.10.2 tls /*
272 1.1.1.1.10.2 tls * Reclaim an nfsnode so that it can be used for other purposes.
273 1.1.1.1.10.2 tls */
274 1.1.1.1.10.2 tls int
275 1.1.1.1.10.2 tls ncl_reclaim(struct vop_reclaim_args *ap)
276 1.1.1.1.10.2 tls {
277 1.1.1.1.10.2 tls struct vnode *vp = ap->a_vp;
278 1.1.1.1.10.2 tls struct nfsnode *np = VTONFS(vp);
279 1.1.1.1.10.2 tls struct nfsdmap *dp, *dp2;
280 1.1.1.1.10.2 tls
281 1.1.1.1.10.2 tls /*
282 1.1.1.1.10.2 tls * If the NLM is running, give it a chance to abort pending
283 1.1.1.1.10.2 tls * locks.
284 1.1.1.1.10.2 tls */
285 1.1.1.1.10.2 tls if (nfs_reclaim_p != NULL)
286 1.1.1.1.10.2 tls nfs_reclaim_p(ap);
287 1.1.1.1.10.2 tls
288 1.1.1.1.10.3 jdolecek mtx_lock(&np->n_mtx);
289 1.1.1.1.10.3 jdolecek ncl_releasesillyrename(vp, ap->a_td);
290 1.1.1.1.10.3 jdolecek mtx_unlock(&np->n_mtx);
291 1.1.1.1.10.3 jdolecek
292 1.1.1.1.10.2 tls /*
293 1.1.1.1.10.2 tls * Destroy the vm object and flush associated pages.
294 1.1.1.1.10.2 tls */
295 1.1.1.1.10.2 tls vnode_destroy_vobject(vp);
296 1.1.1.1.10.2 tls
297 1.1.1.1.10.2 tls if (NFS_ISV4(vp) && vp->v_type == VREG)
298 1.1.1.1.10.2 tls /*
299 1.1.1.1.10.2 tls * We can now safely close any remaining NFSv4 Opens for
300 1.1.1.1.10.2 tls * this file. Most opens will have already been closed by
301 1.1.1.1.10.2 tls * ncl_inactive(), but there are cases where it is not
302 1.1.1.1.10.2 tls * called, so we need to do it again here.
303 1.1.1.1.10.2 tls */
304 1.1.1.1.10.2 tls (void) nfsrpc_close(vp, 1, ap->a_td);
305 1.1.1.1.10.2 tls
306 1.1.1.1.10.2 tls vfs_hash_remove(vp);
307 1.1.1.1.10.2 tls
308 1.1.1.1.10.2 tls /*
309 1.1.1.1.10.2 tls * Call nfscl_reclaimnode() to save attributes in the delegation,
310 1.1.1.1.10.2 tls * as required.
311 1.1.1.1.10.2 tls */
312 1.1.1.1.10.2 tls if (vp->v_type == VREG)
313 1.1.1.1.10.2 tls nfscl_reclaimnode(vp);
314 1.1.1.1.10.2 tls
315 1.1.1.1.10.2 tls /*
316 1.1.1.1.10.2 tls * Free up any directory cookie structures and
317 1.1.1.1.10.2 tls * large file handle structures that might be associated with
318 1.1.1.1.10.2 tls * this nfs node.
319 1.1.1.1.10.2 tls */
320 1.1.1.1.10.2 tls if (vp->v_type == VDIR) {
321 1.1.1.1.10.2 tls dp = LIST_FIRST(&np->n_cookies);
322 1.1.1.1.10.2 tls while (dp) {
323 1.1.1.1.10.2 tls dp2 = dp;
324 1.1.1.1.10.2 tls dp = LIST_NEXT(dp, ndm_list);
325 1.1.1.1.10.2 tls FREE((caddr_t)dp2, M_NFSDIROFF);
326 1.1.1.1.10.2 tls }
327 1.1.1.1.10.2 tls }
328 1.1.1.1.10.2 tls if (np->n_writecred != NULL)
329 1.1.1.1.10.2 tls crfree(np->n_writecred);
330 1.1.1.1.10.2 tls FREE((caddr_t)np->n_fhp, M_NFSFH);
331 1.1.1.1.10.2 tls if (np->n_v4 != NULL)
332 1.1.1.1.10.2 tls FREE((caddr_t)np->n_v4, M_NFSV4NODE);
333 1.1.1.1.10.2 tls mtx_destroy(&np->n_mtx);
334 1.1.1.1.10.2 tls uma_zfree(newnfsnode_zone, vp->v_data);
335 1.1.1.1.10.2 tls vp->v_data = NULL;
336 1.1.1.1.10.2 tls return (0);
337 1.1.1.1.10.2 tls }
338 1.1.1.1.10.2 tls
339 1.1.1.1.10.2 tls /*
340 1.1.1.1.10.2 tls * Invalidate both the access and attribute caches for this vnode.
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_invalcaches(struct vnode *vp)
344 1.1.1.1.10.2 tls {
345 1.1.1.1.10.2 tls struct nfsnode *np = VTONFS(vp);
346 1.1.1.1.10.2 tls int i;
347 1.1.1.1.10.2 tls
348 1.1.1.1.10.2 tls mtx_lock(&np->n_mtx);
349 1.1.1.1.10.2 tls for (i = 0; i < NFS_ACCESSCACHESIZE; i++)
350 1.1.1.1.10.2 tls np->n_accesscache[i].stamp = 0;
351 1.1.1.1.10.2 tls KDTRACE_NFS_ACCESSCACHE_FLUSH_DONE(vp);
352 1.1.1.1.10.2 tls np->n_attrstamp = 0;
353 1.1.1.1.10.2 tls KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
354 1.1.1.1.10.2 tls mtx_unlock(&np->n_mtx);
355 1.1.1.1.10.2 tls }
356