PR kern/38135 vfs_busy/vfs_trybusy confusion
The previous fix worked, but it opened a window where mounts could have disappeared from mountlist while the caller was traversing it using vfs_trybusy(). Fix that.
This commit is contained in:
parent
83bf8c56bb
commit
928a6b2096
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs_syscalls_20.c,v 1.27 2008/04/29 23:51:04 ad Exp $ */
|
||||
/* $NetBSD: vfs_syscalls_20.c,v 1.28 2008/04/30 12:49:16 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.27 2008/04/29 23:51:04 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.28 2008/04/30 12:49:16 ad Exp $");
|
||||
|
||||
#include "opt_compat_netbsd.h"
|
||||
#include "opt_compat_43.h"
|
||||
@ -229,13 +229,12 @@ compat_20_sys_getfsstat(struct lwp *l, const struct compat_20_sys_getfsstat_args
|
||||
error = dostatvfs(mp, sbuf, l, SCARG(uap, flags), 0);
|
||||
if (error) {
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
continue;
|
||||
}
|
||||
error = vfs2fs(sfsp, sbuf);
|
||||
if (error) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
goto out;
|
||||
}
|
||||
sfsp++;
|
||||
@ -243,8 +242,7 @@ compat_20_sys_getfsstat(struct lwp *l, const struct compat_20_sys_getfsstat_args
|
||||
}
|
||||
count++;
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
}
|
||||
mutex_exit(&mountlist_lock);
|
||||
if (root == 0 && l->l_proc->p_cwdi->cwdi_rdir) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: netbsd32_compat_20.c,v 1.22 2008/04/30 06:49:23 jmmv Exp $ */
|
||||
/* $NetBSD: netbsd32_compat_20.c,v 1.23 2008/04/30 12:49:16 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998, 2001 Matthew R. Green
|
||||
@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.22 2008/04/30 06:49:23 jmmv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.23 2008/04/30 12:49:16 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -122,23 +122,21 @@ compat_20_netbsd32_getfsstat(struct lwp *l, const struct compat_20_netbsd32_getf
|
||||
SCARG(uap, flags) == 0) &&
|
||||
(error = VFS_STATVFS(mp, sp)) != 0) {
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = mp->mnt_list.cqe_next;
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
continue;
|
||||
}
|
||||
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||
compat_20_netbsd32_from_statvfs(sp, &sb32);
|
||||
error = copyout(&sb32, sfsp, sizeof(sb32));
|
||||
if (error) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
return (error);
|
||||
}
|
||||
sfsp = (char *)sfsp + sizeof(sb32);
|
||||
}
|
||||
count++;
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = mp->mnt_list.cqe_next;
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
}
|
||||
mutex_exit(&mountlist_lock);
|
||||
if (sfsp && count > maxcount)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: osf1_mount.c,v 1.42 2008/04/30 06:49:23 jmmv Exp $ */
|
||||
/* $NetBSD: osf1_mount.c,v 1.43 2008/04/30 12:49:16 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
|
||||
@ -58,7 +58,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: osf1_mount.c,v 1.42 2008/04/30 06:49:23 jmmv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: osf1_mount.c,v 1.43 2008/04/30 12:49:16 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "fs_nfs.h"
|
||||
@ -167,7 +167,7 @@ osf1_sys_getfsstat(struct lwp *l, const struct osf1_sys_getfsstat_args *uap, reg
|
||||
osf1_cvt_statfs_from_native(sp, &osfs);
|
||||
if ((error = copyout(&osfs, osf_sfsp,
|
||||
sizeof (struct osf1_statfs)))) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
return (error);
|
||||
}
|
||||
osf_sfsp += sizeof (struct osf1_statfs);
|
||||
@ -175,8 +175,7 @@ osf1_sys_getfsstat(struct lwp *l, const struct osf1_sys_getfsstat_args *uap, reg
|
||||
}
|
||||
count++;
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = mp->mnt_list.cqe_next;
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
}
|
||||
mutex_exit(&mountlist_lock);
|
||||
if (osf_sfsp && count > maxcount)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ultrix_fs.c,v 1.47 2008/04/30 06:49:23 jmmv Exp $ */
|
||||
/* $NetBSD: ultrix_fs.c,v 1.48 2008/04/30 12:49:16 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1997 Jonathan Stone
|
||||
@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ultrix_fs.c,v 1.47 2008/04/30 06:49:23 jmmv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ultrix_fs.c,v 1.48 2008/04/30 12:49:16 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -280,7 +280,7 @@ ultrix_sys_getmnt(struct lwp *l, const struct ultrix_sys_getmnt_args *uap, regis
|
||||
make_ultrix_mntent(sp, &tem);
|
||||
if ((error = copyout((void *)&tem, sfsp,
|
||||
sizeof(tem))) != 0) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
goto bad;
|
||||
}
|
||||
sfsp++;
|
||||
@ -288,8 +288,7 @@ ultrix_sys_getmnt(struct lwp *l, const struct ultrix_sys_getmnt_args *uap, regis
|
||||
}
|
||||
}
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = mp->mnt_list.cqe_next;
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
}
|
||||
mutex_exit(&mountlist_lock);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cd9660_vfsops.c,v 1.58 2008/04/29 18:18:08 ad Exp $ */
|
||||
/* $NetBSD: cd9660_vfsops.c,v 1.59 2008/04/30 12:49:16 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.58 2008/04/29 18:18:08 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.59 2008/04/30 12:49:16 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_compat_netbsd.h"
|
||||
@ -149,15 +149,16 @@ cd9660_mountroot(void)
|
||||
|
||||
args.flags = ISOFSMNT_ROOT;
|
||||
if ((error = iso_mountfs(rootvp, mp, l, &args)) != 0) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_destroy(mp);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
vfs_destroy(mp, false);
|
||||
return (error);
|
||||
}
|
||||
mutex_enter(&mountlist_lock);
|
||||
CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
mp->mnt_iflag |= IMNT_ONLIST;
|
||||
mutex_exit(&mountlist_lock);
|
||||
(void)cd9660_statvfs(mp, &mp->mnt_stat);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: filecore_vfsops.c,v 1.50 2008/04/29 18:18:08 ad Exp $ */
|
||||
/* $NetBSD: filecore_vfsops.c,v 1.51 2008/04/30 12:49:16 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The Regents of the University of California.
|
||||
@ -66,7 +66,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: filecore_vfsops.c,v 1.50 2008/04/29 18:18:08 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: filecore_vfsops.c,v 1.51 2008/04/30 12:49:16 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_compat_netbsd.h"
|
||||
@ -173,15 +173,16 @@ filecore_mountroot()
|
||||
|
||||
args.flags = FILECOREMNT_ROOT;
|
||||
if ((error = filecore_mountfs(rootvp, mp, p, &args)) != 0) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_destroy(mp);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
vfs_destroy(mp, false);
|
||||
return (error);
|
||||
}
|
||||
simple_lock(&mountlist_slock);
|
||||
CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
mp->mnt_iflag |= IMNT_ONLIST;
|
||||
simple_unlock(&mountlist_slock);
|
||||
(void)filecore_statvfs(mp, &mp->mnt_stat, p);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: msdosfs_vfsops.c,v 1.62 2008/04/29 18:18:08 ad Exp $ */
|
||||
/* $NetBSD: msdosfs_vfsops.c,v 1.63 2008/04/30 12:49:16 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
|
||||
@ -48,7 +48,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.62 2008/04/29 18:18:08 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.63 2008/04/30 12:49:16 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_quota.h"
|
||||
@ -213,24 +213,25 @@ msdosfs_mountroot()
|
||||
args.dirmask = 0777;
|
||||
|
||||
if ((error = msdosfs_mountfs(rootvp, mp, l, &args)) != 0) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_destroy(mp);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
vfs_destroy(mp, false);
|
||||
return (error);
|
||||
}
|
||||
|
||||
if ((error = update_mp(mp, &args)) != 0) {
|
||||
(void)msdosfs_unmount(mp, 0);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_destroy(mp);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
vfs_destroy(mp, false);
|
||||
vrele(rootvp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
mutex_enter(&mountlist_lock);
|
||||
CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
mp->mnt_iflag |= IMNT_ONLIST;
|
||||
mutex_exit(&mountlist_lock);
|
||||
(void)msdosfs_statvfs(mp, &mp->mnt_stat);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ntfs_vfsops.c,v 1.66 2008/04/29 18:18:08 ad Exp $ */
|
||||
/* $NetBSD: ntfs_vfsops.c,v 1.67 2008/04/30 12:49:16 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999 Semen Ustimenko
|
||||
@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.66 2008/04/29 18:18:08 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.67 2008/04/30 12:49:16 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -129,16 +129,17 @@ ntfs_mountroot()
|
||||
args.mode = 0777;
|
||||
|
||||
if ((error = ntfs_mountfs(rootvp, mp, &args, l)) != 0) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_destroy(mp);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
vfs_destroy(mp, false);
|
||||
return (error);
|
||||
}
|
||||
|
||||
mutex_enter(&mountlist_lock);
|
||||
CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
mp->mnt_iflag |= IMNT_ONLIST;
|
||||
mutex_exit(&mountlist_lock);
|
||||
(void)ntfs_statvfs(mp, &mp->mnt_stat);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: puffs_msgif.c,v 1.69 2008/04/29 23:51:04 ad Exp $ */
|
||||
/* $NetBSD: puffs_msgif.c,v 1.70 2008/04/30 12:49:16 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: puffs_msgif.c,v 1.69 2008/04/29 23:51:04 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: puffs_msgif.c,v 1.70 2008/04/30 12:49:16 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/atomic.h>
|
||||
@ -1036,7 +1036,7 @@ puffs_msgif_close(void *this)
|
||||
mutex_enter(&syncer_mutex);
|
||||
if (mp->mnt_iflag & IMNT_GONE) {
|
||||
mutex_exit(&syncer_mutex);
|
||||
vfs_destroy(mp);
|
||||
vfs_destroy(mp, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1053,7 +1053,7 @@ puffs_msgif_close(void *this)
|
||||
*/
|
||||
if (vfs_busy(mp, RW_WRITER)) {
|
||||
mutex_exit(&syncer_mutex);
|
||||
vfs_destroy(mp);
|
||||
vfs_destroy(mp, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1064,7 +1064,7 @@ puffs_msgif_close(void *this)
|
||||
*/
|
||||
rv = dounmount(mp, MNT_FORCE, curlwp);
|
||||
KASSERT(rv == 0);
|
||||
vfs_destroy(mp);
|
||||
vfs_destroy(mp, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: union_vnops.c,v 1.31 2008/04/29 23:51:04 ad Exp $ */
|
||||
/* $NetBSD: union_vnops.c,v 1.32 2008/04/30 12:49:16 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993, 1994, 1995
|
||||
@ -72,7 +72,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.31 2008/04/29 23:51:04 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.32 2008/04/30 12:49:16 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -253,7 +253,7 @@ union_lookup1(struct vnode *udvp, struct vnode **dvpp, struct vnode **vpp,
|
||||
continue;
|
||||
vput(dvp);
|
||||
error = VFS_ROOT(mp, &tdvp);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
if (error) {
|
||||
return (error);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs_lookup.c,v 1.105 2008/04/29 23:51:04 ad Exp $ */
|
||||
/* $NetBSD: vfs_lookup.c,v 1.106 2008/04/30 12:49:16 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.105 2008/04/29 23:51:04 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.106 2008/04/30 12:49:16 ad Exp $");
|
||||
|
||||
#include "opt_magiclinks.h"
|
||||
|
||||
@ -783,7 +783,7 @@ unionlookup:
|
||||
VOP_UNLOCK(ndp->ni_dvp, 0);
|
||||
vput(dp);
|
||||
error = VFS_ROOT(mp, &tdp);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
if (error) {
|
||||
vn_lock(ndp->ni_dvp, LK_EXCLUSIVE | LK_RETRY);
|
||||
goto bad;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs_subr.c,v 1.338 2008/04/29 23:51:04 ad Exp $ */
|
||||
/* $NetBSD: vfs_subr.c,v 1.339 2008/04/30 12:49:16 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -75,7 +75,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.338 2008/04/29 23:51:04 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.339 2008/04/30 12:49:16 ad Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_compat_netbsd.h"
|
||||
@ -304,9 +304,8 @@ vfs_dobusy(struct mount *mp, const krw_t op, struct mount **nextp)
|
||||
if (__predict_false((mp->mnt_iflag & IMNT_GONE) != 0)) {
|
||||
if (nextp != NULL) {
|
||||
mutex_enter(&mountlist_lock);
|
||||
*nextp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
}
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, nextp);
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
@ -317,7 +316,7 @@ vfs_dobusy(struct mount *mp, const krw_t op, struct mount **nextp)
|
||||
* Mark a mount point as busy, and gain a new reference to it. Used to
|
||||
* synchronize access and to delay unmounting.
|
||||
*
|
||||
* => The caller is expected to hold a reference to the mount.
|
||||
* => The caller must hold a pre-existing reference to the mount.
|
||||
*/
|
||||
int
|
||||
vfs_busy(struct mount *mp, const krw_t op)
|
||||
@ -334,7 +333,7 @@ vfs_busy(struct mount *mp, const krw_t op)
|
||||
}
|
||||
mutex_enter(&mount_lock);
|
||||
if (mp->mnt_unmounter != NULL) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
cv_wait(&mount_cv, &mount_lock);
|
||||
}
|
||||
mutex_exit(&mount_lock);
|
||||
@ -345,10 +344,11 @@ vfs_busy(struct mount *mp, const krw_t op)
|
||||
* As vfs_busy(), but return error if the file system is being
|
||||
* unmounted (and do not wait for the unmount).
|
||||
*
|
||||
* => If namep != NULL, mountlist_lock is understood to be held. On
|
||||
* failure a pointer to the next mount will be returned via namep.
|
||||
* => If nextp != NULL, mountlist_lock is understood to be held. On
|
||||
* failure a pointer to the next mount will be returned via nextp.
|
||||
* The caller need not hold a reference to the mount.
|
||||
*
|
||||
* => If namep == NULL, the caller is expected to hold a reference
|
||||
* => If nextp == NULL, the caller is expected to hold a reference
|
||||
* to the mount.
|
||||
*/
|
||||
int
|
||||
@ -359,14 +359,31 @@ vfs_trybusy(struct mount *mp, krw_t op, struct mount **nextp)
|
||||
|
||||
KASSERT(nextp == NULL || mutex_owned(&mountlist_lock));
|
||||
|
||||
if (nextp != NULL) {
|
||||
/*
|
||||
* We need to prevent adding a reference to the mount
|
||||
* if it is already on the way out: the reference count
|
||||
* could be zero, and as a result another thread could
|
||||
* be in vfs_destroy() trying to throw away the mount.
|
||||
*
|
||||
* mnt_iflag is protected by mnt_lock, but this check is
|
||||
* safe if mountlist_lock is held. mountlist_lock will
|
||||
* be held by vfs_destroy() before removing the mount
|
||||
* from mountlist.
|
||||
*/
|
||||
if (__predict_false((mp->mnt_iflag & IMNT_GONE) != 0)) {
|
||||
*nextp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
return ENOENT;
|
||||
}
|
||||
}
|
||||
|
||||
error = vfs_dobusy(mp, op, nextp);
|
||||
l = mp->mnt_unmounter;
|
||||
if (error == 0 && (l != NULL && l != curlwp)) {
|
||||
if (nextp != NULL) {
|
||||
mutex_enter(&mountlist_lock);
|
||||
*nextp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
}
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, nextp);
|
||||
error = EBUSY;
|
||||
}
|
||||
return error;
|
||||
@ -375,9 +392,12 @@ vfs_trybusy(struct mount *mp, krw_t op, struct mount **nextp)
|
||||
/*
|
||||
* Unlock a busy filesystem and drop reference to it. If 'keepref' is
|
||||
* true, unlock but preserve the reference.
|
||||
*
|
||||
* => If nextp != NULL, mountlist_lock is understood to be held. On
|
||||
* failure a pointer to the next mount will be returned via nextp.
|
||||
*/
|
||||
void
|
||||
vfs_unbusy(struct mount *mp, bool keepref)
|
||||
vfs_unbusy(struct mount *mp, bool keepref, struct mount **nextp)
|
||||
{
|
||||
|
||||
KASSERT(mp->mnt_refcnt > 0);
|
||||
@ -393,8 +413,11 @@ vfs_unbusy(struct mount *mp, bool keepref)
|
||||
} else {
|
||||
rw_exit(&mp->mnt_lock);
|
||||
}
|
||||
if (nextp != NULL) {
|
||||
*nextp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
}
|
||||
if (!keepref) {
|
||||
vfs_destroy(mp);
|
||||
vfs_destroy(mp, nextp != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -520,7 +543,7 @@ getnewvnode(enum vtagtype tag, struct mount *mp, int (**vops)(void *),
|
||||
vp = getcleanvnode();
|
||||
if (vp == NULL) {
|
||||
if (mp != NULL) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
}
|
||||
if (tryalloc) {
|
||||
printf("WARNING: unable to allocate new "
|
||||
@ -564,7 +587,7 @@ getnewvnode(enum vtagtype tag, struct mount *mp, int (**vops)(void *),
|
||||
if (mp != NULL) {
|
||||
if ((mp->mnt_iflag & IMNT_MPSAFE) != 0)
|
||||
vp->v_vflag |= VV_MPSAFE;
|
||||
vfs_unbusy(mp, true);
|
||||
vfs_unbusy(mp, true, NULL);
|
||||
}
|
||||
|
||||
return (0);
|
||||
@ -702,7 +725,7 @@ insmntque(vnode_t *vp, struct mount *mp)
|
||||
|
||||
if (omp != NULL) {
|
||||
/* Release reference to old mount. */
|
||||
vfs_destroy(omp);
|
||||
vfs_destroy(omp, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1691,8 +1714,7 @@ sysctl_kern_vnode(SYSCTLFN_ARGS)
|
||||
}
|
||||
mutex_exit(&mntvnode_lock);
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
vnfree(mvp);
|
||||
}
|
||||
mutex_exit(&mountlist_lock);
|
||||
@ -1720,7 +1742,7 @@ vfs_scrubvnlist(struct mount *mp)
|
||||
vp->v_mount = NULL;
|
||||
mutex_exit(&mntvnode_lock);
|
||||
mutex_exit(&vp->v_interlock);
|
||||
vfs_destroy(mp);
|
||||
vfs_destroy(mp, false);
|
||||
goto retry;
|
||||
}
|
||||
mutex_exit(&vp->v_interlock);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs_subr2.c,v 1.21 2008/04/29 23:51:04 ad Exp $ */
|
||||
/* $NetBSD: vfs_subr2.c,v 1.22 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -75,7 +75,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_subr2.c,v 1.21 2008/04/29 23:51:04 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_subr2.c,v 1.22 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
|
||||
@ -190,15 +190,43 @@ vfs_getvfs(fsid_t *fsid)
|
||||
|
||||
/*
|
||||
* Drop a reference to a mount structure, freeing if the last reference.
|
||||
*
|
||||
* => If nextp != NULL, the caller holds mountlist_lock.
|
||||
*
|
||||
* => If nextp == NULL, it must be safe to take mountlist_lock.
|
||||
*/
|
||||
void
|
||||
vfs_destroy(struct mount *mp)
|
||||
vfs_destroy(struct mount *mp, bool interlocked)
|
||||
{
|
||||
|
||||
if (atomic_dec_uint_nv(&mp->mnt_refcnt) > 0) {
|
||||
KASSERT(!interlocked || mutex_owned(&mountlist_lock));
|
||||
|
||||
if (__predict_true(atomic_dec_uint_nv(&mp->mnt_refcnt) > 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
KASSERT(mp->mnt_unmounter == NULL);
|
||||
|
||||
/*
|
||||
* Remove it from the mountlist. We must interlock with
|
||||
* threads traversing the mountlist. See vfs_trybusy().
|
||||
*/
|
||||
if ((mp->mnt_iflag & IMNT_ONLIST) != 0) {
|
||||
if (!interlocked) {
|
||||
mutex_enter(&mountlist_lock);
|
||||
}
|
||||
CIRCLEQ_REMOVE(&mountlist, mp, mnt_list);
|
||||
if (!interlocked) {
|
||||
mutex_exit(&mountlist_lock);
|
||||
}
|
||||
} else {
|
||||
KASSERT((mp->mnt_iflag & IMNT_GONE) != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Nothing else has visibility of the mount: we can now
|
||||
* free the data structures.
|
||||
*/
|
||||
specificdata_fini(mount_specificdata_domain, &mp->mnt_specdataref);
|
||||
rw_destroy(&mp->mnt_lock);
|
||||
if (mp->mnt_op != NULL) {
|
||||
@ -729,8 +757,7 @@ printlockedvnodes(void)
|
||||
vprint(NULL, vp);
|
||||
}
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
}
|
||||
mutex_exit(&mountlist_lock);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs_syscalls.c,v 1.353 2008/04/29 23:51:04 ad Exp $ */
|
||||
/* $NetBSD: vfs_syscalls.c,v 1.354 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
@ -63,7 +63,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.353 2008/04/29 23:51:04 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.354 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#include "opt_compat_netbsd.h"
|
||||
#include "opt_compat_43.h"
|
||||
@ -242,7 +242,7 @@ mount_update(struct lwp *l, struct vnode *vp, const char *path, int flags,
|
||||
if (mp->mnt_syncer != NULL)
|
||||
vfs_deallocate_syncvnode(mp);
|
||||
}
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
|
||||
out:
|
||||
return (error);
|
||||
@ -364,9 +364,8 @@ mount_domount(struct lwp *l, struct vnode **vpp, struct vfsops *vfsops,
|
||||
cache_purge(vp);
|
||||
if (error != 0) {
|
||||
vp->v_mountedhere = NULL;
|
||||
mp->mnt_op->vfs_refcount--;
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_destroy(mp);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
vfs_destroy(mp, false);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -374,6 +373,7 @@ mount_domount(struct lwp *l, struct vnode **vpp, struct vfsops *vfsops,
|
||||
mutex_enter(&mountlist_lock);
|
||||
vp->v_mountedhere = mp;
|
||||
CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
mp->mnt_iflag |= IMNT_ONLIST;
|
||||
mutex_exit(&mountlist_lock);
|
||||
vn_restorerecurse(vp, recurse);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
@ -381,15 +381,15 @@ mount_domount(struct lwp *l, struct vnode **vpp, struct vfsops *vfsops,
|
||||
if ((mp->mnt_flag & (MNT_RDONLY | MNT_ASYNC)) == 0)
|
||||
error = vfs_allocate_syncvnode(mp);
|
||||
/* Hold an additional reference to the mount across VFS_START(). */
|
||||
vfs_unbusy(mp, true);
|
||||
vfs_unbusy(mp, true, NULL);
|
||||
(void) VFS_STATVFS(mp, &mp->mnt_stat);
|
||||
error = VFS_START(mp, 0);
|
||||
if (error) {
|
||||
vrele(vp);
|
||||
vfs_destroy(mp);
|
||||
vfs_destroy(mp, false);
|
||||
}
|
||||
/* Drop reference held for VFS_START(). */
|
||||
vfs_destroy(mp);
|
||||
vfs_destroy(mp, false);
|
||||
*vpp = NULL;
|
||||
return error;
|
||||
}
|
||||
@ -424,7 +424,7 @@ mount_getargs(struct lwp *l, struct vnode *vp, const char *path, int flags,
|
||||
error = VFS_MOUNT(mp, path, data, data_len);
|
||||
mp->mnt_flag &= ~MNT_OP_FLAGS;
|
||||
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -674,7 +674,7 @@ dounmount_lock(struct mount *mp)
|
||||
KASSERT(mp->mnt_unmounter == NULL);
|
||||
|
||||
mp->mnt_unmounter = curlwp;
|
||||
vfs_unbusy(mp, true);
|
||||
vfs_unbusy(mp, true, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -684,11 +684,13 @@ static void
|
||||
dounmount_unlock(struct mount *mp)
|
||||
{
|
||||
|
||||
KASSERT(mp->mnt_unmounter == curlwp);
|
||||
|
||||
mutex_enter(&mount_lock);
|
||||
mp->mnt_unmounter = NULL;
|
||||
cv_broadcast(&mount_cv);
|
||||
mutex_exit(&mount_lock);
|
||||
vfs_destroy(mp);
|
||||
vfs_destroy(mp, false);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -759,11 +761,8 @@ dounmount(struct mount *mp, int flags, struct lwp *l)
|
||||
return (error);
|
||||
}
|
||||
vfs_scrubvnlist(mp);
|
||||
mutex_enter(&mountlist_lock);
|
||||
CIRCLEQ_REMOVE(&mountlist, mp, mnt_list);
|
||||
if ((coveredvp = mp->mnt_vnodecovered) != NULLVP)
|
||||
coveredvp->v_mountedhere = NULL;
|
||||
mutex_exit(&mountlist_lock);
|
||||
if (TAILQ_FIRST(&mp->mnt_vnodelist) != NULL)
|
||||
panic("unmount: dangling vnode");
|
||||
mp->mnt_iflag |= IMNT_GONE;
|
||||
@ -771,7 +770,7 @@ dounmount(struct mount *mp, int flags, struct lwp *l)
|
||||
mutex_exit(&syncer_mutex);
|
||||
vfs_hooks_unmount(mp);
|
||||
dounmount_unlock(mp);
|
||||
vfs_destroy(mp);
|
||||
vfs_destroy(mp, false);
|
||||
if (coveredvp != NULLVP)
|
||||
vrele(coveredvp);
|
||||
return (0);
|
||||
@ -809,8 +808,7 @@ sys_sync(struct lwp *l, const void *v, register_t *retval)
|
||||
mp->mnt_flag |= MNT_ASYNC;
|
||||
}
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = mp->mnt_list.cqe_next;
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
|
||||
}
|
||||
mutex_exit(&mountlist_lock);
|
||||
@ -1024,13 +1022,12 @@ do_sys_getvfsstat(struct lwp *l, void *sfsp, size_t bufsize, int flags,
|
||||
error = dostatvfs(mp, sb, l, flags, 0);
|
||||
if (error) {
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
continue;
|
||||
}
|
||||
error = copyfn(sb, sfsp, entry_sz);
|
||||
if (error) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
goto out;
|
||||
}
|
||||
sfsp = (char *)sfsp + entry_sz;
|
||||
@ -1038,8 +1035,7 @@ do_sys_getvfsstat(struct lwp *l, void *sfsp, size_t bufsize, int flags,
|
||||
}
|
||||
count++;
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
}
|
||||
|
||||
mutex_exit(&mountlist_lock);
|
||||
@ -1115,7 +1111,7 @@ sys_fchdir(struct lwp *l, const struct sys_fchdir_args *uap, register_t *retval)
|
||||
continue;
|
||||
vput(vp);
|
||||
error = VFS_ROOT(mp, &tdp);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
if (error)
|
||||
goto out;
|
||||
vp = tdp;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: procfs_linux.c,v 1.51 2008/04/29 23:51:05 ad Exp $ */
|
||||
/* $NetBSD: procfs_linux.c,v 1.52 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.51 2008/04/29 23:51:05 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.52 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -589,8 +589,7 @@ procfs_domounts(struct lwp *curl, struct proc *p,
|
||||
mtabsz += len;
|
||||
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
}
|
||||
mutex_exit(&mountlist_lock);
|
||||
free(bf, M_TEMP);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sync_vnops.c,v 1.23 2008/04/29 23:51:05 ad Exp $ */
|
||||
/* $NetBSD: sync_vnops.c,v 1.24 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Marshall Kirk McKusick. All Rights Reserved.
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sync_vnops.c,v 1.23 2008/04/29 23:51:05 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sync_vnops.c,v 1.24 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
@ -163,7 +163,7 @@ sync_fsync(v)
|
||||
VFS_SYNC(mp, MNT_LAZY, ap->a_cred);
|
||||
if (asyncflag)
|
||||
mp->mnt_flag |= MNT_ASYNC;
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: nfs_export.c,v 1.35 2008/04/29 23:51:05 ad Exp $ */
|
||||
/* $NetBSD: nfs_export.c,v 1.36 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -75,7 +75,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.35 2008/04/29 23:51:05 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.36 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#include "opt_compat_netbsd.h"
|
||||
#include "opt_inet.h"
|
||||
@ -287,7 +287,7 @@ mountd_set_exports_list(const struct mountd_exports_list *mel, struct lwp *l)
|
||||
|
||||
out:
|
||||
netexport_wrunlock();
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nfs_vfsops.c,v 1.197 2008/04/29 18:18:09 ad Exp $ */
|
||||
/* $NetBSD: nfs_vfsops.c,v 1.198 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1995
|
||||
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.197 2008/04/29 18:18:09 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.198 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_compat_netbsd.h"
|
||||
@ -360,10 +360,11 @@ nfs_mountroot()
|
||||
*/
|
||||
mutex_enter(&mountlist_lock);
|
||||
CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
mp->mnt_iflag |= IMNT_ONLIST;
|
||||
mutex_exit(&mountlist_lock);
|
||||
rootvp = vp;
|
||||
mp->mnt_vnodecovered = NULLVP;
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
|
||||
/* Get root attributes (for the time). */
|
||||
error = VOP_GETATTR(vp, &attr, l->l_cred);
|
||||
@ -420,8 +421,8 @@ nfs_mount_diskless(ndmntp, mntname, mpp, vpp, l)
|
||||
error = mountnfs(&ndmntp->ndm_args, mp, m, mntname,
|
||||
ndmntp->ndm_args.hostname, vpp, l);
|
||||
if (error) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_destroy(mp);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
vfs_destroy(mp, false);
|
||||
printf("nfs_mountroot: mount %s failed: %d\n",
|
||||
mntname, error);
|
||||
} else
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fstypes.h,v 1.21 2007/10/10 20:42:32 ad Exp $ */
|
||||
/* $NetBSD: fstypes.h,v 1.22 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993
|
||||
@ -208,6 +208,7 @@ typedef struct fhandle fhandle_t;
|
||||
#define IMNT_DTYPE 0x00000040 /* returns d_type fields */
|
||||
#define IMNT_HAS_TRANS 0x00000080 /* supports transactions */
|
||||
#define IMNT_MPSAFE 0x00000100 /* file system code MP safe */
|
||||
#define IMNT_ONLIST 0x00000200 /* queued on 'mountlist' */
|
||||
|
||||
#define __MNT_FLAGS \
|
||||
__MNT_BASIC_FLAGS \
|
||||
@ -252,6 +253,7 @@ typedef struct fhandle fhandle_t;
|
||||
|
||||
#define __IMNT_FLAG_BITS \
|
||||
"\20" \
|
||||
"\30IMNT_ONLIST" \
|
||||
"\20IMNT_MPSAFE" \
|
||||
"\10IMNT_HAS_TRANS" \
|
||||
"\07IMNT_DTYPE" \
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mount.h,v 1.175 2008/04/29 23:51:05 ad Exp $ */
|
||||
/* $NetBSD: mount.h,v 1.176 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993
|
||||
@ -337,13 +337,13 @@ void vfs_unmountall(struct lwp *); /* unmount file systems */
|
||||
int vfs_busy(struct mount *, const krw_t);
|
||||
int vfs_trybusy(struct mount *, const krw_t, struct mount **);
|
||||
int vfs_rootmountalloc(const char *, const char *, struct mount **);
|
||||
void vfs_unbusy(struct mount *, bool);
|
||||
void vfs_unbusy(struct mount *, bool, struct mount **);
|
||||
int vfs_attach(struct vfsops *);
|
||||
int vfs_detach(struct vfsops *);
|
||||
void vfs_reinit(void);
|
||||
struct vfsops *vfs_getopsbyname(const char *);
|
||||
void vfs_delref(struct vfsops *);
|
||||
void vfs_destroy(struct mount *);
|
||||
void vfs_destroy(struct mount *, bool);
|
||||
void vfs_scrubvnlist(struct mount *);
|
||||
|
||||
int vfs_stdextattrctl(struct mount *, int, struct vnode *,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ext2fs_vfsops.c,v 1.132 2008/04/29 18:18:09 ad Exp $ */
|
||||
/* $NetBSD: ext2fs_vfsops.c,v 1.133 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993, 1994
|
||||
@ -65,7 +65,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.132 2008/04/29 18:18:09 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.133 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_compat_netbsd.h"
|
||||
@ -223,12 +223,13 @@ ext2fs_mountroot(void)
|
||||
}
|
||||
|
||||
if ((error = ext2fs_mountfs(rootvp, mp)) != 0) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_destroy(mp);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
vfs_destroy(mp, false);
|
||||
return (error);
|
||||
}
|
||||
mutex_enter(&mountlist_lock);
|
||||
CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
mp->mnt_iflag |= IMNT_ONLIST;
|
||||
mutex_exit(&mountlist_lock);
|
||||
ump = VFSTOUFS(mp);
|
||||
fs = ump->um_e2fs;
|
||||
@ -241,7 +242,7 @@ ext2fs_mountroot(void)
|
||||
sizeof(fs->e2fs.e2fs_fsmnt) - 1, 0);
|
||||
}
|
||||
(void)ext2fs_statvfs(mp, &mp->mnt_stat);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
setrootfstime((time_t)fs->e2fs.e2fs_wtime);
|
||||
return (0);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ffs_vfsops.c,v 1.224 2008/04/29 18:18:09 ad Exp $ */
|
||||
/* $NetBSD: ffs_vfsops.c,v 1.225 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993, 1994
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.224 2008/04/29 18:18:09 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.225 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ffs.h"
|
||||
@ -165,19 +165,20 @@ ffs_mountroot(void)
|
||||
return (error);
|
||||
}
|
||||
if ((error = ffs_mountfs(rootvp, mp, l)) != 0) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_destroy(mp);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
vfs_destroy(mp, false);
|
||||
return (error);
|
||||
}
|
||||
mutex_enter(&mountlist_lock);
|
||||
CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
mp->mnt_iflag |= IMNT_ONLIST;
|
||||
mutex_exit(&mountlist_lock);
|
||||
ump = VFSTOUFS(mp);
|
||||
fs = ump->um_fs;
|
||||
memset(fs->fs_fsmnt, 0, sizeof(fs->fs_fsmnt));
|
||||
(void)copystr(mp->mnt_stat.f_mntonname, fs->fs_fsmnt, MNAMELEN - 1, 0);
|
||||
(void)ffs_statvfs(mp, &mp->mnt_stat);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
setrootfstime((time_t)fs->fs_time);
|
||||
return (0);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lfs_bio.c,v 1.112 2008/04/29 23:51:05 ad Exp $ */
|
||||
/* $NetBSD: lfs_bio.c,v 1.113 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2008 The NetBSD Foundation, Inc.
|
||||
@ -60,7 +60,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.112 2008/04/29 23:51:05 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.113 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -581,7 +581,7 @@ lfs_flush(struct lfs *fs, int flags, int only_onefs)
|
||||
mutex_enter(&lfs_lock);
|
||||
lfs_flush_fs(fs, flags);
|
||||
mutex_exit(&lfs_lock);
|
||||
vfs_unbusy(fs->lfs_ivnode->v_mount, false);
|
||||
vfs_unbusy(fs->lfs_ivnode->v_mount, false, NULL);
|
||||
} else {
|
||||
locked_fakequeue_count = 0;
|
||||
mutex_enter(&mountlist_lock);
|
||||
@ -599,8 +599,7 @@ lfs_flush(struct lfs *fs, int flags, int only_onefs)
|
||||
mutex_exit(&lfs_lock);
|
||||
}
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
}
|
||||
mutex_exit(&mountlist_lock);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lfs_syscalls.c,v 1.130 2008/04/28 20:24:11 martin Exp $ */
|
||||
/* $NetBSD: lfs_syscalls.c,v 1.131 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007, 2008
|
||||
@ -61,7 +61,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.130 2008/04/28 20:24:11 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.131 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#ifndef LFS
|
||||
# define LFS /* for prototypes in syscallargs.h */
|
||||
@ -503,7 +503,7 @@ lfs_markv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov,
|
||||
|
||||
lfs_segunlock(fs);
|
||||
|
||||
vfs_unbusy(mntp, false);
|
||||
vfs_unbusy(mntp, false, NULL);
|
||||
if (error)
|
||||
return (error);
|
||||
else if (do_again)
|
||||
@ -532,7 +532,7 @@ err3:
|
||||
}
|
||||
|
||||
lfs_segunlock(fs);
|
||||
vfs_unbusy(mntp, false);
|
||||
vfs_unbusy(mntp, false, NULL);
|
||||
#ifdef DIAGNOSTIC
|
||||
if (numrefed != 0)
|
||||
panic("lfs_markv: numrefed=%d", numrefed);
|
||||
@ -822,7 +822,7 @@ lfs_bmapv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov, int blkcnt)
|
||||
panic("lfs_bmapv: numrefed=%d", numrefed);
|
||||
#endif
|
||||
|
||||
vfs_unbusy(mntp, false);
|
||||
vfs_unbusy(mntp, false, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -868,7 +868,7 @@ sys_lfs_segclean(struct lwp *l, const struct sys_lfs_segclean_args *uap, registe
|
||||
error = lfs_do_segclean(fs, segnum);
|
||||
lfs_segunlock(fs);
|
||||
KERNEL_UNLOCK_ONE(NULL);
|
||||
vfs_unbusy(mntp, false);
|
||||
vfs_unbusy(mntp, false, NULL);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lfs_vfsops.c,v 1.258 2008/04/29 23:51:05 ad Exp $ */
|
||||
/* $NetBSD: lfs_vfsops.c,v 1.259 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
|
||||
@ -61,7 +61,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.258 2008/04/29 23:51:05 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.259 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_lfs.h"
|
||||
@ -241,8 +241,7 @@ lfs_writerd(void *arg)
|
||||
}
|
||||
|
||||
mutex_enter(&mountlist_lock);
|
||||
nmp = CIRCLEQ_NEXT(mp, mnt_list);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, &nmp);
|
||||
}
|
||||
mutex_exit(&mountlist_lock);
|
||||
|
||||
@ -345,15 +344,16 @@ lfs_mountroot()
|
||||
return (error);
|
||||
}
|
||||
if ((error = lfs_mountfs(rootvp, mp, l))) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_destroy(mp);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
vfs_destroy(mp, false);
|
||||
return (error);
|
||||
}
|
||||
mutex_enter(&mountlist_lock);
|
||||
CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
mp->mnt_iflag |= IMNT_ONLIST;
|
||||
mutex_exit(&mountlist_lock);
|
||||
(void)lfs_statvfs(mp, &mp->mnt_stat);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
setrootfstime((time_t)(VFSTOUFS(mp)->um_lfs->lfs_tstamp));
|
||||
return (0);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mfs_vfsops.c,v 1.94 2008/04/29 23:51:05 ad Exp $ */
|
||||
/* $NetBSD: mfs_vfsops.c,v 1.95 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1990, 1993, 1994
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mfs_vfsops.c,v 1.94 2008/04/29 23:51:05 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mfs_vfsops.c,v 1.95 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_compat_netbsd.h"
|
||||
@ -199,21 +199,22 @@ mfs_mountroot(void)
|
||||
mfsp->mfs_refcnt = 1;
|
||||
bufq_alloc(&mfsp->mfs_buflist, "fcfs", 0);
|
||||
if ((error = ffs_mountfs(rootvp, mp, l)) != 0) {
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
bufq_free(mfsp->mfs_buflist);
|
||||
vfs_destroy(mp);
|
||||
vfs_destroy(mp, false);
|
||||
kmem_free(mfsp, sizeof(*mfsp));
|
||||
return (error);
|
||||
}
|
||||
mutex_enter(&mountlist_lock);
|
||||
CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
mp->mnt_iflag |= IMNT_ONLIST;
|
||||
mutex_exit(&mountlist_lock);
|
||||
mp->mnt_vnodecovered = NULLVP;
|
||||
ump = VFSTOUFS(mp);
|
||||
fs = ump->um_fs;
|
||||
(void) copystr(mp->mnt_stat.f_mntonname, fs->fs_fsmnt, MNAMELEN - 1, 0);
|
||||
(void)ffs_statvfs(mp, &mp->mnt_stat);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -380,7 +381,7 @@ mfs_start(struct mount *mp, int flags)
|
||||
mutex_enter(&mfs_lock);
|
||||
mfsp->mfs_refcnt++;
|
||||
mutex_exit(&mfs_lock);
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
|
||||
base = mfsp->mfs_baseoff;
|
||||
mutex_enter(&mfs_lock);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ufs_vfsops.c,v 1.37 2008/01/30 11:47:05 ad Exp $ */
|
||||
/* $NetBSD: ufs_vfsops.c,v 1.38 2008/04/30 12:49:17 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991, 1993, 1994
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.37 2008/01/30 11:47:05 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.38 2008/04/30 12:49:17 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ffs.h"
|
||||
@ -166,7 +166,7 @@ ufs_quotactl(struct mount *mp, int cmds, uid_t uid, void *arg)
|
||||
default:
|
||||
error = EINVAL;
|
||||
}
|
||||
vfs_unbusy(mp, false);
|
||||
vfs_unbusy(mp, false, NULL);
|
||||
return (error);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user