Annotation of src/sys/dev/raidframe/rf_diskqueue.c, revision 1.28

1.28    ! oster       1: /*     $NetBSD: rf_diskqueue.c,v 1.27 2003/12/30 21:59:03 oster Exp $  */
1.1       oster       2: /*
                      3:  * Copyright (c) 1995 Carnegie-Mellon University.
                      4:  * All rights reserved.
                      5:  *
                      6:  * Author: Mark Holland
                      7:  *
                      8:  * Permission to use, copy, modify and distribute this software and
                      9:  * its documentation is hereby granted, provided that both the copyright
                     10:  * notice and this permission notice appear in all copies of the
                     11:  * software, derivative works or modified versions, and any portions
                     12:  * thereof, and that both notices appear in supporting documentation.
                     13:  *
                     14:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     15:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
                     16:  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     17:  *
                     18:  * Carnegie Mellon requests users of this software to return to
                     19:  *
                     20:  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
                     21:  *  School of Computer Science
                     22:  *  Carnegie Mellon University
                     23:  *  Pittsburgh PA 15213-3890
                     24:  *
                     25:  * any improvements or extensions that they make and grant Carnegie the
                     26:  * rights to redistribute these changes.
                     27:  */
                     28: 
1.13      oster      29: /****************************************************************************
1.1       oster      30:  *
                     31:  * rf_diskqueue.c -- higher-level disk queue code
                     32:  *
                     33:  * the routines here are a generic wrapper around the actual queueing
1.6       oster      34:  * routines.  The code here implements thread scheduling, synchronization,
1.1       oster      35:  * and locking ops (see below) on top of the lower-level queueing code.
                     36:  *
1.13      oster      37:  * to support atomic RMW, we implement "locking operations".  When a
                     38:  * locking op is dispatched to the lower levels of the driver, the
                     39:  * queue is locked, and no further I/Os are dispatched until the queue
                     40:  * receives & completes a corresponding "unlocking operation".  This
                     41:  * code relies on the higher layers to guarantee that a locking op
                     42:  * will always be eventually followed by an unlocking op.  The model
                     43:  * is that the higher layers are structured so locking and unlocking
                     44:  * ops occur in pairs, i.e.  an unlocking op cannot be generated until
                     45:  * after a locking op reports completion.  There is no good way to
                     46:  * check to see that an unlocking op "corresponds" to the op that
                     47:  * currently has the queue locked, so we make no such attempt.  Since
                     48:  * by definition there can be only one locking op outstanding on a
                     49:  * disk, this should not be a problem.
                     50:  *
                     51:  * In the kernel, we allow multiple I/Os to be concurrently dispatched
                     52:  * to the disk driver.  In order to support locking ops in this
                     53:  * environment, when we decide to do a locking op, we stop dispatching
                     54:  * new I/Os and wait until all dispatched I/Os have completed before
                     55:  * dispatching the locking op.
                     56:  *
                     57:  * Unfortunately, the code is different in the 3 different operating
                     58:  * states (user level, kernel, simulator).  In the kernel, I/O is
                     59:  * non-blocking, and we have no disk threads to dispatch for us.
                     60:  * Therefore, we have to dispatch new I/Os to the scsi driver at the
                     61:  * time of enqueue, and also at the time of completion.  At user
                     62:  * level, I/O is blocking, and so only the disk threads may dispatch
                     63:  * I/Os.  Thus at user level, all we can do at enqueue time is enqueue
                     64:  * and wake up the disk thread to do the dispatch.
1.1       oster      65:  *
1.13      oster      66:  ****************************************************************************/
1.15      lukem      67: 
                     68: #include <sys/cdefs.h>
1.28    ! oster      69: __KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.27 2003/12/30 21:59:03 oster Exp $");
1.1       oster      70: 
1.14      oster      71: #include <dev/raidframe/raidframevar.h>
                     72: 
1.1       oster      73: #include "rf_threadstuff.h"
                     74: #include "rf_raid.h"
                     75: #include "rf_diskqueue.h"
                     76: #include "rf_alloclist.h"
                     77: #include "rf_acctrace.h"
                     78: #include "rf_etimer.h"
                     79: #include "rf_general.h"
                     80: #include "rf_debugprint.h"
                     81: #include "rf_shutdown.h"
                     82: #include "rf_cvscan.h"
                     83: #include "rf_sstf.h"
                     84: #include "rf_fifo.h"
1.11      oster      85: #include "rf_kintf.h"
1.1       oster      86: 
                     87: static void rf_ShutdownDiskQueueSystem(void *);
                     88: 
1.21      oster      89: #ifndef RF_DEBUG_DISKQUEUE
                     90: #define RF_DEBUG_DISKQUEUE 0
                     91: #endif
                     92: 
                     93: #if RF_DEBUG_DISKQUEUE
1.1       oster      94: #define Dprintf1(s,a)         if (rf_queueDebug) rf_debug_printf(s,(void *)((unsigned long)a),NULL,NULL,NULL,NULL,NULL,NULL,NULL)
                     95: #define Dprintf2(s,a,b)       if (rf_queueDebug) rf_debug_printf(s,(void *)((unsigned long)a),(void *)((unsigned long)b),NULL,NULL,NULL,NULL,NULL,NULL)
                     96: #define Dprintf3(s,a,b,c)     if (rf_queueDebug) rf_debug_printf(s,(void *)((unsigned long)a),(void *)((unsigned long)b),(void *)((unsigned long)c),NULL,NULL,NULL,NULL,NULL)
1.21      oster      97: #else
                     98: #define Dprintf1(s,a)
                     99: #define Dprintf2(s,a,b)
                    100: #define Dprintf3(s,a,b,c)
                    101: #endif
1.1       oster     102: 
1.13      oster     103: /*****************************************************************************
1.1       oster     104:  *
1.13      oster     105:  * the disk queue switch defines all the functions used in the
                    106:  * different queueing disciplines queue ID, init routine, enqueue
                    107:  * routine, dequeue routine
1.1       oster     108:  *
1.13      oster     109:  ****************************************************************************/
1.1       oster     110: 
1.22      jdolecek  111: static const RF_DiskQueueSW_t diskqueuesw[] = {
1.6       oster     112:        {"fifo",                /* FIFO */
                    113:                rf_FifoCreate,
                    114:                rf_FifoEnqueue,
                    115:                rf_FifoDequeue,
                    116:                rf_FifoPeek,
1.1       oster     117:        rf_FifoPromote},
                    118: 
1.6       oster     119:        {"cvscan",              /* cvscan */
                    120:                rf_CvscanCreate,
                    121:                rf_CvscanEnqueue,
                    122:                rf_CvscanDequeue,
                    123:                rf_CvscanPeek,
                    124:        rf_CvscanPromote},
                    125: 
                    126:        {"sstf",                /* shortest seek time first */
                    127:                rf_SstfCreate,
                    128:                rf_SstfEnqueue,
                    129:                rf_SstfDequeue,
                    130:                rf_SstfPeek,
1.1       oster     131:        rf_SstfPromote},
                    132: 
1.6       oster     133:        {"scan",                /* SCAN (two-way elevator) */
                    134:                rf_ScanCreate,
                    135:                rf_SstfEnqueue,
                    136:                rf_ScanDequeue,
                    137:                rf_ScanPeek,
1.1       oster     138:        rf_SstfPromote},
                    139: 
1.6       oster     140:        {"cscan",               /* CSCAN (one-way elevator) */
                    141:                rf_CscanCreate,
                    142:                rf_SstfEnqueue,
                    143:                rf_CscanDequeue,
                    144:                rf_CscanPeek,
1.1       oster     145:        rf_SstfPromote},
                    146: 
                    147: };
                    148: #define NUM_DISK_QUEUE_TYPES (sizeof(diskqueuesw)/sizeof(RF_DiskQueueSW_t))
                    149: 
1.24      oster     150: static struct pool rf_dqd_pool;
1.1       oster     151: #define RF_MAX_FREE_DQD 256
                    152: #define RF_DQD_INC       16
                    153: #define RF_DQD_INITIAL   64
                    154: 
                    155: #include <sys/buf.h>
                    156: 
1.6       oster     157: /* configures a single disk queue */
1.9       oster     158: 
1.7       oster     159: int 
1.27      oster     160: rf_ConfigureDiskQueue(RF_Raid_t *raidPtr, RF_DiskQueue_t *diskqueue,
                    161:                      RF_RowCol_t c, const RF_DiskQueueSW_t *p,
                    162:                      RF_SectorCount_t sectPerDisk, dev_t dev,
                    163:                      int maxOutstanding, RF_ShutdownList_t **listp,
                    164:                      RF_AllocListElem_t *clList)
1.6       oster     165: {
                    166:        diskqueue->col = c;
                    167:        diskqueue->qPtr = p;
                    168:        diskqueue->qHdr = (p->Create) (sectPerDisk, clList, listp);
                    169:        diskqueue->dev = dev;
                    170:        diskqueue->numOutstanding = 0;
                    171:        diskqueue->queueLength = 0;
                    172:        diskqueue->maxOutstanding = maxOutstanding;
                    173:        diskqueue->curPriority = RF_IO_NORMAL_PRIORITY;
                    174:        diskqueue->nextLockingOp = NULL;
                    175:        diskqueue->numWaiting = 0;
                    176:        diskqueue->flags = 0;
                    177:        diskqueue->raidPtr = raidPtr;
1.23      oster     178:        diskqueue->rf_cinfo = &raidPtr->raid_cinfo[c];
1.25      oster     179:        rf_mutex_init(&diskqueue->mutex);
1.26      oster     180:        diskqueue->cond = 0;
1.6       oster     181:        return (0);
1.1       oster     182: }
                    183: 
1.6       oster     184: static void 
1.27      oster     185: rf_ShutdownDiskQueueSystem(void *ignored)
1.6       oster     186: {
1.24      oster     187:        pool_destroy(&rf_dqd_pool);
1.1       oster     188: }
                    189: 
1.6       oster     190: int 
1.27      oster     191: rf_ConfigureDiskQueueSystem(RF_ShutdownList_t **listp)
1.6       oster     192: {
                    193:        int     rc;
                    194: 
1.24      oster     195:        pool_init(&rf_dqd_pool, sizeof(RF_DiskQueueData_t), 0, 0, 0,
                    196:                  "rf_dqd_pl", NULL);
                    197:        pool_sethiwat(&rf_dqd_pool, RF_MAX_FREE_DQD);
                    198:        pool_prime(&rf_dqd_pool, RF_DQD_INITIAL);
                    199: 
1.6       oster     200:        rc = rf_ShutdownCreate(listp, rf_ShutdownDiskQueueSystem, NULL);
                    201:        if (rc) {
1.18      oster     202:                rf_print_unable_to_add_shutdown( __FILE__, __LINE__, rc);
1.6       oster     203:                rf_ShutdownDiskQueueSystem(NULL);
                    204:                return (rc);
                    205:        }
1.24      oster     206: 
1.6       oster     207:        return (0);
                    208: }
                    209: 
                    210: int 
1.27      oster     211: rf_ConfigureDiskQueues(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
                    212:                       RF_Config_t *cfgPtr)
1.6       oster     213: {
1.23      oster     214:        RF_DiskQueue_t *diskQueues, *spareQueues;
1.22      jdolecek  215:        const RF_DiskQueueSW_t *p;
1.23      oster     216:        RF_RowCol_t r,c;
1.6       oster     217:        int     rc, i;
                    218: 
                    219:        raidPtr->maxQueueDepth = cfgPtr->maxOutstandingDiskReqs;
                    220: 
                    221:        for (p = NULL, i = 0; i < NUM_DISK_QUEUE_TYPES; i++) {
                    222:                if (!strcmp(diskqueuesw[i].queueType, cfgPtr->diskQueueType)) {
                    223:                        p = &diskqueuesw[i];
                    224:                        break;
                    225:                }
                    226:        }
                    227:        if (p == NULL) {
                    228:                RF_ERRORMSG2("Unknown queue type \"%s\".  Using %s\n", cfgPtr->diskQueueType, diskqueuesw[0].queueType);
                    229:                p = &diskqueuesw[0];
                    230:        }
1.10      oster     231:        raidPtr->qType = p;
1.23      oster     232: 
1.24      oster     233:        RF_MallocAndAdd(diskQueues, 
                    234:                        (raidPtr->numCol + RF_MAXSPARE) *
1.23      oster     235:                        sizeof(RF_DiskQueue_t), (RF_DiskQueue_t *), 
                    236:                        raidPtr->cleanupList);
                    237:        if (diskQueues == NULL)
1.6       oster     238:                return (ENOMEM);
                    239:        raidPtr->Queues = diskQueues;
1.23      oster     240: 
                    241:        for (c = 0; c < raidPtr->numCol; c++) {
                    242:                rc = rf_ConfigureDiskQueue(raidPtr, &diskQueues[c],
                    243:                                           c, p,
                    244:                                           raidPtr->sectorsPerDisk, 
                    245:                                           raidPtr->Disks[c].dev,
                    246:                                           cfgPtr->maxOutstandingDiskReqs, 
                    247:                                           listp, raidPtr->cleanupList);
                    248:                if (rc)
                    249:                        return (rc);
1.6       oster     250:        }
                    251: 
1.23      oster     252:        spareQueues = &raidPtr->Queues[raidPtr->numCol];
1.6       oster     253:        for (r = 0; r < raidPtr->numSpare; r++) {
1.9       oster     254:                rc = rf_ConfigureDiskQueue(raidPtr, &spareQueues[r],
1.23      oster     255:                                           raidPtr->numCol + r, p,
                    256:                                           raidPtr->sectorsPerDisk,
                    257:                                           raidPtr->Disks[raidPtr->numCol + r].dev,
                    258:                                           cfgPtr->maxOutstandingDiskReqs, listp,
                    259:                                           raidPtr->cleanupList);
1.6       oster     260:                if (rc)
                    261:                        return (rc);
                    262:        }
                    263:        return (0);
                    264: }
1.1       oster     265: /* Enqueue a disk I/O
                    266:  *
                    267:  * Unfortunately, we have to do things differently in the different
                    268:  * environments (simulator, user-level, kernel).
                    269:  * At user level, all I/O is blocking, so we have 1 or more threads/disk
                    270:  * and the thread that enqueues is different from the thread that dequeues.
                    271:  * In the kernel, I/O is non-blocking and so we'd like to have multiple
                    272:  * I/Os outstanding on the physical disks when possible.
                    273:  *
                    274:  * when any request arrives at a queue, we have two choices:
                    275:  *    dispatch it to the lower levels
                    276:  *    queue it up
                    277:  *
                    278:  * kernel rules for when to do what:
                    279:  *    locking request:  queue empty => dispatch and lock queue,
                    280:  *                      else queue it
                    281:  *    unlocking req  :  always dispatch it
                    282:  *    normal req     :  queue empty => dispatch it & set priority
                    283:  *                      queue not full & priority is ok => dispatch it
                    284:  *                      else queue it
                    285:  *
                    286:  * user-level rules:
                    287:  *    always enqueue.  In the special case of an unlocking op, enqueue
                    288:  *    in a special way that will cause the unlocking op to be the next
                    289:  *    thing dequeued.
                    290:  *
                    291:  * simulator rules:
                    292:  *    Do the same as at user level, with the sleeps and wakeups suppressed.
                    293:  */
1.6       oster     294: void 
1.27      oster     295: rf_DiskIOEnqueue(RF_DiskQueue_t *queue, RF_DiskQueueData_t *req, int pri)
1.6       oster     296: {
                    297:        RF_ETIMER_START(req->qtime);
                    298:        RF_ASSERT(req->type == RF_IO_TYPE_NOP || req->numSector);
                    299:        req->priority = pri;
                    300: 
1.21      oster     301: #if RF_DEBUG_DISKQUEUE
1.6       oster     302:        if (rf_queueDebug && (req->numSector == 0)) {
                    303:                printf("Warning: Enqueueing zero-sector access\n");
                    304:        }
1.21      oster     305: #endif
1.6       oster     306:        /*
                    307:          * kernel
                    308:          */
                    309:        RF_LOCK_QUEUE_MUTEX(queue, "DiskIOEnqueue");
                    310:        /* locking request */
                    311:        if (RF_LOCKING_REQ(req)) {
                    312:                if (RF_QUEUE_EMPTY(queue)) {
1.23      oster     313:                        Dprintf2("Dispatching pri %d locking op to c %d (queue empty)\n", pri, queue->col);
1.6       oster     314:                        RF_LOCK_QUEUE(queue);
                    315:                        rf_DispatchKernelIO(queue, req);
                    316:                } else {
                    317:                        queue->queueLength++;   /* increment count of number
                    318:                                                 * of requests waiting in this
                    319:                                                 * queue */
1.23      oster     320:                        Dprintf2("Enqueueing pri %d locking op to c %d (queue not empty)\n", pri, queue->col);
1.6       oster     321:                        req->queue = (void *) queue;
                    322:                        (queue->qPtr->Enqueue) (queue->qHdr, req, pri);
                    323:                }
                    324:        }
                    325:        /* unlocking request */
                    326:        else
                    327:                if (RF_UNLOCKING_REQ(req)) {    /* we'll do the actual unlock
                    328:                                                 * when this I/O completes */
1.23      oster     329:                        Dprintf2("Dispatching pri %d unlocking op to c %d\n", pri, queue->col);
1.6       oster     330:                        RF_ASSERT(RF_QUEUE_LOCKED(queue));
                    331:                        rf_DispatchKernelIO(queue, req);
                    332:                }
                    333:        /* normal request */
                    334:                else
                    335:                        if (RF_OK_TO_DISPATCH(queue, req)) {
1.23      oster     336:                                Dprintf2("Dispatching pri %d regular op to c %d (ok to dispatch)\n", pri, queue->col);
1.6       oster     337:                                rf_DispatchKernelIO(queue, req);
                    338:                        } else {
                    339:                                queue->queueLength++;   /* increment count of
                    340:                                                         * number of requests
                    341:                                                         * waiting in this queue */
1.23      oster     342:                                Dprintf2("Enqueueing pri %d regular op to c %d (not ok to dispatch)\n", pri, queue->col);
1.6       oster     343:                                req->queue = (void *) queue;
                    344:                                (queue->qPtr->Enqueue) (queue->qHdr, req, pri);
                    345:                        }
                    346:        RF_UNLOCK_QUEUE_MUTEX(queue, "DiskIOEnqueue");
1.1       oster     347: }
1.6       oster     348: 
1.1       oster     349: 
                    350: /* get the next set of I/Os started, kernel version only */
1.6       oster     351: void 
1.27      oster     352: rf_DiskIOComplete(RF_DiskQueue_t *queue, RF_DiskQueueData_t *req, int status)
1.6       oster     353: {
                    354:        int     done = 0;
                    355: 
                    356:        RF_LOCK_QUEUE_MUTEX(queue, "DiskIOComplete");
                    357: 
                    358:        /* unlock the queue: (1) after an unlocking req completes (2) after a
                    359:         * locking req fails */
                    360:        if (RF_UNLOCKING_REQ(req) || (RF_LOCKING_REQ(req) && status)) {
1.23      oster     361:                Dprintf1("DiskIOComplete: unlocking queue at c %d\n", queue->col);
1.20      oster     362:                RF_ASSERT(RF_QUEUE_LOCKED(queue));
1.6       oster     363:                RF_UNLOCK_QUEUE(queue);
                    364:        }
                    365:        queue->numOutstanding--;
                    366:        RF_ASSERT(queue->numOutstanding >= 0);
                    367: 
                    368:        /* dispatch requests to the disk until we find one that we can't. */
                    369:        /* no reason to continue once we've filled up the queue */
                    370:        /* no reason to even start if the queue is locked */
                    371: 
                    372:        while (!done && !RF_QUEUE_FULL(queue) && !RF_QUEUE_LOCKED(queue)) {
                    373:                if (queue->nextLockingOp) {
                    374:                        req = queue->nextLockingOp;
                    375:                        queue->nextLockingOp = NULL;
1.23      oster     376:                        Dprintf2("DiskIOComplete: a pri %d locking req was pending at c %d\n", req->priority, queue->col);
1.6       oster     377:                } else {
                    378:                        req = (queue->qPtr->Dequeue) (queue->qHdr);
                    379:                        if (req != NULL) {
1.23      oster     380:                                Dprintf2("DiskIOComplete: extracting pri %d req from queue at c %d\n", req->priority, queue->col);
1.6       oster     381:                        } else {
                    382:                                Dprintf1("DiskIOComplete: no more requests to extract.\n", "");
                    383:                        }
                    384:                }
                    385:                if (req) {
                    386:                        queue->queueLength--;   /* decrement count of number
                    387:                                                 * of requests waiting in this
                    388:                                                 * queue */
                    389:                        RF_ASSERT(queue->queueLength >= 0);
                    390:                }
                    391:                if (!req)
                    392:                        done = 1;
                    393:                else
                    394:                        if (RF_LOCKING_REQ(req)) {
                    395:                                if (RF_QUEUE_EMPTY(queue)) {    /* dispatch it */
1.23      oster     396:                                        Dprintf2("DiskIOComplete: dispatching pri %d locking req to c %d (queue empty)\n", req->priority, queue->col);
1.6       oster     397:                                        RF_LOCK_QUEUE(queue);
                    398:                                        rf_DispatchKernelIO(queue, req);
                    399:                                        done = 1;
                    400:                                } else {        /* put it aside to wait for
                    401:                                                 * the queue to drain */
1.23      oster     402:                                        Dprintf2("DiskIOComplete: postponing pri %d locking req to c %d\n", req->priority, queue->col);
1.6       oster     403:                                        RF_ASSERT(queue->nextLockingOp == NULL);
                    404:                                        queue->nextLockingOp = req;
                    405:                                        done = 1;
                    406:                                }
                    407:                        } else
                    408:                                if (RF_UNLOCKING_REQ(req)) {    /* should not happen:
                    409:                                                                 * unlocking ops should
                    410:                                                                 * not get queued */
                    411:                                        RF_ASSERT(RF_QUEUE_LOCKED(queue));      /* support it anyway for
                    412:                                                                                 * the future */
1.23      oster     413:                                        Dprintf2("DiskIOComplete: dispatching pri %d unl req to c %d (SHOULD NOT SEE THIS)\n", req->priority, queue->col);
1.6       oster     414:                                        rf_DispatchKernelIO(queue, req);
                    415:                                        done = 1;
                    416:                                } else
                    417:                                        if (RF_OK_TO_DISPATCH(queue, req)) {
1.23      oster     418:                                                Dprintf2("DiskIOComplete: dispatching pri %d regular req to c %d (ok to dispatch)\n", req->priority, queue->col);
1.6       oster     419:                                                rf_DispatchKernelIO(queue, req);
                    420:                                        } else {        /* we can't dispatch it,
                    421:                                                         * so just re-enqueue
                    422:                                                         * it.  */
                    423:                                                /* potential trouble here if
                    424:                                                 * disk queues batch reqs */
1.23      oster     425:                                                Dprintf2("DiskIOComplete: re-enqueueing pri %d regular req to c %d\n", req->priority, queue->col);
1.6       oster     426:                                                queue->queueLength++;
                    427:                                                (queue->qPtr->Enqueue) (queue->qHdr, req, req->priority);
                    428:                                                done = 1;
                    429:                                        }
                    430:        }
                    431: 
                    432:        RF_UNLOCK_QUEUE_MUTEX(queue, "DiskIOComplete");
1.1       oster     433: }
                    434: /* promotes accesses tagged with the given parityStripeID from low priority
                    435:  * to normal priority.  This promotion is optional, meaning that a queue
                    436:  * need not implement it.  If there is no promotion routine associated with
                    437:  * a queue, this routine does nothing and returns -1.
                    438:  */
1.6       oster     439: int 
1.27      oster     440: rf_DiskIOPromote(RF_DiskQueue_t *queue, RF_StripeNum_t parityStripeID,
                    441:                 RF_ReconUnitNum_t which_ru)
1.6       oster     442: {
                    443:        int     retval;
                    444: 
                    445:        if (!queue->qPtr->Promote)
                    446:                return (-1);
                    447:        RF_LOCK_QUEUE_MUTEX(queue, "DiskIOPromote");
                    448:        retval = (queue->qPtr->Promote) (queue->qHdr, parityStripeID, which_ru);
                    449:        RF_UNLOCK_QUEUE_MUTEX(queue, "DiskIOPromote");
                    450:        return (retval);
                    451: }
                    452: 
                    453: RF_DiskQueueData_t *
1.27      oster     454: rf_CreateDiskQueueData(RF_IoType_t typ, RF_SectorNum_t ssect,
                    455:                       RF_SectorCount_t nsect, caddr_t buf,
                    456:                       RF_StripeNum_t parityStripeID,
                    457:                       RF_ReconUnitNum_t which_ru,
                    458:                       int (*wakeF) (void *, int), void *arg,
                    459:                       RF_DiskQueueData_t *next,
                    460:                       RF_AccTraceEntry_t *tracerec, void *raidPtr,
                    461:                       RF_DiskQueueDataFlags_t flags, void *kb_proc)
1.6       oster     462: {
                    463:        RF_DiskQueueData_t *p;
                    464: 
1.24      oster     465:        p = pool_get(&rf_dqd_pool, PR_WAITOK);
1.28    ! oster     466:        p->bp = pool_get(&bufpool, PR_NOWAIT); /* XXX: make up our minds here.
        !           467:                                                  WAITOK, or NOWAIT?? */
        !           468: 
        !           469:        if (p->bp == NULL) {
1.24      oster     470:                /* no memory for the buffer!?!? */
                    471:                pool_put(&rf_dqd_pool, p);
                    472:                return(NULL);
                    473:        }
1.6       oster     474: 
1.28    ! oster     475:        memset(p->bp, 0, sizeof(struct buf));
1.6       oster     476:        p->sectorOffset = ssect + rf_protectedSectors;
                    477:        p->numSector = nsect;
                    478:        p->type = typ;
                    479:        p->buf = buf;
                    480:        p->parityStripeID = parityStripeID;
                    481:        p->which_ru = which_ru;
                    482:        p->CompleteFunc = wakeF;
                    483:        p->argument = arg;
                    484:        p->next = next;
                    485:        p->tracerec = tracerec;
                    486:        p->priority = RF_IO_NORMAL_PRIORITY;
                    487:        p->raidPtr = raidPtr;
                    488:        p->flags = flags;
                    489:        p->b_proc = kb_proc;
                    490:        return (p);
                    491: }
                    492: 
                    493: void 
1.27      oster     494: rf_FreeDiskQueueData(RF_DiskQueueData_t *p)
1.1       oster     495: {
1.28    ! oster     496:        pool_put(&bufpool, p->bp);
1.24      oster     497:        pool_put(&rf_dqd_pool, p);
1.1       oster     498: }

CVSweb <webmaster@jp.NetBSD.org>