Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/kern Pull up following revision(s) (requested by hann...



details:   https://anonhg.NetBSD.org/src/rev/8eef39049844
branches:  netbsd-8
changeset: 435229:8eef39049844
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Sep 01 06:04:16 2018 +0000

description:
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.

diffstat:

 sys/kern/vfs_bio.c |  28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)

diffs (71 lines):

diff -r f16832e18757 -r 8eef39049844 sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c        Sat Sep 01 06:02:13 2018 +0000
+++ b/sys/kern/vfs_bio.c        Sat Sep 01 06:04:16 2018 +0000
@@ -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 @@
  * 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 @@
        }
 
        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 @@
                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 */



Home | Main Index | Thread Index | Old Index