Home | History | Annotate | Line # | Download | only in raidframe
rf_diskqueue.c revision 1.5
      1 /*	$NetBSD: rf_diskqueue.c,v 1.5 1999/01/26 02:33:56 oster Exp $	*/
      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 (at) 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 
     29 /****************************************************************************************
     30  *
     31  * rf_diskqueue.c -- higher-level disk queue code
     32  *
     33  * the routines here are a generic wrapper around the actual queueing
     34  * routines.  The code here implements thread scheduling, synchronization,
     35  * and locking ops (see below) on top of the lower-level queueing code.
     36  *
     37  * to support atomic RMW, we implement "locking operations".  When a locking op
     38  * is dispatched to the lower levels of the driver, the queue is locked, and no further
     39  * I/Os are dispatched until the queue receives & completes a corresponding "unlocking
     40  * operation".  This code relies on the higher layers to guarantee that a locking
     41  * op will always be eventually followed by an unlocking op.  The model is that
     42  * the higher layers are structured so locking and unlocking ops occur in pairs, i.e.
     43  * an unlocking op cannot be generated until after a locking op reports completion.
     44  * There is no good way to check to see that an unlocking op "corresponds" to the
     45  * op that currently has the queue locked, so we make no such attempt.  Since by
     46  * definition there can be only one locking op outstanding on a disk, this should
     47  * not be a problem.
     48  *
     49  * In the kernel, we allow multiple I/Os to be concurrently dispatched to the disk
     50  * driver.  In order to support locking ops in this environment, when we decide to
     51  * do a locking op, we stop dispatching new I/Os and wait until all dispatched I/Os
     52  * have completed before dispatching the locking op.
     53  *
     54  * Unfortunately, the code is different in the 3 different operating states
     55  * (user level, kernel, simulator).  In the kernel, I/O is non-blocking, and
     56  * we have no disk threads to dispatch for us.  Therefore, we have to dispatch
     57  * new I/Os to the scsi driver at the time of enqueue, and also at the time
     58  * of completion.  At user level, I/O is blocking, and so only the disk threads
     59  * may dispatch I/Os.  Thus at user level, all we can do at enqueue time is
     60  * enqueue and wake up the disk thread to do the dispatch.
     61  *
     62  ***************************************************************************************/
     63 
     64 #include "rf_types.h"
     65 #include "rf_threadstuff.h"
     66 #include "rf_threadid.h"
     67 #include "rf_raid.h"
     68 #include "rf_diskqueue.h"
     69 #include "rf_alloclist.h"
     70 #include "rf_acctrace.h"
     71 #include "rf_etimer.h"
     72 #include "rf_configure.h"
     73 #include "rf_general.h"
     74 #include "rf_freelist.h"
     75 #include "rf_debugprint.h"
     76 #include "rf_shutdown.h"
     77 #include "rf_cvscan.h"
     78 #include "rf_sstf.h"
     79 #include "rf_fifo.h"
     80 
     81 static int init_dqd(RF_DiskQueueData_t *);
     82 static void clean_dqd(RF_DiskQueueData_t *);
     83 static void rf_ShutdownDiskQueueSystem(void *);
     84 /* From rf_kintf.c */
     85 int rf_DispatchKernelIO(RF_DiskQueue_t *,RF_DiskQueueData_t *);
     86 
     87 
     88 #define Dprintf1(s,a)         if (rf_queueDebug) rf_debug_printf(s,(void *)((unsigned long)a),NULL,NULL,NULL,NULL,NULL,NULL,NULL)
     89 #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)
     90 #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)
     91 #define Dprintf4(s,a,b,c,d)   if (rf_queueDebug) rf_debug_printf(s,(void *)((unsigned long)a),(void *)((unsigned long)b),(void *)((unsigned long)c),(void *)((unsigned long)d),NULL,NULL,NULL,NULL)
     92 #define Dprintf5(s,a,b,c,d,e) if (rf_queueDebug) rf_debug_printf(s,(void *)((unsigned long)a),(void *)((unsigned long)b),(void *)((unsigned long)c),(void *)((unsigned long)d),(void *)((unsigned long)e),NULL,NULL,NULL)
     93 
     94 
     95 #define SIGNAL_DISK_QUEUE(_q_,_wh_)
     96 #define WAIT_DISK_QUEUE(_q_,_wh_)
     97 
     98 /*****************************************************************************************
     99  *
    100  * the disk queue switch defines all the functions used in the different queueing
    101  * disciplines
    102  *    queue ID, init routine, enqueue routine, dequeue routine
    103  *
    104  ****************************************************************************************/
    105 
    106 static RF_DiskQueueSW_t diskqueuesw[] = {
    107 	{"fifo", /* FIFO */
    108 	rf_FifoCreate,
    109 	rf_FifoEnqueue,
    110 	rf_FifoDequeue,
    111 	rf_FifoPeek,
    112 	rf_FifoPromote},
    113 
    114 	{"cvscan", /* cvscan */
    115 	rf_CvscanCreate,
    116 	rf_CvscanEnqueue,
    117 	rf_CvscanDequeue,
    118 	rf_CvscanPeek,
    119 	rf_CvscanPromote },
    120 
    121 	{"sstf", /* shortest seek time first */
    122 	rf_SstfCreate,
    123 	rf_SstfEnqueue,
    124 	rf_SstfDequeue,
    125 	rf_SstfPeek,
    126 	rf_SstfPromote},
    127 
    128 	{"scan", /* SCAN (two-way elevator) */
    129 	rf_ScanCreate,
    130 	rf_SstfEnqueue,
    131 	rf_ScanDequeue,
    132 	rf_ScanPeek,
    133 	rf_SstfPromote},
    134 
    135 	{"cscan", /* CSCAN (one-way elevator) */
    136 	rf_CscanCreate,
    137 	rf_SstfEnqueue,
    138 	rf_CscanDequeue,
    139 	rf_CscanPeek,
    140 	rf_SstfPromote},
    141 
    142 #if !defined(_KERNEL) && RF_INCLUDE_QUEUE_RANDOM > 0
    143 	/* to make a point to Chris :-> */
    144 	{"random", /* random */
    145 	rf_FifoCreate,
    146 	rf_FifoEnqueue,
    147 	rf_RandomDequeue,
    148 	rf_RandomPeek,
    149 	rf_FifoPromote},
    150 #endif /* !KERNEL && RF_INCLUDE_QUEUE_RANDOM > 0 */
    151 };
    152 #define NUM_DISK_QUEUE_TYPES (sizeof(diskqueuesw)/sizeof(RF_DiskQueueSW_t))
    153 
    154 static RF_FreeList_t *rf_dqd_freelist;
    155 
    156 #define RF_MAX_FREE_DQD 256
    157 #define RF_DQD_INC       16
    158 #define RF_DQD_INITIAL   64
    159 
    160 #include <sys/buf.h>
    161 
    162 static int init_dqd(dqd)
    163   RF_DiskQueueData_t  *dqd;
    164 {
    165 	/* XXX not sure if the following malloc is appropriate... probably not quite... */
    166 	dqd->bp = (struct buf *) malloc( sizeof(struct buf), M_RAIDFRAME, M_NOWAIT);
    167 	if (dqd->bp == NULL) {
    168 		return(ENOMEM);
    169 	}
    170 	memset(dqd->bp,0,sizeof(struct buf)); /* if you don't do it, nobody else will.. */
    171 	return(0);
    172 }
    173 
    174 static void clean_dqd(dqd)
    175   RF_DiskQueueData_t  *dqd;
    176 {
    177 	free( dqd->bp, M_RAIDFRAME );
    178 }
    179 
    180 /* configures a single disk queue */
    181 static int config_disk_queue(
    182   RF_Raid_t            *raidPtr,
    183   RF_DiskQueue_t       *diskqueue,
    184   RF_RowCol_t           r, /* row & col -- debug only.  BZZT not any more... */
    185   RF_RowCol_t           c,
    186   RF_DiskQueueSW_t     *p,
    187   RF_SectorCount_t      sectPerDisk,
    188   dev_t                 dev,
    189   int                   maxOutstanding,
    190   RF_ShutdownList_t   **listp,
    191   RF_AllocListElem_t   *clList)
    192 {
    193   int rc;
    194 
    195   diskqueue->row = r;
    196   diskqueue->col = c;
    197   diskqueue->qPtr = p;
    198   diskqueue->qHdr = (p->Create)(sectPerDisk, clList, listp);
    199   diskqueue->dev  = dev;
    200   diskqueue->numOutstanding = 0;
    201   diskqueue->queueLength = 0;
    202   diskqueue->maxOutstanding = maxOutstanding;
    203   diskqueue->curPriority    = RF_IO_NORMAL_PRIORITY;
    204   diskqueue->nextLockingOp  = NULL;
    205   diskqueue->unlockingOp    = NULL;
    206   diskqueue->numWaiting=0;
    207   diskqueue->flags = 0;
    208   diskqueue->raidPtr = raidPtr;
    209   diskqueue->rf_cinfo = &raidPtr->raid_cinfo[r][c];
    210   rc = rf_create_managed_mutex(listp, &diskqueue->mutex);
    211   if (rc) {
    212     RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__,
    213       __LINE__, rc);
    214     return(rc);
    215   }
    216   rc = rf_create_managed_cond(listp, &diskqueue->cond);
    217   if (rc) {
    218     RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", __FILE__,
    219       __LINE__, rc);
    220     return(rc);
    221   }
    222   return(0);
    223 }
    224 
    225 static void rf_ShutdownDiskQueueSystem(ignored)
    226   void  *ignored;
    227 {
    228   RF_FREELIST_DESTROY_CLEAN(rf_dqd_freelist,next,(RF_DiskQueueData_t *),clean_dqd);
    229 }
    230 
    231 int rf_ConfigureDiskQueueSystem(listp)
    232   RF_ShutdownList_t  **listp;
    233 {
    234   int rc;
    235 
    236   RF_FREELIST_CREATE(rf_dqd_freelist, RF_MAX_FREE_DQD,
    237     RF_DQD_INC, sizeof(RF_DiskQueueData_t));
    238   if (rf_dqd_freelist == NULL)
    239     return(ENOMEM);
    240   rc = rf_ShutdownCreate(listp, rf_ShutdownDiskQueueSystem, NULL);
    241   if (rc) {
    242     RF_ERRORMSG3("Unable to add to shutdown list file %s line %d rc=%d\n",
    243       __FILE__, __LINE__, rc);
    244     rf_ShutdownDiskQueueSystem(NULL);
    245     return(rc);
    246   }
    247   RF_FREELIST_PRIME_INIT(rf_dqd_freelist, RF_DQD_INITIAL,next,
    248     (RF_DiskQueueData_t *),init_dqd);
    249   return(0);
    250 }
    251 
    252 int rf_ConfigureDiskQueues(
    253   RF_ShutdownList_t  **listp,
    254   RF_Raid_t           *raidPtr,
    255   RF_Config_t         *cfgPtr)
    256 {
    257   RF_DiskQueue_t **diskQueues, *spareQueues;
    258   RF_DiskQueueSW_t *p;
    259   RF_RowCol_t r, c;
    260   int rc, i;
    261 
    262   raidPtr->maxQueueDepth = cfgPtr->maxOutstandingDiskReqs;
    263 
    264   for(p=NULL,i=0;i<NUM_DISK_QUEUE_TYPES;i++) {
    265     if (!strcmp(diskqueuesw[i].queueType, cfgPtr->diskQueueType)) {
    266       p = &diskqueuesw[i];
    267       break;
    268     }
    269   }
    270   if (p == NULL) {
    271     RF_ERRORMSG2("Unknown queue type \"%s\".  Using %s\n",cfgPtr->diskQueueType, diskqueuesw[0].queueType);
    272     p = &diskqueuesw[0];
    273   }
    274 
    275   RF_CallocAndAdd(diskQueues, raidPtr->numRow, sizeof(RF_DiskQueue_t *), (RF_DiskQueue_t **), raidPtr->cleanupList);
    276   if (diskQueues == NULL) {
    277     return(ENOMEM);
    278   }
    279   raidPtr->Queues = diskQueues;
    280   for (r=0; r<raidPtr->numRow; r++) {
    281     RF_CallocAndAdd(diskQueues[r], raidPtr->numCol + ((r==0) ? raidPtr->numSpare : 0), sizeof(RF_DiskQueue_t), (RF_DiskQueue_t *), raidPtr->cleanupList);
    282     if (diskQueues[r] == NULL)
    283       return(ENOMEM);
    284     for (c=0; c<raidPtr->numCol; c++) {
    285       rc = config_disk_queue(raidPtr, &diskQueues[r][c], r, c, p,
    286         raidPtr->sectorsPerDisk, raidPtr->Disks[r][c].dev,
    287         cfgPtr->maxOutstandingDiskReqs, listp, raidPtr->cleanupList);
    288       if (rc)
    289         return(rc);
    290     }
    291   }
    292 
    293   spareQueues = &raidPtr->Queues[0][raidPtr->numCol];
    294   for (r=0; r<raidPtr->numSpare; r++) {
    295 	  rc = config_disk_queue(raidPtr, &spareQueues[r],
    296 				 0, raidPtr->numCol+r, p,
    297 				 raidPtr->sectorsPerDisk,
    298 				 raidPtr->Disks[0][raidPtr->numCol+r].dev,
    299 				 cfgPtr->maxOutstandingDiskReqs, listp,
    300 				 raidPtr->cleanupList);
    301     if (rc)
    302       return(rc);
    303   }
    304   return(0);
    305 }
    306 
    307 /* Enqueue a disk I/O
    308  *
    309  * Unfortunately, we have to do things differently in the different
    310  * environments (simulator, user-level, kernel).
    311  * At user level, all I/O is blocking, so we have 1 or more threads/disk
    312  * and the thread that enqueues is different from the thread that dequeues.
    313  * In the kernel, I/O is non-blocking and so we'd like to have multiple
    314  * I/Os outstanding on the physical disks when possible.
    315  *
    316  * when any request arrives at a queue, we have two choices:
    317  *    dispatch it to the lower levels
    318  *    queue it up
    319  *
    320  * kernel rules for when to do what:
    321  *    locking request:  queue empty => dispatch and lock queue,
    322  *                      else queue it
    323  *    unlocking req  :  always dispatch it
    324  *    normal req     :  queue empty => dispatch it & set priority
    325  *                      queue not full & priority is ok => dispatch it
    326  *                      else queue it
    327  *
    328  * user-level rules:
    329  *    always enqueue.  In the special case of an unlocking op, enqueue
    330  *    in a special way that will cause the unlocking op to be the next
    331  *    thing dequeued.
    332  *
    333  * simulator rules:
    334  *    Do the same as at user level, with the sleeps and wakeups suppressed.
    335  */
    336 void rf_DiskIOEnqueue(queue, req, pri)
    337   RF_DiskQueue_t      *queue;
    338   RF_DiskQueueData_t  *req;
    339   int                  pri;
    340 {
    341   int tid;
    342 
    343   RF_ETIMER_START(req->qtime);
    344   rf_get_threadid(tid);
    345   RF_ASSERT(req->type == RF_IO_TYPE_NOP || req->numSector);
    346   req->priority = pri;
    347 
    348   if (rf_queueDebug && (req->numSector == 0)) {
    349     printf("Warning: Enqueueing zero-sector access\n");
    350   }
    351 
    352   /*
    353    * kernel
    354    */
    355   RF_LOCK_QUEUE_MUTEX( queue, "DiskIOEnqueue" );
    356   /* locking request */
    357   if (RF_LOCKING_REQ(req)) {
    358     if (RF_QUEUE_EMPTY(queue)) {
    359       Dprintf3("Dispatching pri %d locking op to r %d c %d (queue empty)\n",pri,queue->row, queue->col);
    360       RF_LOCK_QUEUE(queue);
    361       rf_DispatchKernelIO(queue, req);
    362     } else {
    363       queue->queueLength++;  /* increment count of number of requests waiting in this queue */
    364       Dprintf3("Enqueueing pri %d locking op to r %d c %d (queue not empty)\n",pri,queue->row, queue->col);
    365       req->queue = (void *)queue;
    366       (queue->qPtr->Enqueue)(queue->qHdr, req, pri);
    367     }
    368   }
    369   /* unlocking request */
    370   else if (RF_UNLOCKING_REQ(req)) {           /* we'll do the actual unlock when this I/O completes */
    371     Dprintf3("Dispatching pri %d unlocking op to r %d c %d\n",pri,queue->row, queue->col);
    372     RF_ASSERT(RF_QUEUE_LOCKED(queue));
    373     rf_DispatchKernelIO(queue, req);
    374   }
    375   /* normal request */
    376   else if (RF_OK_TO_DISPATCH(queue, req)) {
    377     Dprintf3("Dispatching pri %d regular op to r %d c %d (ok to dispatch)\n",pri,queue->row, queue->col);
    378     rf_DispatchKernelIO(queue, req);
    379   } else {
    380     queue->queueLength++;  /* increment count of number of requests waiting in this queue */
    381     Dprintf3("Enqueueing pri %d regular op to r %d c %d (not ok to dispatch)\n",pri,queue->row, queue->col);
    382     req->queue = (void *)queue;
    383     (queue->qPtr->Enqueue)(queue->qHdr, req, pri);
    384   }
    385   RF_UNLOCK_QUEUE_MUTEX( queue, "DiskIOEnqueue" );
    386 }
    387 
    388 
    389 /* get the next set of I/Os started, kernel version only */
    390 void rf_DiskIOComplete(queue, req, status)
    391   RF_DiskQueue_t      *queue;
    392   RF_DiskQueueData_t  *req;
    393   int                  status;
    394 {
    395   int done=0;
    396 
    397   RF_LOCK_QUEUE_MUTEX( queue, "DiskIOComplete" );
    398 
    399   /* unlock the queue:
    400      (1) after an unlocking req completes
    401      (2) after a locking req fails
    402   */
    403   if (RF_UNLOCKING_REQ(req) || (RF_LOCKING_REQ(req) && status)) {
    404     Dprintf2("DiskIOComplete: unlocking queue at r %d c %d\n", queue->row, queue->col);
    405     RF_ASSERT(RF_QUEUE_LOCKED(queue) && (queue->unlockingOp == NULL));
    406     RF_UNLOCK_QUEUE(queue);
    407   }
    408 
    409   queue->numOutstanding--;
    410   RF_ASSERT(queue->numOutstanding >= 0);
    411 
    412   /* dispatch requests to the disk until we find one that we can't. */
    413   /* no reason to continue once we've filled up the queue */
    414   /* no reason to even start if the queue is locked */
    415 
    416   while (!done && !RF_QUEUE_FULL(queue) && !RF_QUEUE_LOCKED(queue)) {
    417     if (queue->nextLockingOp) {
    418       req = queue->nextLockingOp; queue->nextLockingOp = NULL;
    419       Dprintf3("DiskIOComplete: a pri %d locking req was pending at r %d c %d\n",req->priority,queue->row, queue->col);
    420     } else {
    421       req = (queue->qPtr->Dequeue)( queue->qHdr );
    422       if (req != NULL) {
    423 	      Dprintf3("DiskIOComplete: extracting pri %d req from queue at r %d c %d\n",req->priority,queue->row, queue->col);
    424       } else {
    425 	      Dprintf1("DiskIOComplete: no more requests to extract.\n","");
    426       }
    427     }
    428     if (req) {
    429 	queue->queueLength--;  /* decrement count of number of requests waiting in this queue */
    430 	RF_ASSERT(queue->queueLength >= 0);
    431     }
    432     if (!req) done=1;
    433     else if (RF_LOCKING_REQ(req)) {
    434       if (RF_QUEUE_EMPTY(queue)) {                   					/* dispatch it */
    435 	Dprintf3("DiskIOComplete: dispatching pri %d locking req to r %d c %d (queue empty)\n",req->priority,queue->row, queue->col);
    436 	RF_LOCK_QUEUE(queue);
    437 	rf_DispatchKernelIO(queue, req);
    438 	done = 1;
    439       } else {                         		           /* put it aside to wait for the queue to drain */
    440 	Dprintf3("DiskIOComplete: postponing pri %d locking req to r %d c %d\n",req->priority,queue->row, queue->col);
    441 	RF_ASSERT(queue->nextLockingOp == NULL);
    442 	queue->nextLockingOp = req;
    443 	done = 1;
    444       }
    445     } else if (RF_UNLOCKING_REQ(req)) {      	/* should not happen: unlocking ops should not get queued */
    446       RF_ASSERT(RF_QUEUE_LOCKED(queue)); 			               /* support it anyway for the future */
    447       Dprintf3("DiskIOComplete: dispatching pri %d unl req to r %d c %d (SHOULD NOT SEE THIS)\n",req->priority,queue->row, queue->col);
    448       rf_DispatchKernelIO(queue, req);
    449       done = 1;
    450     } else if (RF_OK_TO_DISPATCH(queue, req)) {
    451       Dprintf3("DiskIOComplete: dispatching pri %d regular req to r %d c %d (ok to dispatch)\n",req->priority,queue->row, queue->col);
    452       rf_DispatchKernelIO(queue, req);
    453     } else {                                   		  /* we can't dispatch it, so just re-enqueue it.  */
    454       /* potential trouble here if disk queues batch reqs */
    455       Dprintf3("DiskIOComplete: re-enqueueing pri %d regular req to r %d c %d\n",req->priority,queue->row, queue->col);
    456       queue->queueLength++;
    457       (queue->qPtr->Enqueue)(queue->qHdr, req, req->priority);
    458       done = 1;
    459     }
    460   }
    461 
    462   RF_UNLOCK_QUEUE_MUTEX( queue, "DiskIOComplete" );
    463 }
    464 
    465 /* promotes accesses tagged with the given parityStripeID from low priority
    466  * to normal priority.  This promotion is optional, meaning that a queue
    467  * need not implement it.  If there is no promotion routine associated with
    468  * a queue, this routine does nothing and returns -1.
    469  */
    470 int rf_DiskIOPromote(queue, parityStripeID, which_ru)
    471   RF_DiskQueue_t     *queue;
    472   RF_StripeNum_t      parityStripeID;
    473   RF_ReconUnitNum_t   which_ru;
    474 {
    475   int retval;
    476 
    477   if (!queue->qPtr->Promote)
    478     return(-1);
    479   RF_LOCK_QUEUE_MUTEX( queue, "DiskIOPromote" );
    480   retval = (queue->qPtr->Promote)( queue->qHdr, parityStripeID, which_ru );
    481   RF_UNLOCK_QUEUE_MUTEX( queue, "DiskIOPromote" );
    482   return(retval);
    483 }
    484 
    485 RF_DiskQueueData_t *rf_CreateDiskQueueData(
    486   RF_IoType_t                typ,
    487   RF_SectorNum_t             ssect,
    488   RF_SectorCount_t           nsect,
    489   caddr_t                    buf,
    490   RF_StripeNum_t             parityStripeID,
    491   RF_ReconUnitNum_t          which_ru,
    492   int                      (*wakeF)(void *,int),
    493   void                      *arg,
    494   RF_DiskQueueData_t        *next,
    495   RF_AccTraceEntry_t        *tracerec,
    496   void                      *raidPtr,
    497   RF_DiskQueueDataFlags_t    flags,
    498   void                      *kb_proc)
    499 {
    500   RF_DiskQueueData_t *p;
    501 
    502   RF_FREELIST_GET_INIT(rf_dqd_freelist,p,next,(RF_DiskQueueData_t *),init_dqd);
    503 
    504   p->sectorOffset  = ssect + rf_protectedSectors;
    505   p->numSector     = nsect;
    506   p->type          = typ;
    507   p->buf           = buf;
    508   p->parityStripeID= parityStripeID;
    509   p->which_ru      = which_ru;
    510   p->CompleteFunc  = wakeF;
    511   p->argument      = arg;
    512   p->next          = next;
    513   p->tracerec      = tracerec;
    514   p->priority      = RF_IO_NORMAL_PRIORITY;
    515   p->AuxFunc       = NULL;
    516   p->buf2          = NULL;
    517   p->raidPtr       = raidPtr;
    518   p->flags         = flags;
    519   p->b_proc        = kb_proc;
    520   return(p);
    521 }
    522 
    523 RF_DiskQueueData_t *rf_CreateDiskQueueDataFull(
    524   RF_IoType_t                typ,
    525   RF_SectorNum_t             ssect,
    526   RF_SectorCount_t           nsect,
    527   caddr_t                    buf,
    528   RF_StripeNum_t             parityStripeID,
    529   RF_ReconUnitNum_t          which_ru,
    530   int                      (*wakeF)(void *,int),
    531   void                      *arg,
    532   RF_DiskQueueData_t        *next,
    533   RF_AccTraceEntry_t        *tracerec,
    534   int                        priority,
    535   int                      (*AuxFunc)(void *,...),
    536   caddr_t                    buf2,
    537   void                      *raidPtr,
    538   RF_DiskQueueDataFlags_t    flags,
    539   void                      *kb_proc)
    540 {
    541   RF_DiskQueueData_t *p;
    542 
    543   RF_FREELIST_GET_INIT(rf_dqd_freelist,p,next,(RF_DiskQueueData_t *),init_dqd);
    544 
    545   p->sectorOffset  = ssect + rf_protectedSectors;
    546   p->numSector     = nsect;
    547   p->type          = typ;
    548   p->buf           = buf;
    549   p->parityStripeID= parityStripeID;
    550   p->which_ru      = which_ru;
    551   p->CompleteFunc  = wakeF;
    552   p->argument      = arg;
    553   p->next          = next;
    554   p->tracerec      = tracerec;
    555   p->priority      = priority;
    556   p->AuxFunc       = AuxFunc;
    557   p->buf2          = buf2;
    558   p->raidPtr       = raidPtr;
    559   p->flags         = flags;
    560   p->b_proc        = kb_proc;
    561   return(p);
    562 }
    563 
    564 void rf_FreeDiskQueueData(p)
    565   RF_DiskQueueData_t  *p;
    566 {
    567 	RF_FREELIST_FREE_CLEAN(rf_dqd_freelist,p,next,clean_dqd);
    568 }
    569