Module Name:    src
Committed By:   ad
Date:           Sun Dec  8 20:35:23 UTC 2019

Modified Files:
        src/sys/kern: vfs_bio.c

Log Message:
For safety, cv_broadcast(&bp->b_busy) in more places where the buffer is
changing identity or moving from one vnode list to another.


To generate a diff of this commit:
cvs rdiff -u -r1.281 -r1.282 src/sys/kern/vfs_bio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vfs_bio.c
diff -u src/sys/kern/vfs_bio.c:1.281 src/sys/kern/vfs_bio.c:1.282
--- src/sys/kern/vfs_bio.c:1.281	Sun Dec  8 19:49:25 2019
+++ src/sys/kern/vfs_bio.c	Sun Dec  8 20:35:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_bio.c,v 1.281 2019/12/08 19:49:25 ad Exp $	*/
+/*	$NetBSD: vfs_bio.c,v 1.282 2019/12/08 20:35:23 ad Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.281 2019/12/08 19:49:25 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.282 2019/12/08 20:35:23 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bufcache.h"
@@ -896,6 +896,8 @@ bwrite(buf_t *bp)
 		mutex_enter(bp->b_objlock);
 		CLR(bp->b_oflags, BO_DONE | BO_DELWRI);
 		reassignbuf(bp, bp->b_vp);
+		/* Wake anyone trying to busy the buffer via vnode's lists. */
+		cv_broadcast(&bp->b_busy);
 		mutex_exit(&bufcache_lock);
 	} else {
 		curlwp->l_ru.ru_oublock++;
@@ -988,6 +990,8 @@ bdwrite(buf_t *bp)
 		SET(bp->b_oflags, BO_DELWRI);
 		curlwp->l_ru.ru_oublock++;
 		reassignbuf(bp, bp->b_vp);
+		/* Wake anyone trying to busy the buffer via vnode's lists. */
+		cv_broadcast(&bp->b_busy);
 		mutex_exit(&bufcache_lock);
 	} else {
 		mutex_enter(bp->b_objlock);
@@ -1411,6 +1415,9 @@ getnewbuf(int slpflag, int slptimeo, int
 
 		/* Buffer is no longer on free lists. */
 		SET(bp->b_cflags, BC_BUSY);
+
+		/* Wake anyone trying to lock the old identity. */
+		cv_broadcast(&bp->b_busy);
 	} else {
 		/*
 		 * XXX: !from_bufq should be removed.

Reply via email to