Commit | Line | Data |
---|---|---|
3c4390e8 KM |
1 | /* |
2 | * Copyright (c) 1989 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
6 | * provided that the above copyright notice and this paragraph are | |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
16 | * | |
f0556f86 | 17 | * @(#)vfs_subr.c 7.13 (Berkeley) %G% |
3c4390e8 KM |
18 | */ |
19 | ||
20 | /* | |
21 | * External virtual filesystem routines | |
22 | */ | |
23 | ||
24 | #include "param.h" | |
25 | #include "mount.h" | |
26 | #include "time.h" | |
27 | #include "vnode.h" | |
c60798ca KM |
28 | #include "namei.h" |
29 | #include "ucred.h" | |
3c4390e8 | 30 | #include "errno.h" |
ef24f6dd | 31 | #include "malloc.h" |
3c4390e8 | 32 | |
3c4390e8 KM |
33 | /* |
34 | * Remove a mount point from the list of mounted filesystems. | |
35 | * Unmount of the root is illegal. | |
36 | */ | |
37 | void | |
38 | vfs_remove(mp) | |
39 | register struct mount *mp; | |
40 | { | |
41 | ||
42 | if (mp == rootfs) | |
43 | panic("vfs_remove: unmounting root"); | |
44 | mp->m_prev->m_next = mp->m_next; | |
45 | mp->m_next->m_prev = mp->m_prev; | |
46 | mp->m_vnodecovered->v_mountedhere = (struct mount *)0; | |
47 | vfs_unlock(mp); | |
48 | } | |
49 | ||
50 | /* | |
51 | * Lock a filesystem. | |
52 | * Used to prevent access to it while mounting and unmounting. | |
53 | */ | |
54 | vfs_lock(mp) | |
55 | register struct mount *mp; | |
56 | { | |
57 | ||
594501df KM |
58 | while(mp->m_flag & M_MLOCK) { |
59 | mp->m_flag |= M_MWAIT; | |
60 | sleep((caddr_t)mp, PVFS); | |
61 | } | |
3c4390e8 KM |
62 | mp->m_flag |= M_MLOCK; |
63 | return (0); | |
64 | } | |
65 | ||
66 | /* | |
67 | * Unlock a locked filesystem. | |
68 | * Panic if filesystem is not locked. | |
69 | */ | |
70 | void | |
71 | vfs_unlock(mp) | |
72 | register struct mount *mp; | |
73 | { | |
74 | ||
75 | if ((mp->m_flag & M_MLOCK) == 0) | |
76 | panic("vfs_unlock: locked fs"); | |
77 | mp->m_flag &= ~M_MLOCK; | |
78 | if (mp->m_flag & M_MWAIT) { | |
79 | mp->m_flag &= ~M_MWAIT; | |
80 | wakeup((caddr_t)mp); | |
81 | } | |
82 | } | |
83 | ||
84 | /* | |
85 | * Lookup a mount point by filesystem identifier. | |
86 | */ | |
87 | struct mount * | |
88 | getvfs(fsid) | |
89 | fsid_t *fsid; | |
90 | { | |
91 | register struct mount *mp; | |
92 | ||
d713f801 KM |
93 | mp = rootfs; |
94 | do { | |
3c4390e8 KM |
95 | if (mp->m_fsid.val[0] == fsid->val[0] && |
96 | mp->m_fsid.val[1] == fsid->val[1]) { | |
d713f801 | 97 | return (mp); |
3c4390e8 | 98 | } |
d713f801 KM |
99 | mp = mp->m_next; |
100 | } while (mp != rootfs); | |
101 | return ((struct mount *)0); | |
3c4390e8 KM |
102 | } |
103 | ||
104 | /* | |
105 | * Set vnode attributes to VNOVAL | |
106 | */ | |
107 | void vattr_null(vap) | |
108 | register struct vattr *vap; | |
109 | { | |
110 | ||
111 | vap->va_type = VNON; | |
112 | vap->va_mode = vap->va_nlink = vap->va_uid = vap->va_gid = | |
113 | vap->va_fsid = vap->va_fileid = vap->va_size = | |
114 | vap->va_size1 = vap->va_blocksize = vap->va_rdev = | |
115 | vap->va_bytes = vap->va_bytes1 = | |
116 | vap->va_atime.tv_sec = vap->va_atime.tv_usec = | |
117 | vap->va_mtime.tv_sec = vap->va_mtime.tv_usec = | |
8cf4d4fb KM |
118 | vap->va_ctime.tv_sec = vap->va_ctime.tv_usec = |
119 | vap->va_flags = vap->va_gen = VNOVAL; | |
3c4390e8 | 120 | } |
c60798ca KM |
121 | |
122 | /* | |
123 | * Initialize a nameidata structure | |
124 | */ | |
125 | ndinit(ndp) | |
126 | register struct nameidata *ndp; | |
127 | { | |
128 | ||
129 | bzero((caddr_t)ndp, sizeof(struct nameidata)); | |
130 | ndp->ni_iov = &ndp->ni_nd.nd_iovec; | |
131 | ndp->ni_iovcnt = 1; | |
132 | ndp->ni_base = (caddr_t)&ndp->ni_dent; | |
133 | ndp->ni_rw = UIO_WRITE; | |
134 | ndp->ni_segflg = UIO_SYSSPACE; | |
135 | } | |
136 | ||
137 | /* | |
138 | * Duplicate a nameidata structure | |
139 | */ | |
140 | nddup(ndp, newndp) | |
141 | register struct nameidata *ndp, *newndp; | |
142 | { | |
143 | ||
144 | ndinit(newndp); | |
145 | newndp->ni_cdir = ndp->ni_cdir; | |
8fe1c702 | 146 | VREF(newndp->ni_cdir); |
c60798ca KM |
147 | newndp->ni_rdir = ndp->ni_rdir; |
148 | if (newndp->ni_rdir) | |
8fe1c702 | 149 | VREF(newndp->ni_rdir); |
c60798ca KM |
150 | newndp->ni_cred = ndp->ni_cred; |
151 | crhold(newndp->ni_cred); | |
152 | } | |
153 | ||
154 | /* | |
155 | * Release a nameidata structure | |
156 | */ | |
157 | ndrele(ndp) | |
158 | register struct nameidata *ndp; | |
159 | { | |
160 | ||
161 | vrele(ndp->ni_cdir); | |
162 | if (ndp->ni_rdir) | |
163 | vrele(ndp->ni_rdir); | |
164 | crfree(ndp->ni_cred); | |
165 | } | |
36d09cb1 KM |
166 | |
167 | /* | |
168 | * Routines having to do with the management of the vnode table. | |
169 | */ | |
170 | struct vnode *vfreeh, **vfreet; | |
4ef5d036 | 171 | extern struct vnodeops dead_vnodeops, spec_vnodeops; |
ef24f6dd KM |
172 | struct speclist *speclisth; |
173 | struct speclist { | |
174 | struct speclist *sl_next; | |
175 | struct vnode *sl_vp; | |
176 | }; | |
36d09cb1 KM |
177 | |
178 | /* | |
ef24f6dd | 179 | * Initialize the vnode structures and initialize each file system type. |
36d09cb1 | 180 | */ |
ef24f6dd | 181 | vfsinit() |
36d09cb1 KM |
182 | { |
183 | register struct vnode *vp = vnode; | |
ef24f6dd | 184 | struct vfsops **vfsp; |
36d09cb1 | 185 | |
ef24f6dd KM |
186 | /* |
187 | * Build vnode free list. | |
188 | */ | |
36d09cb1 KM |
189 | vfreeh = vp; |
190 | vfreet = &vp->v_freef; | |
191 | vp->v_freeb = &vfreeh; | |
192 | vp->v_op = &dead_vnodeops; | |
193 | for (vp++; vp < vnodeNVNODE; vp++) { | |
194 | *vfreet = vp; | |
195 | vp->v_freeb = vfreet; | |
196 | vfreet = &vp->v_freef; | |
197 | vp->v_op = &dead_vnodeops; | |
198 | } | |
199 | vp--; | |
200 | vp->v_freef = NULL; | |
ef24f6dd KM |
201 | /* |
202 | * Initialize the vnode name cache | |
203 | */ | |
204 | nchinit(); | |
205 | /* | |
206 | * Initialize each file system type. | |
207 | */ | |
208 | for (vfsp = &vfssw[0]; vfsp <= &vfssw[MOUNT_MAXTYPE]; vfsp++) { | |
209 | if (*vfsp == NULL) | |
210 | continue; | |
211 | (*(*vfsp)->vfs_init)(); | |
212 | } | |
36d09cb1 KM |
213 | } |
214 | ||
215 | /* | |
216 | * Return the next vnode from the free list. | |
217 | */ | |
218 | getnewvnode(tag, mp, vops, vpp) | |
219 | enum vtagtype tag; | |
220 | struct mount *mp; | |
221 | struct vnodeops *vops; | |
222 | struct vnode **vpp; | |
223 | { | |
224 | register struct vnode *vp, *vq; | |
225 | ||
226 | if ((vp = vfreeh) == NULL) { | |
227 | tablefull("vnode"); | |
228 | *vpp = 0; | |
229 | return (ENFILE); | |
230 | } | |
ef24f6dd | 231 | if (vp->v_count) |
36d09cb1 KM |
232 | panic("free vnode isn't"); |
233 | if (vq = vp->v_freef) | |
234 | vq->v_freeb = &vfreeh; | |
235 | vfreeh = vq; | |
236 | vp->v_freef = NULL; | |
237 | vp->v_freeb = NULL; | |
ef24f6dd KM |
238 | if (vp->v_type != VNON) |
239 | vgone(vp); | |
36d09cb1 KM |
240 | vp->v_flag = 0; |
241 | vp->v_shlockc = 0; | |
242 | vp->v_exlockc = 0; | |
243 | vp->v_socket = 0; | |
36d09cb1 KM |
244 | cache_purge(vp); |
245 | vp->v_tag = tag; | |
ef24f6dd | 246 | vp->v_op = vops; |
36d09cb1 KM |
247 | vp->v_mount = mp; |
248 | insmntque(vp, mp); | |
249 | VREF(vp); | |
250 | *vpp = vp; | |
251 | return (0); | |
252 | } | |
253 | ||
254 | /* | |
255 | * Move a vnode from one mount queue to another. | |
256 | */ | |
257 | insmntque(vp, mp) | |
258 | register struct vnode *vp; | |
259 | register struct mount *mp; | |
260 | { | |
261 | struct vnode *vq; | |
262 | ||
263 | /* | |
264 | * Delete from old mount point vnode list, if on one. | |
265 | */ | |
266 | if (vp->v_mountb) { | |
267 | if (vq = vp->v_mountf) | |
268 | vq->v_mountb = vp->v_mountb; | |
269 | *vp->v_mountb = vq; | |
270 | } | |
271 | /* | |
272 | * Insert into list of vnodes for the new mount point, if available. | |
273 | */ | |
274 | if (mp == NULL) { | |
275 | vp->v_mountf = NULL; | |
276 | vp->v_mountb = NULL; | |
277 | return; | |
278 | } | |
279 | if (mp->m_mounth) { | |
280 | vp->v_mountf = mp->m_mounth; | |
281 | vp->v_mountb = &mp->m_mounth; | |
282 | mp->m_mounth->v_mountb = &vp->v_mountf; | |
283 | mp->m_mounth = vp; | |
284 | } else { | |
285 | mp->m_mounth = vp; | |
286 | vp->v_mountb = &mp->m_mounth; | |
287 | vp->v_mountf = NULL; | |
288 | } | |
289 | } | |
290 | ||
291 | /* | |
ef24f6dd KM |
292 | * Create a vnode for a block device. |
293 | * Used for root filesystem, argdev, and swap areas. | |
294 | * Also used for memory file system special devices. | |
295 | */ | |
296 | bdevvp(dev, vpp) | |
297 | dev_t dev; | |
298 | struct vnode **vpp; | |
299 | { | |
ef24f6dd KM |
300 | register struct vnode *vp; |
301 | struct vnode *nvp; | |
302 | int error; | |
303 | ||
4ef5d036 | 304 | error = getnewvnode(VT_NON, (struct mount *)0, &spec_vnodeops, &nvp); |
ef24f6dd KM |
305 | if (error) { |
306 | *vpp = 0; | |
307 | return (error); | |
308 | } | |
309 | vp = nvp; | |
310 | vp->v_type = VBLK; | |
311 | vp->v_rdev = dev; | |
312 | if (nvp = checkalias(vp, (struct mount *)0)) { | |
313 | vput(vp); | |
314 | vp = nvp; | |
315 | } | |
316 | *vpp = vp; | |
317 | return (0); | |
318 | } | |
319 | ||
320 | /* | |
321 | * Check to see if the new vnode represents a special device | |
322 | * for which we already have a vnode (either because of | |
323 | * bdevvp() or because of a different vnode representing | |
324 | * the same block device). If such an alias exists, deallocate | |
f0556f86 | 325 | * the existing contents and return the aliased vnode. The |
ef24f6dd KM |
326 | * caller is responsible for filling it with its new contents. |
327 | */ | |
328 | struct vnode * | |
329 | checkalias(nvp, mp) | |
330 | register struct vnode *nvp; | |
331 | struct mount *mp; | |
332 | { | |
333 | register struct vnode *vp; | |
334 | register struct speclist *slp; | |
335 | ||
336 | if (nvp->v_type != VBLK && nvp->v_type != VCHR) | |
337 | return ((struct vnode *)0); | |
338 | loop: | |
339 | for (slp = speclisth; slp; slp = slp->sl_next) { | |
340 | vp = slp->sl_vp; | |
341 | if (nvp->v_rdev != vp->v_rdev || | |
342 | nvp->v_type != vp->v_type) | |
343 | continue; | |
344 | if (vget(vp)) | |
345 | goto loop; | |
346 | break; | |
347 | } | |
348 | if (slp == NULL) { | |
349 | MALLOC(slp, struct speclist *, sizeof(*slp), M_VNODE, M_WAITOK); | |
350 | slp->sl_vp = nvp; | |
351 | slp->sl_next = speclisth; | |
352 | speclisth = slp; | |
353 | return ((struct vnode *)0); | |
354 | } | |
2bae1875 KM |
355 | VOP_UNLOCK(vp); |
356 | vclean(vp, 0); | |
ef24f6dd KM |
357 | vp->v_op = nvp->v_op; |
358 | vp->v_tag = nvp->v_tag; | |
359 | nvp->v_type = VNON; | |
360 | insmntque(vp, mp); | |
361 | return (vp); | |
362 | } | |
363 | ||
364 | /* | |
365 | * Grab a particular vnode from the free list, increment its | |
366 | * reference count and lock it. The vnode lock bit is set the | |
367 | * vnode is being eliminated in vgone. The process is awakened | |
368 | * when the transition is completed, and an error returned to | |
369 | * indicate that the vnode is no longer usable (possibly having | |
370 | * been changed to a new file system type). | |
36d09cb1 KM |
371 | */ |
372 | vget(vp) | |
373 | register struct vnode *vp; | |
374 | { | |
375 | register struct vnode *vq; | |
376 | ||
ef24f6dd KM |
377 | if (vp->v_flag & VXLOCK) { |
378 | vp->v_flag |= VXWANT; | |
379 | sleep((caddr_t)vp, PINOD); | |
380 | return (1); | |
381 | } | |
382 | if (vp->v_count == 0) { | |
383 | if (vq = vp->v_freef) | |
384 | vq->v_freeb = vp->v_freeb; | |
385 | else | |
386 | vfreet = vp->v_freeb; | |
387 | *vp->v_freeb = vq; | |
388 | vp->v_freef = NULL; | |
389 | vp->v_freeb = NULL; | |
390 | } | |
36d09cb1 | 391 | VREF(vp); |
ef24f6dd KM |
392 | VOP_LOCK(vp); |
393 | return (0); | |
36d09cb1 KM |
394 | } |
395 | ||
396 | /* | |
397 | * Vnode reference, just increment the count | |
398 | */ | |
399 | void vref(vp) | |
400 | struct vnode *vp; | |
401 | { | |
402 | ||
403 | vp->v_count++; | |
404 | } | |
405 | ||
406 | /* | |
407 | * vput(), just unlock and vrele() | |
408 | */ | |
409 | void vput(vp) | |
410 | register struct vnode *vp; | |
411 | { | |
412 | VOP_UNLOCK(vp); | |
413 | vrele(vp); | |
414 | } | |
415 | ||
416 | /* | |
417 | * Vnode release. | |
418 | * If count drops to zero, call inactive routine and return to freelist. | |
419 | */ | |
420 | void vrele(vp) | |
421 | register struct vnode *vp; | |
422 | { | |
423 | ||
424 | if (vp == NULL) | |
ef24f6dd | 425 | panic("vrele: null vp"); |
36d09cb1 KM |
426 | vp->v_count--; |
427 | if (vp->v_count < 0) | |
428 | printf("vnode bad ref count %d, type %d, tag %d\n", | |
429 | vp->v_count, vp->v_type, vp->v_tag); | |
430 | if (vp->v_count > 0) | |
431 | return; | |
36d09cb1 KM |
432 | if (vfreeh == (struct vnode *)0) { |
433 | /* | |
434 | * insert into empty list | |
435 | */ | |
436 | vfreeh = vp; | |
437 | vp->v_freeb = &vfreeh; | |
36d09cb1 KM |
438 | } else { |
439 | /* | |
440 | * insert at tail of list | |
441 | */ | |
442 | *vfreet = vp; | |
443 | vp->v_freeb = vfreet; | |
36d09cb1 | 444 | } |
ef24f6dd KM |
445 | vp->v_freef = NULL; |
446 | vfreet = &vp->v_freef; | |
447 | VOP_INACTIVE(vp); | |
448 | } | |
449 | ||
f0556f86 KM |
450 | /* |
451 | * Remove any vnodes in the vnode table belonging to mount point mp. | |
452 | * | |
453 | * If MNT_NOFORCE is specified, there should not be any active ones, | |
454 | * return error if any are found (nb: this is a user error, not a | |
455 | * system error). If MNT_FORCE is specified, detach any active vnodes | |
456 | * that are found. | |
457 | */ | |
458 | int busyprt = 0; /* patch to print out busy vnodes */ | |
459 | ||
460 | vflush(mp, skipvp, flags) | |
461 | struct mount *mp; | |
462 | struct vnode *skipvp; | |
463 | int flags; | |
464 | { | |
465 | register struct vnode *vp, *nvp; | |
466 | int busy = 0; | |
467 | ||
468 | for (vp = mp->m_mounth; vp; vp = nvp) { | |
469 | nvp = vp->v_mountf; | |
470 | /* | |
471 | * Skip over a selected vnode. | |
472 | * Used by ufs to skip over the quota structure inode. | |
473 | */ | |
474 | if (vp == skipvp) | |
475 | continue; | |
476 | /* | |
477 | * With v_count == 0, all we need to do is clear | |
478 | * out the vnode data structures and we are done. | |
479 | */ | |
480 | if (vp->v_count == 0) { | |
481 | vgone(vp); | |
482 | continue; | |
483 | } | |
484 | /* | |
485 | * For block or character devices, revert to an | |
486 | * anonymous device. For all other files, just kill them. | |
487 | */ | |
488 | if (flags & MNT_FORCE) { | |
489 | if (vp->v_type != VBLK && vp->v_type != VCHR) { | |
490 | vgone(vp); | |
491 | } else { | |
492 | vclean(vp, 0); | |
493 | vp->v_op = &spec_vnodeops; | |
494 | insmntque(vp, (struct mount *)0); | |
495 | } | |
496 | continue; | |
497 | } | |
498 | if (busyprt) | |
499 | printf("vflush: busy vnode count %d type %d tag %d\n", | |
500 | vp->v_count, vp->v_type, vp->v_tag); | |
501 | busy++; | |
502 | } | |
503 | if (busy) | |
504 | return (EBUSY); | |
505 | return (0); | |
506 | } | |
507 | ||
ef24f6dd KM |
508 | /* |
509 | * Disassociate the underlying file system from a vnode. | |
ef24f6dd | 510 | */ |
2bae1875 | 511 | void vclean(vp, doclose) |
ef24f6dd | 512 | register struct vnode *vp; |
2bae1875 | 513 | long doclose; |
ef24f6dd KM |
514 | { |
515 | struct vnodeops *origops; | |
2bae1875 | 516 | int active; |
ef24f6dd | 517 | |
2bae1875 KM |
518 | /* |
519 | * Check to see if the vnode is in use. | |
520 | * If so we have to lock it before we clean it out. | |
521 | */ | |
522 | if (active = vp->v_count) { | |
523 | VREF(vp); | |
524 | VOP_LOCK(vp); | |
525 | } | |
526 | /* | |
527 | * Prevent the vnode from being recycled or | |
528 | * brought into use while we clean it out. | |
529 | */ | |
ef24f6dd KM |
530 | while (vp->v_flag & VXLOCK) { |
531 | vp->v_flag |= VXWANT; | |
532 | sleep((caddr_t)vp, PINOD); | |
533 | } | |
534 | vp->v_flag |= VXLOCK; | |
535 | /* | |
536 | * Prevent any further operations on the vnode from | |
537 | * being passed through to the old file system. | |
538 | */ | |
539 | origops = vp->v_op; | |
540 | vp->v_op = &dead_vnodeops; | |
541 | vp->v_tag = VT_NON; | |
542 | /* | |
2bae1875 KM |
543 | * If purging an active vnode, it must be unlocked, closed, |
544 | * and deactivated before being reclaimed. | |
ef24f6dd | 545 | */ |
2bae1875 | 546 | if (active) { |
ef24f6dd | 547 | (*(origops->vn_unlock))(vp); |
2bae1875 KM |
548 | if (doclose) |
549 | (*(origops->vn_close))(vp, 0, NOCRED); | |
ef24f6dd KM |
550 | (*(origops->vn_inactive))(vp); |
551 | } | |
552 | /* | |
553 | * Reclaim the vnode. | |
554 | */ | |
555 | if ((*(origops->vn_reclaim))(vp)) | |
556 | panic("vclean: cannot reclaim"); | |
2bae1875 KM |
557 | if (active) |
558 | vrele(vp); | |
ef24f6dd KM |
559 | /* |
560 | * Done with purge, notify sleepers in vget of the grim news. | |
561 | */ | |
562 | vp->v_flag &= ~VXLOCK; | |
563 | if (vp->v_flag & VXWANT) { | |
564 | vp->v_flag &= ~VXWANT; | |
565 | wakeup((caddr_t)vp); | |
566 | } | |
567 | } | |
568 | ||
569 | /* | |
570 | * Eliminate all activity associated with a vnode | |
571 | * in preparation for reuse. | |
572 | */ | |
573 | void vgone(vp) | |
574 | register struct vnode *vp; | |
575 | { | |
576 | register struct speclist *slp; | |
577 | struct speclist *pslp; | |
578 | register struct vnode *vq; | |
579 | ||
ef24f6dd KM |
580 | /* |
581 | * Clean out the filesystem specific data. | |
582 | */ | |
2bae1875 | 583 | vclean(vp, 1); |
ef24f6dd KM |
584 | /* |
585 | * Delete from old mount point vnode list, if on one. | |
586 | */ | |
587 | if (vp->v_mountb) { | |
588 | if (vq = vp->v_mountf) | |
589 | vq->v_mountb = vp->v_mountb; | |
590 | *vp->v_mountb = vq; | |
591 | vp->v_mountf = NULL; | |
592 | vp->v_mountb = NULL; | |
593 | } | |
594 | /* | |
595 | * If special device, remove it from special device alias list. | |
596 | */ | |
597 | if (vp->v_type == VBLK || vp->v_type == VCHR) { | |
598 | if (speclisth->sl_vp == vp) { | |
599 | slp = speclisth; | |
600 | speclisth = slp->sl_next; | |
601 | } else { | |
ff4fb102 | 602 | for (pslp = speclisth, slp = pslp->sl_next; slp; |
ef24f6dd KM |
603 | pslp = slp, slp = slp->sl_next) { |
604 | if (slp->sl_vp != vp) | |
605 | continue; | |
606 | pslp->sl_next = slp->sl_next; | |
607 | break; | |
608 | } | |
609 | if (slp == NULL) | |
610 | panic("missing bdev"); | |
611 | } | |
612 | FREE(slp, M_VNODE); | |
613 | } | |
614 | /* | |
615 | * If it is on the freelist, move it to the head of the list. | |
616 | */ | |
617 | if (vp->v_freeb) { | |
618 | if (vq = vp->v_freef) | |
619 | vq->v_freeb = vp->v_freeb; | |
620 | else | |
621 | vfreet = vp->v_freeb; | |
622 | *vp->v_freeb = vq; | |
623 | vp->v_freef = vfreeh; | |
624 | vp->v_freeb = &vfreeh; | |
625 | vfreeh->v_freeb = &vp->v_freef; | |
626 | vfreeh = vp; | |
627 | } | |
2bae1875 | 628 | vp->v_type = VBAD; |
36d09cb1 | 629 | } |