| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: vfs_subr.c,v 1.387 2009/11/17 22:20:14 bouyer Exp $ */ | | 1 | /* $NetBSD: vfs_subr.c,v 1.388 2009/11/19 02:59:33 enami Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
9 | * NASA Ames Research Center, by Charles M. Hannum, and by Andrew Doran. | | 9 | * NASA Ames Research Center, by Charles M. Hannum, and by Andrew Doran. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -81,27 +81,27 @@ | | | @@ -81,27 +81,27 @@ |
81 | * must be held. | | 81 | * must be held. |
82 | * To modify the VC_XLOCK bit, the interlock must be held. | | 82 | * To modify the VC_XLOCK bit, the interlock must be held. |
83 | * We always keep the usecount (v_usecount & VC_MASK) non-zero while the | | 83 | * We always keep the usecount (v_usecount & VC_MASK) non-zero while the |
84 | * VC_XLOCK bit is set. | | 84 | * VC_XLOCK bit is set. |
85 | * | | 85 | * |
86 | * Unless the VC_XLOCK bit is set, changing the usecount from a non-zero | | 86 | * Unless the VC_XLOCK bit is set, changing the usecount from a non-zero |
87 | * value to a non-zero value can safely be done using atomic operations, | | 87 | * value to a non-zero value can safely be done using atomic operations, |
88 | * without the interlock held. | | 88 | * without the interlock held. |
89 | * Even if the VC_XLOCK bit is set, decreasing the usecount to a non-zero | | 89 | * Even if the VC_XLOCK bit is set, decreasing the usecount to a non-zero |
90 | * value can be done using atomic operations, without the interlock held. | | 90 | * value can be done using atomic operations, without the interlock held. |
91 | */ | | 91 | */ |
92 | | | 92 | |
93 | #include <sys/cdefs.h> | | 93 | #include <sys/cdefs.h> |
94 | __KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.387 2009/11/17 22:20:14 bouyer Exp $"); | | 94 | __KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.388 2009/11/19 02:59:33 enami Exp $"); |
95 | | | 95 | |
96 | #include "opt_ddb.h" | | 96 | #include "opt_ddb.h" |
97 | #include "opt_compat_netbsd.h" | | 97 | #include "opt_compat_netbsd.h" |
98 | #include "opt_compat_43.h" | | 98 | #include "opt_compat_43.h" |
99 | | | 99 | |
100 | #include <sys/param.h> | | 100 | #include <sys/param.h> |
101 | #include <sys/systm.h> | | 101 | #include <sys/systm.h> |
102 | #include <sys/conf.h> | | 102 | #include <sys/conf.h> |
103 | #include <sys/proc.h> | | 103 | #include <sys/proc.h> |
104 | #include <sys/kernel.h> | | 104 | #include <sys/kernel.h> |
105 | #include <sys/mount.h> | | 105 | #include <sys/mount.h> |
106 | #include <sys/fcntl.h> | | 106 | #include <sys/fcntl.h> |
107 | #include <sys/vnode.h> | | 107 | #include <sys/vnode.h> |
| @@ -2198,38 +2198,40 @@ sysctl_kern_vnode(SYSCTLFN_ARGS) | | | @@ -2198,38 +2198,40 @@ sysctl_kern_vnode(SYSCTLFN_ARGS) |
2198 | for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = vunmark(mvp)) { | | 2198 | for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = vunmark(mvp)) { |
2199 | vmark(mvp, vp); | | 2199 | vmark(mvp, vp); |
2200 | /* | | 2200 | /* |
2201 | * Check that the vp is still associated with | | 2201 | * Check that the vp is still associated with |
2202 | * this filesystem. RACE: could have been | | 2202 | * this filesystem. RACE: could have been |
2203 | * recycled onto the same filesystem. | | 2203 | * recycled onto the same filesystem. |
2204 | */ | | 2204 | */ |
2205 | if (vp->v_mount != mp || vismarker(vp)) | | 2205 | if (vp->v_mount != mp || vismarker(vp)) |
2206 | continue; | | 2206 | continue; |
2207 | if (bp + VPTRSZ + VNODESZ > ewhere) { | | 2207 | if (bp + VPTRSZ + VNODESZ > ewhere) { |
2208 | (void)vunmark(mvp); | | 2208 | (void)vunmark(mvp); |
2209 | mutex_exit(&mntvnode_lock); | | 2209 | mutex_exit(&mntvnode_lock); |
2210 | vnfree(mvp); | | 2210 | vnfree(mvp); |
| | | 2211 | vfs_unbusy(mp, false, NULL); |
2211 | sysctl_relock(); | | 2212 | sysctl_relock(); |
2212 | *sizep = bp - where; | | 2213 | *sizep = bp - where; |
2213 | return (ENOMEM); | | 2214 | return (ENOMEM); |
2214 | } | | 2215 | } |
2215 | memcpy(&vbuf, vp, VNODESZ); | | 2216 | memcpy(&vbuf, vp, VNODESZ); |
2216 | mutex_exit(&mntvnode_lock); | | 2217 | mutex_exit(&mntvnode_lock); |
2217 | if ((error = copyout(&vp, bp, VPTRSZ)) || | | 2218 | if ((error = copyout(&vp, bp, VPTRSZ)) || |
2218 | (error = copyout(&vbuf, bp + VPTRSZ, VNODESZ))) { | | 2219 | (error = copyout(&vbuf, bp + VPTRSZ, VNODESZ))) { |
2219 | mutex_enter(&mntvnode_lock); | | 2220 | mutex_enter(&mntvnode_lock); |
2220 | (void)vunmark(mvp); | | 2221 | (void)vunmark(mvp); |
2221 | mutex_exit(&mntvnode_lock); | | 2222 | mutex_exit(&mntvnode_lock); |
2222 | vnfree(mvp); | | 2223 | vnfree(mvp); |
| | | 2224 | vfs_unbusy(mp, false, NULL); |
2223 | sysctl_relock(); | | 2225 | sysctl_relock(); |
2224 | return (error); | | 2226 | return (error); |
2225 | } | | 2227 | } |
2226 | bp += VPTRSZ + VNODESZ; | | 2228 | bp += VPTRSZ + VNODESZ; |
2227 | mutex_enter(&mntvnode_lock); | | 2229 | mutex_enter(&mntvnode_lock); |
2228 | } | | 2230 | } |
2229 | mutex_exit(&mntvnode_lock); | | 2231 | mutex_exit(&mntvnode_lock); |
2230 | vnfree(mvp); | | 2232 | vnfree(mvp); |
2231 | vfs_unbusy(mp, false, &nmp); | | 2233 | vfs_unbusy(mp, false, &nmp); |
2232 | } | | 2234 | } |
2233 | mutex_exit(&mountlist_lock); | | 2235 | mutex_exit(&mountlist_lock); |
2234 | sysctl_relock(); | | 2236 | sysctl_relock(); |
2235 | | | 2237 | |