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_writer_daemon to use condvar instead ...
details: https://anonhg.NetBSD.org/src/rev/5969ee848682
branches: trunk
changeset: 352446:5969ee848682
user: maya <maya%NetBSD.org@localhost>
date: Sat Apr 01 17:34:21 2017 +0000
description:
Switch lfs_writer_daemon to use condvar instead of mtsleep.
track thread existence with struct lwp instead of pid + lid,
it's more useful from ddb.
diffstat:
sys/ufs/lfs/lfs_bio.c | 8 ++++----
sys/ufs/lfs/lfs_pages.c | 10 +++++-----
sys/ufs/lfs/lfs_vfsops.c | 24 ++++++++++++------------
sys/ufs/lfs/lfs_vnops.c | 10 +++++-----
4 files changed, 26 insertions(+), 26 deletions(-)
diffs (206 lines):
diff -r cd1de21b6306 -r 5969ee848682 sys/ufs/lfs/lfs_bio.c
--- a/sys/ufs/lfs/lfs_bio.c Sat Apr 01 17:19:40 2017 +0000
+++ b/sys/ufs/lfs/lfs_bio.c Sat Apr 01 17:34:21 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_bio.c,v 1.136 2017/03/13 14:24:20 riastradh Exp $ */
+/* $NetBSD: lfs_bio.c,v 1.137 2017/04/01 17:34:21 maya 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.136 2017/03/13 14:24:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.137 2017/04/01 17:34:21 maya Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -583,7 +583,7 @@
int error;
struct lfs *fs;
struct inode *ip;
- extern pid_t lfs_writer_daemon;
+ extern kcondvar_t lfs_writerd_cv;
error = 0;
ip = VTOI(vp);
@@ -660,7 +660,7 @@
* still might want to be flushed.
*/
++fs->lfs_pdflush;
- wakeup(&lfs_writer_daemon);
+ cv_broadcast(&lfs_writerd_cv);
}
while (locked_queue_count + INOCOUNT(fs) >= LFS_WAIT_BUFS ||
diff -r cd1de21b6306 -r 5969ee848682 sys/ufs/lfs/lfs_pages.c
--- a/sys/ufs/lfs/lfs_pages.c Sat Apr 01 17:19:40 2017 +0000
+++ b/sys/ufs/lfs/lfs_pages.c Sat Apr 01 17:34:21 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_pages.c,v 1.10 2017/03/30 09:10:08 hannken Exp $ */
+/* $NetBSD: lfs_pages.c,v 1.11 2017/04/01 17:34:21 maya Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.10 2017/03/30 09:10:08 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.11 2017/04/01 17:34:21 maya Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -103,7 +103,7 @@
#include <ufs/lfs/lfs_kernel.h>
#include <ufs/lfs/lfs_extern.h>
-extern pid_t lfs_writer_daemon;
+extern kcondvar_t lfs_writerd_cv;
static int check_dirty(struct lfs *, struct vnode *, off_t, off_t, off_t, int, int, struct vm_page **);
@@ -691,8 +691,8 @@
if (!(ip->i_flags & IN_PAGING)) {
ip->i_flags |= IN_PAGING;
TAILQ_INSERT_TAIL(&fs->lfs_pchainhd, ip, i_lfs_pchain);
- }
- wakeup(&lfs_writer_daemon);
+ }
+ cv_broadcast(&lfs_writerd_cv);
mutex_exit(&lfs_lock);
preempt();
KASSERT(!mutex_owned(vp->v_interlock));
diff -r cd1de21b6306 -r 5969ee848682 sys/ufs/lfs/lfs_vfsops.c
--- a/sys/ufs/lfs/lfs_vfsops.c Sat Apr 01 17:19:40 2017 +0000
+++ b/sys/ufs/lfs/lfs_vfsops.c Sat Apr 01 17:34:21 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_vfsops.c,v 1.355 2017/04/01 14:43:00 maya Exp $ */
+/* $NetBSD: lfs_vfsops.c,v 1.356 2017/04/01 17:34:21 maya 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.355 2017/04/01 14:43:00 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.356 2017/04/01 17:34:21 maya Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@@ -128,8 +128,9 @@
extern const struct vnodeopv_desc lfs_specop_opv_desc;
extern const struct vnodeopv_desc lfs_fifoop_opv_desc;
-pid_t lfs_writer_daemon = 0;
-lwpid_t lfs_writer_lid = 0;
+struct lwp * lfs_writer_daemon = NULL;
+kcondvar_t lfs_writerd_cv;
+
int lfs_do_flush = 0;
#ifdef LFS_KERNEL_RFW
int lfs_do_rfw = 0;
@@ -395,8 +396,8 @@
int wrote_something = 0;
mutex_enter(&lfs_lock);
- lfs_writer_daemon = curproc->p_pid;
- lfs_writer_lid = curlwp->l_lid;
+ KASSERTMSG(lfs_writer_daemon == NULL, "more than one LFS writer daemon");
+ lfs_writer_daemon = curlwp;
mutex_exit(&lfs_lock);
/* Take an extra reference to the LFS vfsops. */
@@ -406,9 +407,7 @@
for (;;) {
KASSERT(mutex_owned(&lfs_lock));
if (wrote_something == 0)
- mtsleep(&lfs_writer_daemon, PVM, "lfswriter", hz/10 + 1,
- &lfs_lock);
-
+ cv_timedwait(&lfs_writerd_cv, &lfs_lock, hz/10 + 1);
KASSERT(mutex_owned(&lfs_lock));
wrote_something = 0;
@@ -508,8 +507,7 @@
}
if (lfsc + skipc == 0) {
mutex_enter(&lfs_lock);
- lfs_writer_daemon = 0;
- lfs_writer_lid = 0;
+ lfs_writer_daemon = NULL;
mutex_exit(&lfs_lock);
mutex_exit(&mountlist_lock);
break;
@@ -557,6 +555,7 @@
memset(lfs_log, 0, sizeof(lfs_log));
#endif
mutex_init(&lfs_lock, MUTEX_DEFAULT, IPL_NONE);
+ cv_init(&lfs_writerd_cv, "lfswrite");
cv_init(&locked_queue_cv, "lfsbuf");
cv_init(&lfs_writing_cv, "lfsflush");
}
@@ -572,6 +571,7 @@
{
ulfs_done();
mutex_destroy(&lfs_lock);
+ cv_destroy(&lfs_writerd_cv);
cv_destroy(&locked_queue_cv);
cv_destroy(&lfs_writing_cv);
pool_destroy(&lfs_inode_pool);
@@ -1298,7 +1298,7 @@
/* Start the pagedaemon-anticipating daemon */
mutex_enter(&lfs_lock);
- if (lfs_writer_daemon == 0 && lfs_writer_lid == 0 &&
+ if (lfs_writer_daemon == NULL &&
kthread_create(PRI_BIO, 0, NULL,
lfs_writerd, NULL, NULL, "lfs_writer") != 0)
panic("fork lfs_writer");
diff -r cd1de21b6306 -r 5969ee848682 sys/ufs/lfs/lfs_vnops.c
--- a/sys/ufs/lfs/lfs_vnops.c Sat Apr 01 17:19:40 2017 +0000
+++ b/sys/ufs/lfs/lfs_vnops.c Sat Apr 01 17:34:21 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_vnops.c,v 1.309 2017/04/01 14:43:00 maya Exp $ */
+/* $NetBSD: lfs_vnops.c,v 1.310 2017/04/01 17:34:21 maya Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.309 2017/04/01 14:43:00 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.310 2017/04/01 17:34:21 maya Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -167,7 +167,7 @@
#include <ufs/lfs/lfs_kernel.h>
#include <ufs/lfs/lfs_extern.h>
-extern pid_t lfs_writer_daemon;
+extern kcondvar_t lfs_writerd_cv;
int lfs_ignore_lazy_sync = 1;
static int lfs_openextattr(void *v);
@@ -462,7 +462,7 @@
TAILQ_INSERT_TAIL(&fs->lfs_pchainhd, ip,
i_lfs_pchain);
}
- wakeup(&lfs_writer_daemon);
+ cv_broadcast(&lfs_writerd_cv);
mutex_exit(&lfs_lock);
}
return 0;
@@ -580,7 +580,7 @@
}
}
if (lfs_dirvcount > LFS_MAX_DIROP && fs->lfs_dirops == 0) {
- wakeup(&lfs_writer_daemon);
+ cv_broadcast(&lfs_writerd_cv);
mutex_exit(&lfs_lock);
preempt();
goto restart;
Home |
Main Index |
Thread Index |
Old Index