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

1.26    ! oster       1: /*     $NetBSD: rf_diskqueue.c,v 1.25 2003/12/29 05:22:16 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.26    ! oster      69: __KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.25 2003/12/29 05:22:16 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 int init_dqd(RF_DiskQueueData_t *);
                     88: static void clean_dqd(RF_DiskQueueData_t *);
                     89: static void rf_ShutdownDiskQueueSystem(void *);
                     90: 
1.21      oster      91: #ifndef RF_DEBUG_DISKQUEUE
                     92: #define RF_DEBUG_DISKQUEUE 0
                     93: #endif
                     94: 
                     95: #if RF_DEBUG_DISKQUEUE
1.1       oster      96: #define Dprintf1(s,a)         if (rf_queueDebug) rf_debug_printf(s,(void *)((unsigned long)a),NULL,NULL,NULL,NULL,NULL,NULL,NULL)
                     97: #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)
                     98: #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      99: #else
                    100: #define Dprintf1(s,a)
                    101: #define Dprintf2(s,a,b)
                    102: #define Dprintf3(s,a,b,c)
                    103: #endif
1.1       oster     104: 
1.13      oster     105: /*****************************************************************************
1.1       oster     106:  *
1.13      oster     107:  * the disk queue switch defines all the functions used in the
                    108:  * different queueing disciplines queue ID, init routine, enqueue
                    109:  * routine, dequeue routine
1.1       oster     110:  *
1.13      oster     111:  ****************************************************************************/
1.1       oster     112: 
1.22      jdolecek  113: static const RF_DiskQueueSW_t diskqueuesw[] = {
1.6       oster     114:        {"fifo",                /* FIFO */
                    115:                rf_FifoCreate,
                    116:                rf_FifoEnqueue,
                    117:                rf_FifoDequeue,
                    118:                rf_FifoPeek,
1.1       oster     119:        rf_FifoPromote},
                    120: 
1.6       oster     121:        {"cvscan",              /* cvscan */
                    122:                rf_CvscanCreate,
                    123:                rf_CvscanEnqueue,
                    124:                rf_CvscanDequeue,
                    125:                rf_CvscanPeek,
                    126:        rf_CvscanPromote},
                    127: 
                    128:        {"sstf",                /* shortest seek time first */
                    129:                rf_SstfCreate,
                    130:                rf_SstfEnqueue,
                    131:                rf_SstfDequeue,
                    132:                rf_SstfPeek,
1.1       oster     133:        rf_SstfPromote},
                    134: 
1.6       oster     135:        {"scan",                /* SCAN (two-way elevator) */
                    136:                rf_ScanCreate,
                    137:                rf_SstfEnqueue,
                    138:                rf_ScanDequeue,
                    139:                rf_ScanPeek,
1.1       oster     140:        rf_SstfPromote},
                    141: 
1.6       oster     142:        {"cscan",               /* CSCAN (one-way elevator) */
                    143:                rf_CscanCreate,
                    144:                rf_SstfEnqueue,
                    145:                rf_CscanDequeue,
                    146:                rf_CscanPeek,
1.1       oster     147:        rf_SstfPromote},
                    148: 
                    149: };
                    150: #define NUM_DISK_QUEUE_TYPES (sizeof(diskqueuesw)/sizeof(RF_DiskQueueSW_t))
                    151: 
1.24      oster     152: static struct pool rf_dqd_pool;
1.1       oster     153: #define RF_MAX_FREE_DQD 256
                    154: #define RF_DQD_INC       16
                    155: #define RF_DQD_INITIAL   64
                    156: 
                    157: #include <sys/buf.h>
                    158: 
1.6       oster     159: static int 
                    160: init_dqd(dqd)
                    161:        RF_DiskQueueData_t *dqd;
                    162: {
1.13      oster     163: 
1.9       oster     164:        dqd->bp = (struct buf *) malloc(sizeof(struct buf), 
                    165:                                        M_RAIDFRAME, M_NOWAIT);
1.1       oster     166:        if (dqd->bp == NULL) {
1.6       oster     167:                return (ENOMEM);
1.1       oster     168:        }
1.6       oster     169:        memset(dqd->bp, 0, sizeof(struct buf)); /* if you don't do it, nobody
                    170:                                                 * else will.. */
                    171:        return (0);
1.1       oster     172: }
                    173: 
1.6       oster     174: static void 
                    175: clean_dqd(dqd)
                    176:        RF_DiskQueueData_t *dqd;
1.1       oster     177: {
1.6       oster     178:        free(dqd->bp, M_RAIDFRAME);
                    179: }
                    180: /* configures a single disk queue */
1.9       oster     181: 
1.7       oster     182: int 
1.9       oster     183: rf_ConfigureDiskQueue(
                    184:       RF_Raid_t * raidPtr,
                    185:       RF_DiskQueue_t * diskqueue,
                    186:       RF_RowCol_t c,
1.22      jdolecek  187:       const RF_DiskQueueSW_t * p,
1.9       oster     188:       RF_SectorCount_t sectPerDisk,
                    189:       dev_t dev,
                    190:       int maxOutstanding,
                    191:       RF_ShutdownList_t ** listp,
                    192:       RF_AllocListElem_t * clList)
1.6       oster     193: {
                    194:        diskqueue->col = c;
                    195:        diskqueue->qPtr = p;
                    196:        diskqueue->qHdr = (p->Create) (sectPerDisk, clList, listp);
                    197:        diskqueue->dev = dev;
                    198:        diskqueue->numOutstanding = 0;
                    199:        diskqueue->queueLength = 0;
                    200:        diskqueue->maxOutstanding = maxOutstanding;
                    201:        diskqueue->curPriority = RF_IO_NORMAL_PRIORITY;
                    202:        diskqueue->nextLockingOp = NULL;
                    203:        diskqueue->numWaiting = 0;
                    204:        diskqueue->flags = 0;
                    205:        diskqueue->raidPtr = raidPtr;
1.23      oster     206:        diskqueue->rf_cinfo = &raidPtr->raid_cinfo[c];
1.25      oster     207:        rf_mutex_init(&diskqueue->mutex);
1.26    ! oster     208:        diskqueue->cond = 0;
1.6       oster     209:        return (0);
1.1       oster     210: }
                    211: 
1.6       oster     212: static void 
                    213: rf_ShutdownDiskQueueSystem(ignored)
                    214:        void   *ignored;
                    215: {
1.24      oster     216:        pool_destroy(&rf_dqd_pool);
1.1       oster     217: }
                    218: 
1.6       oster     219: int 
                    220: rf_ConfigureDiskQueueSystem(listp)
                    221:        RF_ShutdownList_t **listp;
                    222: {
                    223:        int     rc;
                    224: 
1.24      oster     225:        pool_init(&rf_dqd_pool, sizeof(RF_DiskQueueData_t), 0, 0, 0,
                    226:                  "rf_dqd_pl", NULL);
                    227:        pool_sethiwat(&rf_dqd_pool, RF_MAX_FREE_DQD);
                    228:        pool_prime(&rf_dqd_pool, RF_DQD_INITIAL);
                    229: 
1.6       oster     230:        rc = rf_ShutdownCreate(listp, rf_ShutdownDiskQueueSystem, NULL);
                    231:        if (rc) {
1.18      oster     232:                rf_print_unable_to_add_shutdown( __FILE__, __LINE__, rc);
1.6       oster     233:                rf_ShutdownDiskQueueSystem(NULL);
                    234:                return (rc);
                    235:        }
1.24      oster     236: 
1.6       oster     237:        return (0);
                    238: }
                    239: 
                    240: int 
                    241: rf_ConfigureDiskQueues(
                    242:     RF_ShutdownList_t ** listp,
                    243:     RF_Raid_t * raidPtr,
                    244:     RF_Config_t * cfgPtr)
                    245: {
1.23      oster     246:        RF_DiskQueue_t *diskQueues, *spareQueues;
1.22      jdolecek  247:        const RF_DiskQueueSW_t *p;
1.23      oster     248:        RF_RowCol_t r,c;
1.6       oster     249:        int     rc, i;
                    250: 
                    251:        raidPtr->maxQueueDepth = cfgPtr->maxOutstandingDiskReqs;
                    252: 
                    253:        for (p = NULL, i = 0; i < NUM_DISK_QUEUE_TYPES; i++) {
                    254:                if (!strcmp(diskqueuesw[i].queueType, cfgPtr->diskQueueType)) {
                    255:                        p = &diskqueuesw[i];
                    256:                        break;
                    257:                }
                    258:        }
                    259:        if (p == NULL) {
                    260:                RF_ERRORMSG2("Unknown queue type \"%s\".  Using %s\n", cfgPtr->diskQueueType, diskqueuesw[0].queueType);
                    261:                p = &diskqueuesw[0];
                    262:        }
1.10      oster     263:        raidPtr->qType = p;
1.23      oster     264: 
1.24      oster     265:        RF_MallocAndAdd(diskQueues, 
                    266:                        (raidPtr->numCol + RF_MAXSPARE) *
1.23      oster     267:                        sizeof(RF_DiskQueue_t), (RF_DiskQueue_t *), 
                    268:                        raidPtr->cleanupList);
                    269:        if (diskQueues == NULL)
1.6       oster     270:                return (ENOMEM);
                    271:        raidPtr->Queues = diskQueues;
1.23      oster     272: 
                    273:        for (c = 0; c < raidPtr->numCol; c++) {
                    274:                rc = rf_ConfigureDiskQueue(raidPtr, &diskQueues[c],
                    275:                                           c, p,
                    276:                                           raidPtr->sectorsPerDisk, 
                    277:                                           raidPtr->Disks[c].dev,
                    278:                                           cfgPtr->maxOutstandingDiskReqs, 
                    279:                                           listp, raidPtr->cleanupList);
                    280:                if (rc)
                    281:                        return (rc);
1.6       oster     282:        }
                    283: 
1.23      oster     284:        spareQueues = &raidPtr->Queues[raidPtr->numCol];
1.6       oster     285:        for (r = 0; r < raidPtr->numSpare; r++) {
1.9       oster     286:                rc = rf_ConfigureDiskQueue(raidPtr, &spareQueues[r],
1.23      oster     287:                                           raidPtr->numCol + r, p,
                    288:                                           raidPtr->sectorsPerDisk,
                    289:                                           raidPtr->Disks[raidPtr->numCol + r].dev,
                    290:                                           cfgPtr->maxOutstandingDiskReqs, listp,
                    291:                                           raidPtr->cleanupList);
1.6       oster     292:                if (rc)
                    293:                        return (rc);
                    294:        }
                    295:        return (0);
                    296: }
1.1       oster     297: /* Enqueue a disk I/O
                    298:  *
                    299:  * Unfortunately, we have to do things differently in the different
                    300:  * environments (simulator, user-level, kernel).
                    301:  * At user level, all I/O is blocking, so we have 1 or more threads/disk
                    302:  * and the thread that enqueues is different from the thread that dequeues.
                    303:  * In the kernel, I/O is non-blocking and so we'd like to have multiple
                    304:  * I/Os outstanding on the physical disks when possible.
                    305:  *
                    306:  * when any request arrives at a queue, we have two choices:
                    307:  *    dispatch it to the lower levels
                    308:  *    queue it up
                    309:  *
                    310:  * kernel rules for when to do what:
                    311:  *    locking request:  queue empty => dispatch and lock queue,
                    312:  *                      else queue it
                    313:  *    unlocking req  :  always dispatch it
                    314:  *    normal req     :  queue empty => dispatch it & set priority
                    315:  *                      queue not full & priority is ok => dispatch it
                    316:  *                      else queue it
                    317:  *
                    318:  * user-level rules:
                    319:  *    always enqueue.  In the special case of an unlocking op, enqueue
                    320:  *    in a special way that will cause the unlocking op to be the next
                    321:  *    thing dequeued.
                    322:  *
                    323:  * simulator rules:
                    324:  *    Do the same as at user level, with the sleeps and wakeups suppressed.
                    325:  */
1.6       oster     326: void 
                    327: rf_DiskIOEnqueue(queue, req, pri)
                    328:        RF_DiskQueue_t *queue;
                    329:        RF_DiskQueueData_t *req;
                    330:        int     pri;
                    331: {
                    332:        RF_ETIMER_START(req->qtime);
                    333:        RF_ASSERT(req->type == RF_IO_TYPE_NOP || req->numSector);
                    334:        req->priority = pri;
                    335: 
1.21      oster     336: #if RF_DEBUG_DISKQUEUE
1.6       oster     337:        if (rf_queueDebug && (req->numSector == 0)) {
                    338:                printf("Warning: Enqueueing zero-sector access\n");
                    339:        }
1.21      oster     340: #endif
1.6       oster     341:        /*
                    342:          * kernel
                    343:          */
                    344:        RF_LOCK_QUEUE_MUTEX(queue, "DiskIOEnqueue");
                    345:        /* locking request */
                    346:        if (RF_LOCKING_REQ(req)) {
                    347:                if (RF_QUEUE_EMPTY(queue)) {
1.23      oster     348:                        Dprintf2("Dispatching pri %d locking op to c %d (queue empty)\n", pri, queue->col);
1.6       oster     349:                        RF_LOCK_QUEUE(queue);
                    350:                        rf_DispatchKernelIO(queue, req);
                    351:                } else {
                    352:                        queue->queueLength++;   /* increment count of number
                    353:                                                 * of requests waiting in this
                    354:                                                 * queue */
1.23      oster     355:                        Dprintf2("Enqueueing pri %d locking op to c %d (queue not empty)\n", pri, queue->col);
1.6       oster     356:                        req->queue = (void *) queue;
                    357:                        (queue->qPtr->Enqueue) (queue->qHdr, req, pri);
                    358:                }
                    359:        }
                    360:        /* unlocking request */
                    361:        else
                    362:                if (RF_UNLOCKING_REQ(req)) {    /* we'll do the actual unlock
                    363:                                                 * when this I/O completes */
1.23      oster     364:                        Dprintf2("Dispatching pri %d unlocking op to c %d\n", pri, queue->col);
1.6       oster     365:                        RF_ASSERT(RF_QUEUE_LOCKED(queue));
                    366:                        rf_DispatchKernelIO(queue, req);
                    367:                }
                    368:        /* normal request */
                    369:                else
                    370:                        if (RF_OK_TO_DISPATCH(queue, req)) {
1.23      oster     371:                                Dprintf2("Dispatching pri %d regular op to c %d (ok to dispatch)\n", pri, queue->col);
1.6       oster     372:                                rf_DispatchKernelIO(queue, req);
                    373:                        } else {
                    374:                                queue->queueLength++;   /* increment count of
                    375:                                                         * number of requests
                    376:                                                         * waiting in this queue */
1.23      oster     377:                                Dprintf2("Enqueueing pri %d regular op to c %d (not ok to dispatch)\n", pri, queue->col);
1.6       oster     378:                                req->queue = (void *) queue;
                    379:                                (queue->qPtr->Enqueue) (queue->qHdr, req, pri);
                    380:                        }
                    381:        RF_UNLOCK_QUEUE_MUTEX(queue, "DiskIOEnqueue");
1.1       oster     382: }
1.6       oster     383: 
1.1       oster     384: 
                    385: /* get the next set of I/Os started, kernel version only */
1.6       oster     386: void 
                    387: rf_DiskIOComplete(queue, req, status)
                    388:        RF_DiskQueue_t *queue;
                    389:        RF_DiskQueueData_t *req;
                    390:        int     status;
                    391: {
                    392:        int     done = 0;
                    393: 
                    394:        RF_LOCK_QUEUE_MUTEX(queue, "DiskIOComplete");
                    395: 
                    396:        /* unlock the queue: (1) after an unlocking req completes (2) after a
                    397:         * locking req fails */
                    398:        if (RF_UNLOCKING_REQ(req) || (RF_LOCKING_REQ(req) && status)) {
1.23      oster     399:                Dprintf1("DiskIOComplete: unlocking queue at c %d\n", queue->col);
1.20      oster     400:                RF_ASSERT(RF_QUEUE_LOCKED(queue));
1.6       oster     401:                RF_UNLOCK_QUEUE(queue);
                    402:        }
                    403:        queue->numOutstanding--;
                    404:        RF_ASSERT(queue->numOutstanding >= 0);
                    405: 
                    406:        /* dispatch requests to the disk until we find one that we can't. */
                    407:        /* no reason to continue once we've filled up the queue */
                    408:        /* no reason to even start if the queue is locked */
                    409: 
                    410:        while (!done && !RF_QUEUE_FULL(queue) && !RF_QUEUE_LOCKED(queue)) {
                    411:                if (queue->nextLockingOp) {
                    412:                        req = queue->nextLockingOp;
                    413:                        queue->nextLockingOp = NULL;
1.23      oster     414:                        Dprintf2("DiskIOComplete: a pri %d locking req was pending at c %d\n", req->priority, queue->col);
1.6       oster     415:                } else {
                    416:                        req = (queue->qPtr->Dequeue) (queue->qHdr);
                    417:                        if (req != NULL) {
1.23      oster     418:                                Dprintf2("DiskIOComplete: extracting pri %d req from queue at c %d\n", req->priority, queue->col);
1.6       oster     419:                        } else {
                    420:                                Dprintf1("DiskIOComplete: no more requests to extract.\n", "");
                    421:                        }
                    422:                }
                    423:                if (req) {
                    424:                        queue->queueLength--;   /* decrement count of number
                    425:                                                 * of requests waiting in this
                    426:                                                 * queue */
                    427:                        RF_ASSERT(queue->queueLength >= 0);
                    428:                }
                    429:                if (!req)
                    430:                        done = 1;
                    431:                else
                    432:                        if (RF_LOCKING_REQ(req)) {
                    433:                                if (RF_QUEUE_EMPTY(queue)) {    /* dispatch it */
1.23      oster     434:                                        Dprintf2("DiskIOComplete: dispatching pri %d locking req to c %d (queue empty)\n", req->priority, queue->col);
1.6       oster     435:                                        RF_LOCK_QUEUE(queue);
                    436:                                        rf_DispatchKernelIO(queue, req);
                    437:                                        done = 1;
                    438:                                } else {        /* put it aside to wait for
                    439:                                                 * the queue to drain */
1.23      oster     440:                                        Dprintf2("DiskIOComplete: postponing pri %d locking req to c %d\n", req->priority, queue->col);
1.6       oster     441:                                        RF_ASSERT(queue->nextLockingOp == NULL);
                    442:                                        queue->nextLockingOp = req;
                    443:                                        done = 1;
                    444:                                }
                    445:                        } else
                    446:                                if (RF_UNLOCKING_REQ(req)) {    /* should not happen:
                    447:                                                                 * unlocking ops should
                    448:                                                                 * not get queued */
                    449:                                        RF_ASSERT(RF_QUEUE_LOCKED(queue));      /* support it anyway for
                    450:                                                                                 * the future */
1.23      oster     451:                                        Dprintf2("DiskIOComplete: dispatching pri %d unl req to c %d (SHOULD NOT SEE THIS)\n", req->priority, queue->col);
1.6       oster     452:                                        rf_DispatchKernelIO(queue, req);
                    453:                                        done = 1;
                    454:                                } else
                    455:                                        if (RF_OK_TO_DISPATCH(queue, req)) {
1.23      oster     456:                                                Dprintf2("DiskIOComplete: dispatching pri %d regular req to c %d (ok to dispatch)\n", req->priority, queue->col);
1.6       oster     457:                                                rf_DispatchKernelIO(queue, req);
                    458:                                        } else {        /* we can't dispatch it,
                    459:                                                         * so just re-enqueue
                    460:                                                         * it.  */
                    461:                                                /* potential trouble here if
                    462:                                                 * disk queues batch reqs */
1.23      oster     463:                                                Dprintf2("DiskIOComplete: re-enqueueing pri %d regular req to c %d\n", req->priority, queue->col);
1.6       oster     464:                                                queue->queueLength++;
                    465:                                                (queue->qPtr->Enqueue) (queue->qHdr, req, req->priority);
                    466:                                                done = 1;
                    467:                                        }
                    468:        }
                    469: 
                    470:        RF_UNLOCK_QUEUE_MUTEX(queue, "DiskIOComplete");
1.1       oster     471: }
                    472: /* promotes accesses tagged with the given parityStripeID from low priority
                    473:  * to normal priority.  This promotion is optional, meaning that a queue
                    474:  * need not implement it.  If there is no promotion routine associated with
                    475:  * a queue, this routine does nothing and returns -1.
                    476:  */
1.6       oster     477: int 
                    478: rf_DiskIOPromote(queue, parityStripeID, which_ru)
                    479:        RF_DiskQueue_t *queue;
                    480:        RF_StripeNum_t parityStripeID;
                    481:        RF_ReconUnitNum_t which_ru;
                    482: {
                    483:        int     retval;
                    484: 
                    485:        if (!queue->qPtr->Promote)
                    486:                return (-1);
                    487:        RF_LOCK_QUEUE_MUTEX(queue, "DiskIOPromote");
                    488:        retval = (queue->qPtr->Promote) (queue->qHdr, parityStripeID, which_ru);
                    489:        RF_UNLOCK_QUEUE_MUTEX(queue, "DiskIOPromote");
                    490:        return (retval);
                    491: }
                    492: 
                    493: RF_DiskQueueData_t *
                    494: rf_CreateDiskQueueData(
                    495:     RF_IoType_t typ,
                    496:     RF_SectorNum_t ssect,
                    497:     RF_SectorCount_t nsect,
                    498:     caddr_t buf,
                    499:     RF_StripeNum_t parityStripeID,
                    500:     RF_ReconUnitNum_t which_ru,
                    501:     int (*wakeF) (void *, int),
                    502:     void *arg,
                    503:     RF_DiskQueueData_t * next,
                    504:     RF_AccTraceEntry_t * tracerec,
                    505:     void *raidPtr,
                    506:     RF_DiskQueueDataFlags_t flags,
                    507:     void *kb_proc)
                    508: {
                    509:        RF_DiskQueueData_t *p;
                    510: 
1.24      oster     511:        p = pool_get(&rf_dqd_pool, PR_WAITOK);
                    512:        if (init_dqd(p)) {
                    513:                /* no memory for the buffer!?!? */
                    514:                pool_put(&rf_dqd_pool, p);
                    515:                return(NULL);
                    516:        }
1.6       oster     517: 
                    518:        p->sectorOffset = ssect + rf_protectedSectors;
                    519:        p->numSector = nsect;
                    520:        p->type = typ;
                    521:        p->buf = buf;
                    522:        p->parityStripeID = parityStripeID;
                    523:        p->which_ru = which_ru;
                    524:        p->CompleteFunc = wakeF;
                    525:        p->argument = arg;
                    526:        p->next = next;
                    527:        p->tracerec = tracerec;
                    528:        p->priority = RF_IO_NORMAL_PRIORITY;
                    529:        p->raidPtr = raidPtr;
                    530:        p->flags = flags;
                    531:        p->b_proc = kb_proc;
                    532:        return (p);
                    533: }
                    534: 
                    535: void 
                    536: rf_FreeDiskQueueData(p)
                    537:        RF_DiskQueueData_t *p;
1.1       oster     538: {
1.24      oster     539:        clean_dqd(p);
                    540:        pool_put(&rf_dqd_pool, p);
1.1       oster     541: }

CVSweb <webmaster@jp.NetBSD.org>