Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/dev/raidframe Pull up following revision(s) (requeste...



details:   https://anonhg.NetBSD.org/src/rev/7316a098f7d1
branches:  netbsd-9
changeset: 1002396:7316a098f7d1
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Oct 19 10:55:15 2021 +0000

description:
Pull up following revision(s) (requested by oster in ticket #1361):

        sys/dev/raidframe/rf_netbsd.h: revision 1.36 (via patch)
        sys/dev/raidframe/rf_diskqueue.c: revision 1.58
        sys/dev/raidframe/rf_diskqueue.c: revision 1.59

remove unnnecessary splbio() in rf_FreeDiskQueueData()

getiobuf() can return NULL if there are no IO buffers available.
RAIDframe can't deal with that, so create a dedicated pool of buffers
to use for IO.  PR_WAITOK is fine here, as we pre-allocate more than
we need to guarantee IO can make progress.  Tuning of pool still to
come.

diffstat:

 sys/dev/raidframe/rf_diskqueue.c |  46 +++++++++++++++++++++++----------------
 sys/dev/raidframe/rf_netbsd.h    |   3 +-
 2 files changed, 29 insertions(+), 20 deletions(-)

diffs (122 lines):

diff -r 47353fdc556c -r 7316a098f7d1 sys/dev/raidframe/rf_diskqueue.c
--- a/sys/dev/raidframe/rf_diskqueue.c  Fri Oct 15 15:15:52 2021 +0000
+++ b/sys/dev/raidframe/rf_diskqueue.c  Tue Oct 19 10:55:15 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_diskqueue.c,v 1.55 2019/02/10 17:13:33 christos Exp $       */
+/*     $NetBSD: rf_diskqueue.c,v 1.55.4.1 2021/10/19 10:55:15 martin Exp $     */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -66,7 +66,7 @@
  ****************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.55 2019/02/10 17:13:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.55.4.1 2021/10/19 10:55:15 martin Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 
@@ -84,6 +84,8 @@
 #include "rf_fifo.h"
 #include "rf_kintf.h"
 
+#include <sys/buf.h>
+
 static void rf_ShutdownDiskQueueSystem(void *);
 
 #ifndef RF_DEBUG_DISKQUEUE
@@ -147,10 +149,15 @@
 };
 #define NUM_DISK_QUEUE_TYPES (sizeof(diskqueuesw)/sizeof(RF_DiskQueueSW_t))
 
+
 #define RF_MAX_FREE_DQD 256
 #define RF_MIN_FREE_DQD  64
 
-#include <sys/buf.h>
+/* XXX: scale these... */
+#define RF_MAX_FREE_BUFIO 256
+#define RF_MIN_FREE_BUFIO  64
+
+
 
 /* configures a single disk queue */
 
@@ -189,6 +196,7 @@
 rf_ShutdownDiskQueueSystem(void *ignored)
 {
        pool_destroy(&rf_pools.dqd);
+       pool_destroy(&rf_pools.bufio);
 }
 
 int
@@ -197,6 +205,8 @@
 
        rf_pool_init(&rf_pools.dqd, sizeof(RF_DiskQueueData_t),
                     "rf_dqd_pl", RF_MIN_FREE_DQD, RF_MAX_FREE_DQD);
+       rf_pool_init(&rf_pools.bufio, sizeof(buf_t),
+                    "rf_bufio_pl", RF_MIN_FREE_BUFIO, RF_MAX_FREE_BUFIO);
        rf_ShutdownCreate(listp, rf_ShutdownDiskQueueSystem, NULL);
 
        return (0);
@@ -367,19 +377,20 @@
 {
        RF_DiskQueueData_t *p;
 
-       p = pool_get(&rf_pools.dqd, waitflag | PR_ZERO);
-       if (p == NULL)
-               return (NULL);
+       p = pool_get(&rf_pools.dqd, PR_WAITOK | PR_ZERO);
+       KASSERT(p != NULL);
 
-       if (waitflag == PR_WAITOK) {
-               p->bp = getiobuf(NULL, true);
-       } else {
-               p->bp = getiobuf(NULL, false);
-       }
-       if (p->bp == NULL) {
-               pool_put(&rf_pools.dqd, p);
-               return (NULL);
-       }
+       /* Obtain a buffer from our own pool.  It is possible for the
+          regular getiobuf() to run out of memory and return NULL.
+          We need to guarantee that never happens, as RAIDframe
+          doesn't have a good way to recover if memory allocation
+          fails here.
+       */
+       p->bp = pool_get(&rf_pools.bufio, PR_WAITOK | PR_ZERO);
+       KASSERT(p->bp != NULL);
+       
+       buf_init(p->bp);
+               
        SET(p->bp->b_cflags, BC_BUSY);  /* mark buffer busy */
 
        p->sectorOffset = ssect + rf_protectedSectors;
@@ -402,9 +413,6 @@
 void
 rf_FreeDiskQueueData(RF_DiskQueueData_t *p)
 {
-       int s;
-       s = splbio();           /* XXX protect only pool_put, or neither? */
-       putiobuf(p->bp);
+       pool_put(&rf_pools.bufio, p->bp);
        pool_put(&rf_pools.dqd, p);
-       splx(s);
 }
diff -r 47353fdc556c -r 7316a098f7d1 sys/dev/raidframe/rf_netbsd.h
--- a/sys/dev/raidframe/rf_netbsd.h     Fri Oct 15 15:15:52 2021 +0000
+++ b/sys/dev/raidframe/rf_netbsd.h     Tue Oct 19 10:55:15 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsd.h,v 1.33 2019/02/06 02:49:09 oster Exp $     */
+/*     $NetBSD: rf_netbsd.h,v 1.33.4.1 2021/10/19 10:55:15 martin Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -61,6 +61,7 @@
        struct pool asm_hdr;     /* Access Stripe Map Header */
        struct pool asmap;       /* Access Stripe Map */
        struct pool asmhle;      /* Access Stripe Map Header List Elements */
+       struct pool bufio;       /* Buffer IO Pool */
        struct pool callback;    /* Callback descriptors */
        struct pool dagh;        /* DAG headers */
        struct pool dagnode;     /* DAG nodes */



Home | Main Index | Thread Index | Old Index