Home | History | Annotate | Line # | Download | only in raidframe
rf_diskqueue.c revision 1.10
      1 /*	$NetBSD: rf_diskqueue.c,v 1.10 2000/02/24 03:48:41 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 	raidPtr->qType = p;
    284 	RF_CallocAndAdd(diskQueues, raidPtr->numRow, sizeof(RF_DiskQueue_t *), (RF_DiskQueue_t **), raidPtr->cleanupList);
    285 	if (diskQueues == NULL) {
    286 		return (ENOMEM);
    287 	}
    288 	raidPtr->Queues = diskQueues;
    289 	for (r = 0; r < raidPtr->numRow; r++) {
    290 		RF_CallocAndAdd(diskQueues[r], raidPtr->numCol +
    291 				 ((r == 0) ? RF_MAXSPARE : 0),
    292 				sizeof(RF_DiskQueue_t), (RF_DiskQueue_t *),
    293 				raidPtr->cleanupList);
    294 		if (diskQueues[r] == NULL)
    295 			return (ENOMEM);
    296 		for (c = 0; c < raidPtr->numCol; c++) {
    297 			rc = rf_ConfigureDiskQueue(raidPtr, &diskQueues[r][c],
    298 						   r, c, p,
    299 						   raidPtr->sectorsPerDisk,
    300 						   raidPtr->Disks[r][c].dev,
    301 						   cfgPtr->maxOutstandingDiskReqs,
    302 						   listp, raidPtr->cleanupList);
    303 			if (rc)
    304 				return (rc);
    305 		}
    306 	}
    307 
    308 	spareQueues = &raidPtr->Queues[0][raidPtr->numCol];
    309 	for (r = 0; r < raidPtr->numSpare; r++) {
    310 		rc = rf_ConfigureDiskQueue(raidPtr, &spareQueues[r],
    311 		    0, raidPtr->numCol + r, p,
    312 		    raidPtr->sectorsPerDisk,
    313 		    raidPtr->Disks[0][raidPtr->numCol + r].dev,
    314 		    cfgPtr->maxOutstandingDiskReqs, listp,
    315 		    raidPtr->cleanupList);
    316 		if (rc)
    317 			return (rc);
    318 	}
    319 	return (0);
    320 }
    321 /* Enqueue a disk I/O
    322  *
    323  * Unfortunately, we have to do things differently in the different
    324  * environments (simulator, user-level, kernel).
    325  * At user level, all I/O is blocking, so we have 1 or more threads/disk
    326  * and the thread that enqueues is different from the thread that dequeues.
    327  * In the kernel, I/O is non-blocking and so we'd like to have multiple
    328  * I/Os outstanding on the physical disks when possible.
    329  *
    330  * when any request arrives at a queue, we have two choices:
    331  *    dispatch it to the lower levels
    332  *    queue it up
    333  *
    334  * kernel rules for when to do what:
    335  *    locking request:  queue empty => dispatch and lock queue,
    336  *                      else queue it
    337  *    unlocking req  :  always dispatch it
    338  *    normal req     :  queue empty => dispatch it & set priority
    339  *                      queue not full & priority is ok => dispatch it
    340  *                      else queue it
    341  *
    342  * user-level rules:
    343  *    always enqueue.  In the special case of an unlocking op, enqueue
    344  *    in a special way that will cause the unlocking op to be the next
    345  *    thing dequeued.
    346  *
    347  * simulator rules:
    348  *    Do the same as at user level, with the sleeps and wakeups suppressed.
    349  */
    350 void
    351 rf_DiskIOEnqueue(queue, req, pri)
    352 	RF_DiskQueue_t *queue;
    353 	RF_DiskQueueData_t *req;
    354 	int     pri;
    355 {
    356 	RF_ETIMER_START(req->qtime);
    357 	RF_ASSERT(req->type == RF_IO_TYPE_NOP || req->numSector);
    358 	req->priority = pri;
    359 
    360 	if (rf_queueDebug && (req->numSector == 0)) {
    361 		printf("Warning: Enqueueing zero-sector access\n");
    362 	}
    363 	/*
    364          * kernel
    365          */
    366 	RF_LOCK_QUEUE_MUTEX(queue, "DiskIOEnqueue");
    367 	/* locking request */
    368 	if (RF_LOCKING_REQ(req)) {
    369 		if (RF_QUEUE_EMPTY(queue)) {
    370 			Dprintf3("Dispatching pri %d locking op to r %d c %d (queue empty)\n", pri, queue->row, queue->col);
    371 			RF_LOCK_QUEUE(queue);
    372 			rf_DispatchKernelIO(queue, req);
    373 		} else {
    374 			queue->queueLength++;	/* increment count of number
    375 						 * of requests waiting in this
    376 						 * queue */
    377 			Dprintf3("Enqueueing pri %d locking op to r %d c %d (queue not empty)\n", pri, queue->row, queue->col);
    378 			req->queue = (void *) queue;
    379 			(queue->qPtr->Enqueue) (queue->qHdr, req, pri);
    380 		}
    381 	}
    382 	/* unlocking request */
    383 	else
    384 		if (RF_UNLOCKING_REQ(req)) {	/* we'll do the actual unlock
    385 						 * when this I/O completes */
    386 			Dprintf3("Dispatching pri %d unlocking op to r %d c %d\n", pri, queue->row, queue->col);
    387 			RF_ASSERT(RF_QUEUE_LOCKED(queue));
    388 			rf_DispatchKernelIO(queue, req);
    389 		}
    390 	/* normal request */
    391 		else
    392 			if (RF_OK_TO_DISPATCH(queue, req)) {
    393 				Dprintf3("Dispatching pri %d regular op to r %d c %d (ok to dispatch)\n", pri, queue->row, queue->col);
    394 				rf_DispatchKernelIO(queue, req);
    395 			} else {
    396 				queue->queueLength++;	/* increment count of
    397 							 * number of requests
    398 							 * waiting in this queue */
    399 				Dprintf3("Enqueueing pri %d regular op to r %d c %d (not ok to dispatch)\n", pri, queue->row, queue->col);
    400 				req->queue = (void *) queue;
    401 				(queue->qPtr->Enqueue) (queue->qHdr, req, pri);
    402 			}
    403 	RF_UNLOCK_QUEUE_MUTEX(queue, "DiskIOEnqueue");
    404 }
    405 
    406 
    407 /* get the next set of I/Os started, kernel version only */
    408 void
    409 rf_DiskIOComplete(queue, req, status)
    410 	RF_DiskQueue_t *queue;
    411 	RF_DiskQueueData_t *req;
    412 	int     status;
    413 {
    414 	int     done = 0;
    415 
    416 	RF_LOCK_QUEUE_MUTEX(queue, "DiskIOComplete");
    417 
    418 	/* unlock the queue: (1) after an unlocking req completes (2) after a
    419 	 * locking req fails */
    420 	if (RF_UNLOCKING_REQ(req) || (RF_LOCKING_REQ(req) && status)) {
    421 		Dprintf2("DiskIOComplete: unlocking queue at r %d c %d\n", queue->row, queue->col);
    422 		RF_ASSERT(RF_QUEUE_LOCKED(queue) && (queue->unlockingOp == NULL));
    423 		RF_UNLOCK_QUEUE(queue);
    424 	}
    425 	queue->numOutstanding--;
    426 	RF_ASSERT(queue->numOutstanding >= 0);
    427 
    428 	/* dispatch requests to the disk until we find one that we can't. */
    429 	/* no reason to continue once we've filled up the queue */
    430 	/* no reason to even start if the queue is locked */
    431 
    432 	while (!done && !RF_QUEUE_FULL(queue) && !RF_QUEUE_LOCKED(queue)) {
    433 		if (queue->nextLockingOp) {
    434 			req = queue->nextLockingOp;
    435 			queue->nextLockingOp = NULL;
    436 			Dprintf3("DiskIOComplete: a pri %d locking req was pending at r %d c %d\n", req->priority, queue->row, queue->col);
    437 		} else {
    438 			req = (queue->qPtr->Dequeue) (queue->qHdr);
    439 			if (req != NULL) {
    440 				Dprintf3("DiskIOComplete: extracting pri %d req from queue at r %d c %d\n", req->priority, queue->row, queue->col);
    441 			} else {
    442 				Dprintf1("DiskIOComplete: no more requests to extract.\n", "");
    443 			}
    444 		}
    445 		if (req) {
    446 			queue->queueLength--;	/* decrement count of number
    447 						 * of requests waiting in this
    448 						 * queue */
    449 			RF_ASSERT(queue->queueLength >= 0);
    450 		}
    451 		if (!req)
    452 			done = 1;
    453 		else
    454 			if (RF_LOCKING_REQ(req)) {
    455 				if (RF_QUEUE_EMPTY(queue)) {	/* dispatch it */
    456 					Dprintf3("DiskIOComplete: dispatching pri %d locking req to r %d c %d (queue empty)\n", req->priority, queue->row, queue->col);
    457 					RF_LOCK_QUEUE(queue);
    458 					rf_DispatchKernelIO(queue, req);
    459 					done = 1;
    460 				} else {	/* put it aside to wait for
    461 						 * the queue to drain */
    462 					Dprintf3("DiskIOComplete: postponing pri %d locking req to r %d c %d\n", req->priority, queue->row, queue->col);
    463 					RF_ASSERT(queue->nextLockingOp == NULL);
    464 					queue->nextLockingOp = req;
    465 					done = 1;
    466 				}
    467 			} else
    468 				if (RF_UNLOCKING_REQ(req)) {	/* should not happen:
    469 								 * unlocking ops should
    470 								 * not get queued */
    471 					RF_ASSERT(RF_QUEUE_LOCKED(queue));	/* support it anyway for
    472 										 * the future */
    473 					Dprintf3("DiskIOComplete: dispatching pri %d unl req to r %d c %d (SHOULD NOT SEE THIS)\n", req->priority, queue->row, queue->col);
    474 					rf_DispatchKernelIO(queue, req);
    475 					done = 1;
    476 				} else
    477 					if (RF_OK_TO_DISPATCH(queue, req)) {
    478 						Dprintf3("DiskIOComplete: dispatching pri %d regular req to r %d c %d (ok to dispatch)\n", req->priority, queue->row, queue->col);
    479 						rf_DispatchKernelIO(queue, req);
    480 					} else {	/* we can't dispatch it,
    481 							 * so just re-enqueue
    482 							 * it.  */
    483 						/* potential trouble here if
    484 						 * disk queues batch reqs */
    485 						Dprintf3("DiskIOComplete: re-enqueueing pri %d regular req to r %d c %d\n", req->priority, queue->row, queue->col);
    486 						queue->queueLength++;
    487 						(queue->qPtr->Enqueue) (queue->qHdr, req, req->priority);
    488 						done = 1;
    489 					}
    490 	}
    491 
    492 	RF_UNLOCK_QUEUE_MUTEX(queue, "DiskIOComplete");
    493 }
    494 /* promotes accesses tagged with the given parityStripeID from low priority
    495  * to normal priority.  This promotion is optional, meaning that a queue
    496  * need not implement it.  If there is no promotion routine associated with
    497  * a queue, this routine does nothing and returns -1.
    498  */
    499 int
    500 rf_DiskIOPromote(queue, parityStripeID, which_ru)
    501 	RF_DiskQueue_t *queue;
    502 	RF_StripeNum_t parityStripeID;
    503 	RF_ReconUnitNum_t which_ru;
    504 {
    505 	int     retval;
    506 
    507 	if (!queue->qPtr->Promote)
    508 		return (-1);
    509 	RF_LOCK_QUEUE_MUTEX(queue, "DiskIOPromote");
    510 	retval = (queue->qPtr->Promote) (queue->qHdr, parityStripeID, which_ru);
    511 	RF_UNLOCK_QUEUE_MUTEX(queue, "DiskIOPromote");
    512 	return (retval);
    513 }
    514 
    515 RF_DiskQueueData_t *
    516 rf_CreateDiskQueueData(
    517     RF_IoType_t typ,
    518     RF_SectorNum_t ssect,
    519     RF_SectorCount_t nsect,
    520     caddr_t buf,
    521     RF_StripeNum_t parityStripeID,
    522     RF_ReconUnitNum_t which_ru,
    523     int (*wakeF) (void *, int),
    524     void *arg,
    525     RF_DiskQueueData_t * next,
    526     RF_AccTraceEntry_t * tracerec,
    527     void *raidPtr,
    528     RF_DiskQueueDataFlags_t flags,
    529     void *kb_proc)
    530 {
    531 	RF_DiskQueueData_t *p;
    532 
    533 	RF_FREELIST_GET_INIT(rf_dqd_freelist, p, next, (RF_DiskQueueData_t *), init_dqd);
    534 
    535 	p->sectorOffset = ssect + rf_protectedSectors;
    536 	p->numSector = nsect;
    537 	p->type = typ;
    538 	p->buf = buf;
    539 	p->parityStripeID = parityStripeID;
    540 	p->which_ru = which_ru;
    541 	p->CompleteFunc = wakeF;
    542 	p->argument = arg;
    543 	p->next = next;
    544 	p->tracerec = tracerec;
    545 	p->priority = RF_IO_NORMAL_PRIORITY;
    546 	p->AuxFunc = NULL;
    547 	p->buf2 = NULL;
    548 	p->raidPtr = raidPtr;
    549 	p->flags = flags;
    550 	p->b_proc = kb_proc;
    551 	return (p);
    552 }
    553 
    554 RF_DiskQueueData_t *
    555 rf_CreateDiskQueueDataFull(
    556     RF_IoType_t typ,
    557     RF_SectorNum_t ssect,
    558     RF_SectorCount_t nsect,
    559     caddr_t buf,
    560     RF_StripeNum_t parityStripeID,
    561     RF_ReconUnitNum_t which_ru,
    562     int (*wakeF) (void *, int),
    563     void *arg,
    564     RF_DiskQueueData_t * next,
    565     RF_AccTraceEntry_t * tracerec,
    566     int priority,
    567     int (*AuxFunc) (void *,...),
    568     caddr_t buf2,
    569     void *raidPtr,
    570     RF_DiskQueueDataFlags_t flags,
    571     void *kb_proc)
    572 {
    573 	RF_DiskQueueData_t *p;
    574 
    575 	RF_FREELIST_GET_INIT(rf_dqd_freelist, p, next, (RF_DiskQueueData_t *), init_dqd);
    576 
    577 	p->sectorOffset = ssect + rf_protectedSectors;
    578 	p->numSector = nsect;
    579 	p->type = typ;
    580 	p->buf = buf;
    581 	p->parityStripeID = parityStripeID;
    582 	p->which_ru = which_ru;
    583 	p->CompleteFunc = wakeF;
    584 	p->argument = arg;
    585 	p->next = next;
    586 	p->tracerec = tracerec;
    587 	p->priority = priority;
    588 	p->AuxFunc = AuxFunc;
    589 	p->buf2 = buf2;
    590 	p->raidPtr = raidPtr;
    591 	p->flags = flags;
    592 	p->b_proc = kb_proc;
    593 	return (p);
    594 }
    595 
    596 void
    597 rf_FreeDiskQueueData(p)
    598 	RF_DiskQueueData_t *p;
    599 {
    600 	RF_FREELIST_FREE_CLEAN(rf_dqd_freelist, p, next, clean_dqd);
    601 }
    602