Extract vfs_unmountall1() from vfs_unmountall() for reuse.

This commit is contained in:
dyoung 2009-04-29 15:44:55 +00:00
parent f6e36a0172
commit dfec23a174
2 changed files with 20 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_subr.c,v 1.376 2009/04/29 01:03:43 dyoung Exp $ */
/* $NetBSD: vfs_subr.c,v 1.377 2009/04/29 15:44:55 dyoung Exp $ */
/*-
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@ -81,7 +81,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.376 2009/04/29 01:03:43 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.377 2009/04/29 15:44:55 dyoung Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@ -2245,12 +2245,18 @@ vfs_mountedon(vnode_t *vp)
*/
bool
vfs_unmountall(struct lwp *l)
{
printf("unmounting file systems...");
return vfs_unmountall1(l, true, true);
}
bool
vfs_unmountall1(struct lwp *l, bool force, bool verbose)
{
struct mount *mp, *nmp;
bool any_error, progress;
int error;
printf("unmounting file systems...");
for (any_error = false, mp = CIRCLEQ_LAST(&mountlist);
!CIRCLEQ_EMPTY(&mountlist);
mp = nmp) {
@ -2260,16 +2266,19 @@ vfs_unmountall(struct lwp *l)
mp->mnt_stat.f_mntonname, mp->mnt_stat.f_mntfromname);
#endif
atomic_inc_uint(&mp->mnt_refcnt);
if ((error = dounmount(mp, MNT_FORCE, l)) == 0)
if ((error = dounmount(mp, force ? MNT_FORCE : 0, l)) == 0)
progress = true;
else {
printf("unmount of %s failed with error %d\n",
mp->mnt_stat.f_mntonname, error);
if (verbose) {
printf("unmount of %s failed with error %d\n",
mp->mnt_stat.f_mntonname, error);
}
any_error = true;
}
}
printf(" done\n");
if (any_error)
if (verbose)
printf(" done\n");
if (any_error && verbose)
printf("WARNING: some file systems would not unmount\n");
return progress;
}
@ -2283,9 +2292,7 @@ vfs_shutdown(void)
struct lwp *l;
/* XXX we're certainly not running in lwp0's context! */
l = curlwp;
if (l == NULL)
l = &lwp0;
l = (curlwp == NULL) ? &lwp0 : curlwp;
printf("syncing disks... ");

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount.h,v 1.188 2009/04/29 10:46:46 martin Exp $ */
/* $NetBSD: mount.h,v 1.189 2009/04/29 15:44:55 dyoung Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@ -390,6 +390,7 @@ int vfs_mountedon(struct vnode *);/* is a vfs mounted on vp */
int vfs_mountroot(void);
void vfs_shutdown(void); /* unmount and sync file systems */
bool vfs_unmountall(struct lwp *); /* unmount file systems */
bool vfs_unmountall1(struct lwp *, bool, bool);
int vfs_busy(struct mount *, struct mount **);
int vfs_rootmountalloc(const char *, const char *, struct mount **);
void vfs_unbusy(struct mount *, bool, struct mount **);