Module Name: src
Committed By: martin
Date: Sat Sep 1 06:04:16 UTC 2018
Modified Files:
src/sys/kern [netbsd-8]: vfs_bio.c
Log Message:
Pull up following revision(s) (requested by hannken in ticket #1000):
sys/kern/vfs_bio.c: revision 1.277
Make sure getnewbuf() runs bawrite() inside fstrans.
Use fstrans_start_nowait() to skip buffers that would block.
To generate a diff of this commit:
cvs rdiff -u -r1.273.2.1 -r1.273.2.2 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.273.2.1 src/sys/kern/vfs_bio.c:1.273.2.2
--- src/sys/kern/vfs_bio.c:1.273.2.1 Thu Nov 2 21:29:52 2017
+++ src/sys/kern/vfs_bio.c Sat Sep 1 06:04:16 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_bio.c,v 1.273.2.1 2017/11/02 21:29:52 snj Exp $ */
+/* $NetBSD: vfs_bio.c,v 1.273.2.2 2018/09/01 06:04:16 martin 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.273.2.1 2017/11/02 21:29:52 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.273.2.2 2018/09/01 06:04:16 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_bufcache.h"
@@ -1347,11 +1347,12 @@ allocbuf(buf_t *bp, int size, int preser
* Called with the buffer queues locked.
* Return buffer locked.
*/
-buf_t *
+static buf_t *
getnewbuf(int slpflag, int slptimeo, int from_bufq)
{
buf_t *bp;
struct vnode *vp;
+ struct mount *transmp = NULL;
start:
KASSERT(mutex_owned(&bufcache_lock));
@@ -1376,8 +1377,21 @@ getnewbuf(int slpflag, int slptimeo, int
}
KASSERT(mutex_owned(&bufcache_lock));
- if ((bp = TAILQ_FIRST(&bufqueues[BQ_AGE].bq_queue)) != NULL ||
- (bp = TAILQ_FIRST(&bufqueues[BQ_LRU].bq_queue)) != NULL) {
+ if ((bp = TAILQ_FIRST(&bufqueues[BQ_AGE].bq_queue)) != NULL) {
+ KASSERT(!ISSET(bp->b_oflags, BO_DELWRI));
+ } else {
+ TAILQ_FOREACH(bp, &bufqueues[BQ_LRU].bq_queue, b_freelist) {
+ if (ISSET(bp->b_cflags, BC_VFLUSH) ||
+ !ISSET(bp->b_oflags, BO_DELWRI))
+ break;
+ if (fstrans_start_nowait(bp->b_vp->v_mount) == 0) {
+ KASSERT(transmp == NULL);
+ transmp = bp->b_vp->v_mount;
+ break;
+ }
+ }
+ }
+ if (bp != NULL) {
KASSERT(!ISSET(bp->b_cflags, BC_BUSY) || ISSET(bp->b_cflags, BC_VFLUSH));
bremfree(bp);
@@ -1431,10 +1445,14 @@ getnewbuf(int slpflag, int slptimeo, int
SET(bp->b_cflags, BC_AGE);
mutex_exit(&bufcache_lock);
bawrite(bp);
+ KASSERT(transmp != NULL);
+ fstrans_done(transmp);
mutex_enter(&bufcache_lock);
return (NULL);
}
+ KASSERT(transmp == NULL);
+
vp = bp->b_vp;
/* clear out various other fields */