Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/raidframe Remove the component buffer bits, now that...



details:   https://anonhg.NetBSD.org/src/rev/d821bfd452b5
branches:  trunk
changeset: 586983:d821bfd452b5
user:      oster <oster%NetBSD.org@localhost>
date:      Sat Jan 07 16:08:44 2006 +0000

description:
Remove the component buffer bits, now that I know there is a
"private" structure in struct buf that can be used to keep track of
the request associated with this buffer (the buffer used here is one
allocated from rf_CreateDiskQueueData(), so it's ours to do with what
we please).  Shrinks code a little, reduces the run-time memory
footprint a bit, and simplifies both rf_DispatchKernelIO() and
KernelWakeupFunc().

Thanks to yamt for his "why is rf_DispatchKernelIO using another buf"
question which prompted me to revisit this code.

diffstat:

 sys/dev/raidframe/rf_netbsd.h      |   3 +-
 sys/dev/raidframe/rf_netbsdkintf.c |  64 ++++++-------------------------------
 2 files changed, 12 insertions(+), 55 deletions(-)

diffs (180 lines):

diff -r a0ab2437a955 -r d821bfd452b5 sys/dev/raidframe/rf_netbsd.h
--- a/sys/dev/raidframe/rf_netbsd.h     Sat Jan 07 14:19:51 2006 +0000
+++ b/sys/dev/raidframe/rf_netbsd.h     Sat Jan 07 16:08:44 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsd.h,v 1.25 2005/12/11 12:23:37 christos Exp $  */
+/*     $NetBSD: rf_netbsd.h,v 1.26 2006/01/07 16:08:44 oster Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -68,7 +68,6 @@
        struct pool asmap;       /* Access Stripe Map */
        struct pool asmhle;      /* Access Stripe Map Header List Elements */
        struct pool callback;    /* Callback descriptors */
-       struct pool cbuf;        /* Component buffers */
        struct pool dagh;        /* DAG headers */
        struct pool dagnode;     /* DAG nodes */
        struct pool daglist;     /* DAG lists */
diff -r a0ab2437a955 -r d821bfd452b5 sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Sat Jan 07 14:19:51 2006 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Sat Jan 07 16:08:44 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.193 2006/01/04 04:56:41 oster Exp $       */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.194 2006/01/07 16:08:44 oster Exp $       */
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -146,7 +146,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.193 2006/01/04 04:56:41 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.194 2006/01/07 16:08:44 oster Exp $");
 
 #include <sys/param.h>
 #include <sys/errno.h>
@@ -233,16 +233,6 @@
        nostop, notty, nopoll, nommap, nokqfilter, D_DISK
 };
 
-/*
- * Pilfered from ccd.c
- */
-
-struct raidbuf {
-       struct buf rf_buf;      /* new I/O buf.  MUST BE FIRST!!! */
-       struct buf *rf_obp;     /* ptr. to original I/O buf */
-       RF_DiskQueueData_t *req;/* the request that this was part of.. */
-};
-
 /* XXX Not sure if the following should be replacing the raidPtrs above,
    or if it should be used in conjunction with that...
 */
@@ -358,11 +348,6 @@
                panic("raidPtrs is NULL!!");
        }
 
-       /* Initialize the component buffer pool. */
-       rf_pool_init(&rf_pools.cbuf, sizeof(struct raidbuf),
-                    "raidpl", num * RAIDOUTSTANDING,
-                    2 * num * RAIDOUTSTANDING);
-
        rf_mutex_init(&rf_sparet_wait_mutex);
 
        rf_sparet_wait_queue = rf_sparet_resp_queue = NULL;
@@ -1804,7 +1789,6 @@
 {
        int     op = (req->type == RF_IO_TYPE_READ) ? B_READ : B_WRITE;
        struct buf *bp;
-       struct raidbuf *raidbp = NULL;
 
        req->queue = queue;
 
@@ -1830,21 +1814,12 @@
                bp->b_error = 0;
        }
 #endif
-       raidbp = pool_get(&rf_pools.cbuf, PR_NOWAIT);
-       if (raidbp == NULL) {
-               bp->b_flags |= B_ERROR;
-               bp->b_error = ENOMEM;
-               return (ENOMEM);
-       }
-       BUF_INIT(&raidbp->rf_buf);
 
        /*
         * context for raidiodone
         */
-       raidbp->rf_obp = bp;
-       raidbp->req = req;
-
-       BIO_COPYPRIO(&raidbp->rf_buf, bp);
+
+       bp->b_fspriv.bf_private = req;
 
        switch (req->type) {
        case RF_IO_TYPE_NOP:    /* used primarily to unlock a locked queue */
@@ -1856,7 +1831,7 @@
 
                /* XXX need to glue the original buffer into this??  */
 
-               KernelWakeupFunc(&raidbp->rf_buf);
+               KernelWakeupFunc(bp);
                break;
 
        case RF_IO_TYPE_READ:
@@ -1866,7 +1841,7 @@
                        RF_ETIMER_START(req->tracerec->timer);
                }
 #endif
-               InitBP(&raidbp->rf_buf, queue->rf_cinfo->ci_vp,
+               InitBP(bp, queue->rf_cinfo->ci_vp,
                    op | bp->b_flags, queue->rf_cinfo->ci_dev,
                    req->sectorOffset, req->numSector,
                    req->buf, KernelWakeupFunc, (void *) req,
@@ -1890,10 +1865,10 @@
                        (int) (req->numSector <<
                            queue->raidPtr->logBytesPerSector),
                        (int) queue->raidPtr->logBytesPerSector));
-               if ((raidbp->rf_buf.b_flags & B_READ) == 0) {
-                       raidbp->rf_buf.b_vp->v_numoutput++;
+               if ((bp->b_flags & B_READ) == 0) {
+                       bp->b_vp->v_numoutput++;
                }
-               VOP_STRATEGY(raidbp->rf_buf.b_vp, &raidbp->rf_buf);
+               VOP_STRATEGY(bp->b_vp, bp);
 
                break;
 
@@ -1908,32 +1883,18 @@
    kernel code.
  */
 static void
-KernelWakeupFunc(struct buf *vbp)
+KernelWakeupFunc(struct buf *bp)
 {
        RF_DiskQueueData_t *req = NULL;
        RF_DiskQueue_t *queue;
-       struct raidbuf *raidbp = (struct raidbuf *) vbp;
-       struct buf *bp;
        int s;
 
        s = splbio();
        db1_printf(("recovering the request queue:\n"));
-       req = raidbp->req;
-
-       bp = raidbp->rf_obp;
+       req = bp->b_fspriv.bf_private;
 
        queue = (RF_DiskQueue_t *) req->queue;
 
-       if (raidbp->rf_buf.b_flags & B_ERROR) {
-               bp->b_flags |= B_ERROR;
-               bp->b_error = raidbp->rf_buf.b_error ?
-                   raidbp->rf_buf.b_error : EIO;
-       }
-
-       /* XXX methinks this could be wrong... */
-#if 1
-       bp->b_resid = raidbp->rf_buf.b_resid;
-#endif
 #if RF_ACC_TRACE > 0
        if (req->tracerec) {
                RF_ETIMER_STOP(req->tracerec->timer);
@@ -1945,7 +1906,6 @@
                RF_UNLOCK_MUTEX(rf_tracing_mutex);
        }
 #endif
-       bp->b_bcount = raidbp->rf_buf.b_bcount; /* XXXX ?? */
 
        /* XXX Ok, let's get aggressive... If B_ERROR is set, let's go
         * ballistic, and mark the component as hosed... */
@@ -1975,8 +1935,6 @@
 
        }
 
-       pool_put(&rf_pools.cbuf, raidbp);
-
        /* Fill in the error value */
 
        req->error = (bp->b_flags & B_ERROR) ? bp->b_error : 0;



Home | Main Index | Thread Index | Old Index