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