summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1997-02-26 15:35:42 +0000
committerbde <bde@FreeBSD.org>1997-02-26 15:35:42 +0000
commitc19ef735579e7d3b9a6a71f96e59c54dd4fb9c47 (patch)
tree4cdd3e7e0223ce7b1dea21eae38c973b324cb076 /sys/kern
parent26d93ee7e17fd7b6270c426b888f5157872b7c62 (diff)
downloadFreeBSD-src-c19ef735579e7d3b9a6a71f96e59c54dd4fb9c47.zip
FreeBSD-src-c19ef735579e7d3b9a6a71f96e59c54dd4fb9c47.tar.gz
Fixed unmounting of the root fs. vfs_unmountroot() wasn't fully updated
to do Lite2 locking and vfs_unmountall() wasn't as simple as the Lite2 version.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_export.c60
-rw-r--r--sys/kern/vfs_subr.c60
2 files changed, 22 insertions, 98 deletions
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c
index 06a854a..7b91e63 100644
--- a/sys/kern/vfs_export.c
+++ b/sys/kern/vfs_export.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
- * $Id: vfs_subr.c,v 1.70 1997/02/22 09:39:34 peter Exp $
+ * $Id: vfs_subr.c,v 1.71 1997/02/25 19:33:23 bde Exp $
*/
/*
@@ -78,7 +78,6 @@ extern void printlockedvnodes __P((void));
static void vclean __P((struct vnode *vp, int flags, struct proc *p));
extern void vgonel __P((struct vnode *vp, struct proc *p));
unsigned long numvnodes;
-extern void vfs_unmountroot __P((struct mount *rootfs));
enum vtype iftovt_tab[16] = {
VNON, VFIFO, VCHR, VNON, VDIR, VNON, VBLK, VNON,
@@ -324,35 +323,6 @@ vattr_null(vap)
vap->va_vaflags = 0;
}
-void
-vfs_unmountroot(struct mount *rootfs)
-{
- struct proc *p = curproc; /* XXX */
- struct mount *mp = rootfs;
- int error;
-
- if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
- printf("failed to unmount root\n");
- return;
- }
- mp->mnt_flag |= MNT_UNMOUNT;
- vnode_pager_umount(mp); /* release cached vnodes */
- cache_purgevfs(mp); /* remove cache entries for this file sys */
-
- if ((error = VFS_SYNC(mp, MNT_WAIT, initproc->p_ucred, initproc)))
- printf("sync of root filesystem failed (%d)\n", error);
-
- if ((error = VFS_UNMOUNT(mp, MNT_FORCE, initproc))) {
- printf("unmount of root filesystem failed (");
- if (error == EBUSY)
- printf("BUSY)\n");
- else
- printf("%d)\n", error);
- }
- mp->mnt_flag &= ~MNT_UNMOUNT;
- vfs_unbusy(mp, p);
-}
-
/*
* Routines having to do with the management of the vnode table.
*/
@@ -1735,39 +1705,31 @@ vfs_mountedon(vp)
}
/*
- * Unmount all filesystems. The list is traversed in reverse order
- * of mounting to avoid dependencies. Should only be called by halt().
+ * Unmount all filesystems. The list is traversed in reverse order
+ * of mounting to avoid dependencies.
*/
void
vfs_unmountall()
{
- struct mount *mp, *nmp, *rootfs = NULL;
+ struct mount *mp, *nmp;
+ struct proc *p = initproc; /* XXX XXX should this be proc0? */
int error;
- /* unmount all but rootfs */
+ /*
+ * Since this only runs when rebooting, it is not interlocked.
+ */
for (mp = mountlist.cqh_last; mp != (void *)&mountlist; mp = nmp) {
nmp = mp->mnt_list.cqe_prev;
-
- if (mp->mnt_flag & MNT_ROOTFS) {
- rootfs = mp;
- continue;
- }
- error = dounmount(mp, MNT_FORCE, initproc);
+ error = dounmount(mp, MNT_FORCE, p);
if (error) {
- printf("unmount of %s failed (", mp->mnt_stat.f_mntonname);
+ printf("unmount of %s failed (",
+ mp->mnt_stat.f_mntonname);
if (error == EBUSY)
printf("BUSY)\n");
else
printf("%d)\n", error);
}
}
-
- /* and finally... */
- if (rootfs) {
- vfs_unmountroot(rootfs);
- } else {
- printf("no root filesystem\n");
- }
}
/*
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 06a854a..7b91e63 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
- * $Id: vfs_subr.c,v 1.70 1997/02/22 09:39:34 peter Exp $
+ * $Id: vfs_subr.c,v 1.71 1997/02/25 19:33:23 bde Exp $
*/
/*
@@ -78,7 +78,6 @@ extern void printlockedvnodes __P((void));
static void vclean __P((struct vnode *vp, int flags, struct proc *p));
extern void vgonel __P((struct vnode *vp, struct proc *p));
unsigned long numvnodes;
-extern void vfs_unmountroot __P((struct mount *rootfs));
enum vtype iftovt_tab[16] = {
VNON, VFIFO, VCHR, VNON, VDIR, VNON, VBLK, VNON,
@@ -324,35 +323,6 @@ vattr_null(vap)
vap->va_vaflags = 0;
}
-void
-vfs_unmountroot(struct mount *rootfs)
-{
- struct proc *p = curproc; /* XXX */
- struct mount *mp = rootfs;
- int error;
-
- if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
- printf("failed to unmount root\n");
- return;
- }
- mp->mnt_flag |= MNT_UNMOUNT;
- vnode_pager_umount(mp); /* release cached vnodes */
- cache_purgevfs(mp); /* remove cache entries for this file sys */
-
- if ((error = VFS_SYNC(mp, MNT_WAIT, initproc->p_ucred, initproc)))
- printf("sync of root filesystem failed (%d)\n", error);
-
- if ((error = VFS_UNMOUNT(mp, MNT_FORCE, initproc))) {
- printf("unmount of root filesystem failed (");
- if (error == EBUSY)
- printf("BUSY)\n");
- else
- printf("%d)\n", error);
- }
- mp->mnt_flag &= ~MNT_UNMOUNT;
- vfs_unbusy(mp, p);
-}
-
/*
* Routines having to do with the management of the vnode table.
*/
@@ -1735,39 +1705,31 @@ vfs_mountedon(vp)
}
/*
- * Unmount all filesystems. The list is traversed in reverse order
- * of mounting to avoid dependencies. Should only be called by halt().
+ * Unmount all filesystems. The list is traversed in reverse order
+ * of mounting to avoid dependencies.
*/
void
vfs_unmountall()
{
- struct mount *mp, *nmp, *rootfs = NULL;
+ struct mount *mp, *nmp;
+ struct proc *p = initproc; /* XXX XXX should this be proc0? */
int error;
- /* unmount all but rootfs */
+ /*
+ * Since this only runs when rebooting, it is not interlocked.
+ */
for (mp = mountlist.cqh_last; mp != (void *)&mountlist; mp = nmp) {
nmp = mp->mnt_list.cqe_prev;
-
- if (mp->mnt_flag & MNT_ROOTFS) {
- rootfs = mp;
- continue;
- }
- error = dounmount(mp, MNT_FORCE, initproc);
+ error = dounmount(mp, MNT_FORCE, p);
if (error) {
- printf("unmount of %s failed (", mp->mnt_stat.f_mntonname);
+ printf("unmount of %s failed (",
+ mp->mnt_stat.f_mntonname);
if (error == EBUSY)
printf("BUSY)\n");
else
printf("%d)\n", error);
}
}
-
- /* and finally... */
- if (rootfs) {
- vfs_unmountroot(rootfs);
- } else {
- printf("no root filesystem\n");
- }
}
/*
OpenPOWER on IntegriCloud