Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/lfs Switch lfs_flush() and lfs_writerd() to mountlis...
details: https://anonhg.NetBSD.org/src/rev/44a539883bd1
branches: trunk
changeset: 352878:44a539883bd1
user: hannken <hannken%NetBSD.org@localhost>
date: Thu Apr 13 09:57:28 2017 +0000
description:
Switch lfs_flush() and lfs_writerd() to mountlist iterator.
diffstat:
sys/ufs/lfs/lfs_bio.c | 18 +++++++-----------
sys/ufs/lfs/lfs_vfsops.c | 27 +++++++++------------------
2 files changed, 16 insertions(+), 29 deletions(-)
diffs (144 lines):
diff -r 6b9869b017ff -r 44a539883bd1 sys/ufs/lfs/lfs_bio.c
--- a/sys/ufs/lfs/lfs_bio.c Thu Apr 13 09:54:18 2017 +0000
+++ b/sys/ufs/lfs/lfs_bio.c Thu Apr 13 09:57:28 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_bio.c,v 1.137 2017/04/01 17:34:21 maya Exp $ */
+/* $NetBSD: lfs_bio.c,v 1.138 2017/04/13 09:57:28 hannken 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.137 2017/04/01 17:34:21 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.138 2017/04/13 09:57:28 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -514,7 +514,8 @@
lfs_flush(struct lfs *fs, int flags, int only_onefs)
{
extern u_int64_t locked_fakequeue_count;
- struct mount *mp, *nmp;
+ mount_iterator_t *iter;
+ struct mount *mp;
struct lfs *tfs;
KASSERT(mutex_owned(&lfs_lock));
@@ -543,12 +544,8 @@
vfs_unbusy(fs->lfs_ivnode->v_mount, false, NULL);
} else {
locked_fakequeue_count = 0;
- mutex_enter(&mountlist_lock);
- for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
- if (vfs_busy(mp, &nmp)) {
- DLOG((DLOG_FLUSH, "lfs_flush: fs vfs_busy\n"));
- continue;
- }
+ mountlist_iterator_init(&iter);
+ while ((mp = mountlist_iterator_next(iter)) != NULL) {
if (strncmp(&mp->mnt_stat.f_fstypename[0], MOUNT_LFS,
sizeof(mp->mnt_stat.f_fstypename)) == 0) {
tfs = VFSTOULFS(mp)->um_lfs;
@@ -556,9 +553,8 @@
lfs_flush_fs(tfs, flags);
mutex_exit(&lfs_lock);
}
- vfs_unbusy(mp, false, &nmp);
}
- mutex_exit(&mountlist_lock);
+ mountlist_iterator_destroy(iter);
}
LFS_DEBUG_COUNTLOCKED("flush");
wakeup(&lfs_subsys_pages);
diff -r 6b9869b017ff -r 44a539883bd1 sys/ufs/lfs/lfs_vfsops.c
--- a/sys/ufs/lfs/lfs_vfsops.c Thu Apr 13 09:54:18 2017 +0000
+++ b/sys/ufs/lfs/lfs_vfsops.c Thu Apr 13 09:57:28 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_vfsops.c,v 1.356 2017/04/01 17:34:21 maya Exp $ */
+/* $NetBSD: lfs_vfsops.c,v 1.357 2017/04/13 09:57:28 hannken 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.356 2017/04/01 17:34:21 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.357 2017/04/13 09:57:28 hannken Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@@ -387,11 +387,11 @@
static void
lfs_writerd(void *arg)
{
- struct mount *mp, *nmp;
+ mount_iterator_t *iter;
+ struct mount *mp;
struct lfs *fs;
struct vfsops *vfs = NULL;
int fsflags;
- int skipc;
int lfsc;
int wrote_something = 0;
@@ -446,14 +446,9 @@
* Look through the list of LFSs to see if any of them
* have requested pageouts.
*/
- mutex_enter(&mountlist_lock);
+ mountlist_iterator_init(&iter);
lfsc = 0;
- skipc = 0;
- for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
- if (vfs_busy(mp, &nmp)) {
- ++skipc;
- continue;
- }
+ while ((mp = mountlist_iterator_next(iter)) != NULL) {
KASSERT(!mutex_owned(&lfs_lock));
if (strncmp(mp->mnt_stat.f_fstypename, MOUNT_LFS,
sizeof(mp->mnt_stat.f_fstypename)) == 0) {
@@ -468,7 +463,6 @@
if (lfs_sb_getnextseg(fs) < lfs_sb_getcurseg(fs) && fs->lfs_nowrap) {
/* Don't try to write if we're suspended */
mutex_exit(&lfs_lock);
- vfs_unbusy(mp, false, &nmp);
continue;
}
if (LFS_STARVED_FOR_SEGS(fs)) {
@@ -476,7 +470,6 @@
DLOG((DLOG_FLUSH, "lfs_writerd: need cleaning before writing possible\n"));
lfs_wakeup_cleaner(fs);
- vfs_unbusy(mp, false, &nmp);
continue;
}
@@ -503,21 +496,19 @@
mutex_exit(&lfs_lock);
}
KASSERT(!mutex_owned(&lfs_lock));
- vfs_unbusy(mp, false, &nmp);
}
- if (lfsc + skipc == 0) {
+ if (lfsc == 0) {
mutex_enter(&lfs_lock);
lfs_writer_daemon = NULL;
mutex_exit(&lfs_lock);
- mutex_exit(&mountlist_lock);
+ mountlist_iterator_destroy(iter);
break;
}
- mutex_exit(&mountlist_lock);
+ mountlist_iterator_destroy(iter);
mutex_enter(&lfs_lock);
}
KASSERT(!mutex_owned(&lfs_lock));
- KASSERT(!mutex_owned(&mountlist_lock));
/* Give up our extra reference so the module can be unloaded. */
mutex_enter(&vfs_list_lock);
Home |
Main Index |
Thread Index |
Old Index