Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Fix locking so we don't release the lock between th...



details:   https://anonhg.NetBSD.org/src/rev/0cbee16f3e4f
branches:  trunk
changeset: 820016:0cbee16f3e4f
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon Dec 26 23:15:15 2016 +0000

description:
Fix locking so we don't release the lock between the time we check the
tailq (for being non-empty) and the time we remove an entry.

diffstat:

 sys/kern/vfs_bio.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (40 lines):

diff -r 86c45e675242 -r 0cbee16f3e4f sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c        Mon Dec 26 23:12:33 2016 +0000
+++ b/sys/kern/vfs_bio.c        Mon Dec 26 23:15:15 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_bio.c,v 1.264 2016/12/26 23:12:33 pgoyette Exp $   */
+/*     $NetBSD: vfs_bio.c,v 1.265 2016/12/26 23:15:15 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.264 2016/12/26 23:12:33 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.265 2016/12/26 23:15:15 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bufcache.h"
@@ -1647,17 +1647,20 @@
 
        ci = curcpu();
 
+       s = splvm();
        while (!TAILQ_EMPTY(&ci->ci_data.cpu_biodone)) {
                KASSERT(curcpu() == ci);
 
-               s = splvm();
                bp = TAILQ_FIRST(&ci->ci_data.cpu_biodone);
                TAILQ_REMOVE(&ci->ci_data.cpu_biodone, bp, b_actq);
                splx(s);
 
                KERNHIST_LOG(biohist, "bp=%p", bp, 0, 0, 0);
                biodone2(bp);
+
+               s = splvm();
        }
+       splx(s);
 }
 
 /*



Home | Main Index | Thread Index | Old Index