Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Restructure vdrain_vrele(). While it is not possib...
details: https://anonhg.NetBSD.org/src/rev/7157ce0b27b0
branches: trunk
changeset: 349722:7157ce0b27b0
user: hannken <hannken%NetBSD.org@localhost>
date: Tue Dec 20 10:02:21 2016 +0000
description:
Restructure vdrain_vrele(). While it is not possible for another thread
to lock this vnodes v_interlock -> vdrain_lock another vnode sharing the
v_interlock may lock this order.
While here, restore fstrans_start_nowait arg to FSTRANS_LAZY.
Fixes a deadlock seen recently on some pbulk environments.
diffstat:
sys/kern/vfs_vnode.c | 25 ++++++++++++-------------
1 files changed, 12 insertions(+), 13 deletions(-)
diffs (55 lines):
diff -r ea2abdc43a96 -r 7157ce0b27b0 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c Tue Dec 20 09:22:18 2016 +0000
+++ b/sys/kern/vfs_vnode.c Tue Dec 20 10:02:21 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnode.c,v 1.63 2016/12/14 15:49:35 hannken Exp $ */
+/* $NetBSD: vfs_vnode.c,v 1.64 2016/12/20 10:02:21 hannken Exp $ */
/*-
* Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.63 2016/12/14 15:49:35 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.64 2016/12/20 10:02:21 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -502,26 +502,25 @@
KASSERT(mutex_owned(&vdrain_lock));
+ mp = vp->v_mount;
+ if (fstrans_start_nowait(mp, FSTRANS_LAZY) != 0)
+ return;
+
/*
- * Safe to take v_interlock -- no other thread will
- * lock v_interlock -> vdrain_lock as usecount > 0.
+ * First remove the vnode from the vrele list.
+ * Put it on the last lru list, the last vrele()
+ * will put it back onto the right list before
+ * its v_usecount reaches zero.
*/
- mutex_enter(vp->v_interlock);
- mp = vp->v_mount;
- if (fstrans_start_nowait(mp, FSTRANS_SHARED) != 0) {
- mutex_exit(vp->v_interlock);
- return;
- }
-
- /* First put the vnode back onto its lru list. */
KASSERT(node->vi_lrulisthd == &lru_vrele_list);
TAILQ_REMOVE(node->vi_lrulisthd, node, vi_lrulist);
- node->vi_lrulisthd = lru_which(vp);
+ node->vi_lrulisthd = &lru_hold_list;
TAILQ_INSERT_TAIL(node->vi_lrulisthd, node, vi_lrulist);
vdrain_retry = true;
mutex_exit(&vdrain_lock);
+ mutex_enter(vp->v_interlock);
vrelel(vp, 0);
fstrans_done(mp);
Home |
Main Index |
Thread Index |
Old Index