Remove the syncer dance from dounmount(). The syncer skips

unmounting file systems as they are suspended.

Remove now unused syncer_mutex.
This commit is contained in:
hannken 2017-05-24 09:52:59 +00:00
parent 1104a9e5a4
commit c2c49e1ed2
3 changed files with 5 additions and 39 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_mount.c,v 1.62 2017/05/17 12:45:03 hannken Exp $ */
/* $NetBSD: vfs_mount.c,v 1.63 2017/05/24 09:52:59 hannken Exp $ */
/*-
* Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.62 2017/05/17 12:45:03 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.63 2017/05/24 09:52:59 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -869,15 +869,8 @@ dounmount(struct mount *mp, int flags, struct lwp *l)
}
mountlist_iterator_destroy(iter);
/*
* XXX Freeze syncer. Must do this before locking the
* mount point. See dounmount() for details.
*/
mutex_enter(&syncer_mutex);
error = vfs_suspend(mp, 0);
if (error) {
mutex_exit(&syncer_mutex);
return error;
}
@ -887,7 +880,6 @@ dounmount(struct mount *mp, int flags, struct lwp *l)
mutex_enter(&mp->mnt_unmounting);
if (mp->mnt_busynest != 0) {
mutex_exit(&mp->mnt_unmounting);
mutex_exit(&syncer_mutex);
vfs_resume(mp);
return EBUSY;
}
@ -897,28 +889,12 @@ dounmount(struct mount *mp, int flags, struct lwp *l)
*/
if ((mp->mnt_iflag & IMNT_GONE) != 0) {
mutex_exit(&mp->mnt_unmounting);
mutex_exit(&syncer_mutex);
return ENOENT;
}
used_syncer = (mp->mnt_iflag & IMNT_ONWORKLIST) != 0;
used_extattr = mp->mnt_flag & MNT_EXTATTR;
/*
* XXX Syncer must be frozen when we get here. This should really
* be done on a per-mountpoint basis, but the syncer doesn't work
* like that.
*
* The caller of dounmount() must acquire syncer_mutex because
* the syncer itself acquires locks in syncer_mutex -> vfs_busy
* order, and we must preserve that order to avoid deadlock.
*
* So, if the file system did not use the syncer, now is
* the time to release the syncer_mutex.
*/
if (used_syncer == 0) {
mutex_exit(&syncer_mutex);
}
mp->mnt_iflag |= IMNT_UNMOUNT;
mutex_enter(&mp->mnt_updating);
async = mp->mnt_flag & MNT_ASYNC;
@ -941,8 +917,6 @@ dounmount(struct mount *mp, int flags, struct lwp *l)
mp->mnt_flag |= async;
mutex_exit(&mp->mnt_updating);
vfs_resume(mp);
if (used_syncer)
mutex_exit(&syncer_mutex);
if (used_extattr) {
if (start_extattr(mp) != 0)
mp->mnt_flag &= ~MNT_EXTATTR;
@ -973,8 +947,6 @@ dounmount(struct mount *mp, int flags, struct lwp *l)
mountlist_remove(mp);
if (TAILQ_FIRST(&mp->mnt_vnodelist) != NULL)
panic("unmount: dangling vnode");
if (used_syncer)
mutex_exit(&syncer_mutex);
vfs_hooks_unmount(mp);
fstrans_unmount(mp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_subr.c,v 1.464 2017/05/07 08:26:58 hannken Exp $ */
/* $NetBSD: vfs_subr.c,v 1.465 2017/05/24 09:52:59 hannken Exp $ */
/*-
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.464 2017/05/07 08:26:58 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.465 2017/05/24 09:52:59 hannken Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@ -568,7 +568,6 @@ time_t dirdelay = 15; /* time to delay syncing directories */
time_t metadelay = 10; /* time to delay syncing metadata */
time_t lockdelay = 1; /* time to delay if locking fails */
kmutex_t syncer_mutex; /* used to freeze syncer, long term */
static kmutex_t syncer_data_lock; /* short term lock on data structs */
static int syncer_delayno = 0;
@ -590,7 +589,6 @@ vn_initialize_syncerd(void)
for (i = 0; i < syncer_last; i++)
TAILQ_INIT(&syncer_workitem_pending[i]);
mutex_init(&syncer_mutex, MUTEX_DEFAULT, IPL_NONE);
mutex_init(&syncer_data_lock, MUTEX_DEFAULT, IPL_NONE);
}
@ -767,8 +765,6 @@ sched_sync(void *arg)
bool synced;
for (;;) {
mutex_enter(&syncer_mutex);
starttime = time_second;
/*
@ -830,7 +826,6 @@ sched_sync(void *arg)
synced ? syncdelay : lockdelay);
}
}
mutex_exit(&syncer_mutex);
/*
* If it has taken us less than a second to process the

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount.h,v 1.226 2017/04/17 08:34:27 hannken Exp $ */
/* $NetBSD: mount.h,v 1.227 2017/05/24 09:52:59 hannken Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@ -458,7 +458,6 @@ struct vnode *vfs_vnode_iterator_next(struct vnode_iterator *,
/* Syncer */
extern int syncer_maxdelay;
extern kmutex_t syncer_mutex;
extern time_t syncdelay;
extern time_t filedelay;
extern time_t dirdelay;