vfs_export.c (986f4ce75ecfc9a4b7e3bdfe993bb2f35a0fa7de) | vfs_export.c (4b2af45f4ba1f8d8d5a56c4b18f29da6d08146e9) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94 | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94 |
39 * $Id: vfs_subr.c,v 1.41 1995/11/14 09:19:12 phk Exp $ | 39 * $Id: vfs_subr.c,v 1.42 1995/11/16 09:45:23 bde Exp $ |
40 */ 41 42/* 43 * External virtual filesystem routines 44 */ 45 46#include <sys/param.h> 47#include <sys/systm.h> --- 122 unchanged lines hidden (view full) --- 170 mp->mnt_flag &= ~MNT_MPBUSY; 171 if (mp->mnt_flag & MNT_MPWANT) { 172 mp->mnt_flag &= ~MNT_MPWANT; 173 wakeup((caddr_t) &mp->mnt_flag); 174 } 175} 176 177void | 40 */ 41 42/* 43 * External virtual filesystem routines 44 */ 45 46#include <sys/param.h> 47#include <sys/systm.h> --- 122 unchanged lines hidden (view full) --- 170 mp->mnt_flag &= ~MNT_MPBUSY; 171 if (mp->mnt_flag & MNT_MPWANT) { 172 mp->mnt_flag &= ~MNT_MPWANT; 173 wakeup((caddr_t) &mp->mnt_flag); 174 } 175} 176 177void |
178vfs_unmountroot(rootfs) 179 struct mount *rootfs; | 178vfs_unmountroot(struct mount *rootfs) |
180{ 181 struct mount *mp = rootfs; 182 int error; 183 184 if (vfs_busy(mp)) { 185 printf("failed to unmount root\n"); 186 return; 187 } --- 760 unchanged lines hidden (view full) --- 948 return (EBUSY); 949 return (0); 950} 951 952/* 953 * Disassociate the underlying file system from a vnode. 954 */ 955void | 179{ 180 struct mount *mp = rootfs; 181 int error; 182 183 if (vfs_busy(mp)) { 184 printf("failed to unmount root\n"); 185 return; 186 } --- 760 unchanged lines hidden (view full) --- 947 return (EBUSY); 948 return (0); 949} 950 951/* 952 * Disassociate the underlying file system from a vnode. 953 */ 954void |
956vclean(vp, flags) 957 register struct vnode *vp; 958 int flags; | 955vclean(struct vnode *vp, int flags) |
959{ 960 int active; 961 962 /* 963 * Check to see if the vnode is in use. If so we have to reference it 964 * before we clean it out so that its count cannot fall to zero and 965 * generate a race against ourselves to recycle it. 966 */ --- 275 unchanged lines hidden (view full) --- 1242} 1243 1244#ifdef DDB 1245/* 1246 * List all of the locked vnodes in the system. 1247 * Called when debugging the kernel. 1248 */ 1249void | 956{ 957 int active; 958 959 /* 960 * Check to see if the vnode is in use. If so we have to reference it 961 * before we clean it out so that its count cannot fall to zero and 962 * generate a race against ourselves to recycle it. 963 */ --- 275 unchanged lines hidden (view full) --- 1239} 1240 1241#ifdef DDB 1242/* 1243 * List all of the locked vnodes in the system. 1244 * Called when debugging the kernel. 1245 */ 1246void |
1250printlockedvnodes() | 1247printlockedvnodes(void) |
1251{ 1252 register struct mount *mp; 1253 register struct vnode *vp; 1254 1255 printf("Locked vnodes\n"); 1256 for (mp = mountlist.cqh_first; mp != (void *)&mountlist; 1257 mp = mp->mnt_list.cqe_next) { 1258 for (vp = mp->mnt_vnodelist.lh_first; --- 9 unchanged lines hidden (view full) --- 1268int kinfo_vgetfailed; 1269 1270#define KINFO_VNODESLOP 10 1271/* 1272 * Dump vnode list (via sysctl). 1273 * Copyout address of vnode followed by vnode. 1274 */ 1275/* ARGSUSED */ | 1248{ 1249 register struct mount *mp; 1250 register struct vnode *vp; 1251 1252 printf("Locked vnodes\n"); 1253 for (mp = mountlist.cqh_first; mp != (void *)&mountlist; 1254 mp = mp->mnt_list.cqe_next) { 1255 for (vp = mp->mnt_vnodelist.lh_first; --- 9 unchanged lines hidden (view full) --- 1265int kinfo_vgetfailed; 1266 1267#define KINFO_VNODESLOP 10 1268/* 1269 * Dump vnode list (via sysctl). 1270 * Copyout address of vnode followed by vnode. 1271 */ 1272/* ARGSUSED */ |
1276int 1277sysctl_vnode(where, sizep) 1278 char *where; 1279 size_t *sizep; | 1273static int 1274sysctl_vnode SYSCTL_HANDLER_ARGS |
1280{ 1281 register struct mount *mp, *nmp; 1282 struct vnode *vp; | 1275{ 1276 register struct mount *mp, *nmp; 1277 struct vnode *vp; |
1283 register char *bp = where, *savebp; 1284 char *ewhere; | |
1285 int error; 1286 1287#define VPTRSZ sizeof (struct vnode *) 1288#define VNODESZ sizeof (struct vnode) | 1278 int error; 1279 1280#define VPTRSZ sizeof (struct vnode *) 1281#define VNODESZ sizeof (struct vnode) |
1289 if (where == NULL) { 1290 *sizep = (numvnodes + KINFO_VNODESLOP) * (VPTRSZ + VNODESZ); 1291 return (0); 1292 } 1293 ewhere = where + *sizep; | |
1294 | 1282 |
1283 req->lock = 0; 1284 if (req->oldptr) /* Make an estimate */ 1285 return (SYSCTL_OUT(req, 0, 1286 (numvnodes + KINFO_VNODESLOP) * (VPTRSZ + VNODESZ))); 1287 |
|
1295 for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) { 1296 nmp = mp->mnt_list.cqe_next; 1297 if (vfs_busy(mp)) 1298 continue; | 1288 for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) { 1289 nmp = mp->mnt_list.cqe_next; 1290 if (vfs_busy(mp)) 1291 continue; |
1299 savebp = bp; | |
1300again: 1301 for (vp = mp->mnt_vnodelist.lh_first; 1302 vp != NULL; 1303 vp = vp->v_mntvnodes.le_next) { 1304 /* 1305 * Check that the vp is still associated with this 1306 * filesystem. RACE: could have been recycled onto 1307 * the same filesystem. 1308 */ 1309 if (vp->v_mount != mp) { 1310 if (kinfo_vdebug) 1311 printf("kinfo: vp changed\n"); | 1292again: 1293 for (vp = mp->mnt_vnodelist.lh_first; 1294 vp != NULL; 1295 vp = vp->v_mntvnodes.le_next) { 1296 /* 1297 * Check that the vp is still associated with this 1298 * filesystem. RACE: could have been recycled onto 1299 * the same filesystem. 1300 */ 1301 if (vp->v_mount != mp) { 1302 if (kinfo_vdebug) 1303 printf("kinfo: vp changed\n"); |
1312 bp = savebp; | |
1313 goto again; 1314 } | 1304 goto again; 1305 } |
1315 if (bp + VPTRSZ + VNODESZ > ewhere) { | 1306 if ((error = SYSCTL_OUT(req, &vp, VPTRSZ)) || 1307 (error = SYSCTL_OUT(req, vp, VNODESZ))) { |
1316 vfs_unbusy(mp); | 1308 vfs_unbusy(mp); |
1317 *sizep = bp - where; 1318 return (ENOMEM); 1319 } 1320 if ((error = copyout(&vp, bp, VPTRSZ)) || 1321 (error = copyout(vp, bp + VPTRSZ, VNODESZ))) { 1322 vfs_unbusy(mp); 1323 *sizep = bp - where; | |
1324 return (error); 1325 } | 1309 return (error); 1310 } |
1326 bp += VPTRSZ + VNODESZ; | |
1327 } 1328 vfs_unbusy(mp); 1329 } 1330 | 1311 } 1312 vfs_unbusy(mp); 1313 } 1314 |
1331 *sizep = bp - where; | |
1332 return (0); 1333} 1334 | 1315 return (0); 1316} 1317 |
1318SYSCTL_NODE(_kern, KERN_VNODE, vnode, CTLTYPE_OPAQUE|CTLFLAG_RD, 1319 sysctl_vnode, ""); 1320 1321 |
|
1335/* 1336 * Check to see if a filesystem is mounted on a block device. 1337 */ 1338int 1339vfs_mountedon(vp) 1340 register struct vnode *vp; 1341{ 1342 register struct vnode *vq; --- 12 unchanged lines hidden (view full) --- 1355 return (0); 1356} 1357 1358/* 1359 * Build hash lists of net addresses and hang them off the mount point. 1360 * Called by ufs_mount() to set up the lists of export addresses. 1361 */ 1362static int | 1322/* 1323 * Check to see if a filesystem is mounted on a block device. 1324 */ 1325int 1326vfs_mountedon(vp) 1327 register struct vnode *vp; 1328{ 1329 register struct vnode *vq; --- 12 unchanged lines hidden (view full) --- 1342 return (0); 1343} 1344 1345/* 1346 * Build hash lists of net addresses and hang them off the mount point. 1347 * Called by ufs_mount() to set up the lists of export addresses. 1348 */ 1349static int |
1363vfs_hang_addrlist(mp, nep, argp) 1364 struct mount *mp; 1365 struct netexport *nep; 1366 struct export_args *argp; | 1350vfs_hang_addrlist(struct mount *mp, struct netexport *nep, 1351 struct export_args *argp) |
1367{ 1368 register struct netcred *np; 1369 register struct radix_node_head *rnh; 1370 register int i; 1371 struct radix_node *rn; 1372 struct sockaddr *saddr, *smask = 0; 1373 struct domain *dom; 1374 int error; --- 53 unchanged lines hidden (view full) --- 1428 return (0); 1429out: 1430 free(np, M_NETADDR); 1431 return (error); 1432} 1433 1434/* ARGSUSED */ 1435static int | 1352{ 1353 register struct netcred *np; 1354 register struct radix_node_head *rnh; 1355 register int i; 1356 struct radix_node *rn; 1357 struct sockaddr *saddr, *smask = 0; 1358 struct domain *dom; 1359 int error; --- 53 unchanged lines hidden (view full) --- 1413 return (0); 1414out: 1415 free(np, M_NETADDR); 1416 return (error); 1417} 1418 1419/* ARGSUSED */ 1420static int |
1436vfs_free_netcred(rn, w) 1437 struct radix_node *rn; 1438 void *w; | 1421vfs_free_netcred(struct radix_node *rn, void *w) |
1439{ 1440 register struct radix_node_head *rnh = (struct radix_node_head *) w; 1441 1442 (*rnh->rnh_deladdr) (rn->rn_key, rn->rn_mask, rnh); 1443 free((caddr_t) rn, M_NETADDR); 1444 return (0); 1445} 1446 1447/* 1448 * Free the net address hash lists that are hanging off the mount points. 1449 */ 1450static void | 1422{ 1423 register struct radix_node_head *rnh = (struct radix_node_head *) w; 1424 1425 (*rnh->rnh_deladdr) (rn->rn_key, rn->rn_mask, rnh); 1426 free((caddr_t) rn, M_NETADDR); 1427 return (0); 1428} 1429 1430/* 1431 * Free the net address hash lists that are hanging off the mount points. 1432 */ 1433static void |
1451vfs_free_addrlist(nep) 1452 struct netexport *nep; | 1434vfs_free_addrlist(struct netexport *nep) |
1453{ 1454 register int i; 1455 register struct radix_node_head *rnh; 1456 1457 for (i = 0; i <= AF_MAX; i++) 1458 if ((rnh = nep->ne_rtable[i])) { 1459 (*rnh->rnh_walktree) (rnh, vfs_free_netcred, 1460 (caddr_t) rnh); --- 83 unchanged lines hidden --- | 1435{ 1436 register int i; 1437 register struct radix_node_head *rnh; 1438 1439 for (i = 0; i <= AF_MAX; i++) 1440 if ((rnh = nep->ne_rtable[i])) { 1441 (*rnh->rnh_walktree) (rnh, vfs_free_netcred, 1442 (caddr_t) rnh); --- 83 unchanged lines hidden --- |