Annotation of src/sys/dev/raidframe/rf_diskqueue.h, revision 1.3
1.3 ! oster 1: /* $NetBSD: rf_diskqueue.h,v 1.2 1999/01/26 02:33:56 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:
29: /*****************************************************************************************
30: *
31: * rf_diskqueue.h -- header file for disk queues
32: *
33: * see comments in rf_diskqueue.c
34: *
35: ****************************************************************************************/
36:
37:
38: #ifndef _RF__RF_DISKQUEUE_H_
39: #define _RF__RF_DISKQUEUE_H_
40:
41: #include "rf_threadstuff.h"
42: #include "rf_acctrace.h"
43: #include "rf_alloclist.h"
44: #include "rf_types.h"
45: #include "rf_etimer.h"
46:
47:
48: #include "rf_netbsd.h"
49:
50:
51: #define RF_IO_NORMAL_PRIORITY 1
52: #define RF_IO_LOW_PRIORITY 0
53:
54: /* the data held by a disk queue entry */
55: struct RF_DiskQueueData_s {
1.3 ! oster 56: RF_SectorNum_t sectorOffset; /* sector offset into the disk */
! 57: RF_SectorCount_t numSector; /* number of sectors to read/write */
! 58: RF_IoType_t type; /* read/write/nop */
! 59: caddr_t buf; /* buffer pointer */
! 60: RF_StripeNum_t parityStripeID; /* the RAID parity stripe ID this
! 61: * access is for */
! 62: RF_ReconUnitNum_t which_ru; /* which RU within this parity stripe */
! 63: int priority; /* the priority of this request */
! 64: int (*CompleteFunc) (void *, int); /* function to be called upon
! 65: * completion */
! 66: int (*AuxFunc) (void *,...); /* function called upon
! 67: * completion of the first I/O
! 68: * of a Read_Op_Write pair */
! 69: void *argument; /* argument to be passed to CompleteFunc */
! 70: void *raidPtr; /* needed for simulation */
! 71: RF_AccTraceEntry_t *tracerec; /* perf mon only */
! 72: RF_Etimer_t qtime; /* perf mon only - time request is in queue */
! 73: long entryTime;
! 74: RF_DiskQueueData_t *next;
! 75: RF_DiskQueueData_t *prev;
! 76: caddr_t buf2; /* for read-op-write */
! 77: dev_t dev; /* the device number for in-kernel version */
! 78: RF_DiskQueue_t *queue; /* the disk queue to which this req is
! 79: * targeted */
! 80: RF_DiskQueueDataFlags_t flags; /* flags controlling operation */
! 81:
! 82: struct proc *b_proc; /* the b_proc from the original bp passed into
! 83: * the driver for this I/O */
! 84: struct buf *bp; /* a bp to use to get this I/O done */
1.1 oster 85: };
86: #define RF_LOCK_DISK_QUEUE 0x01
87: #define RF_UNLOCK_DISK_QUEUE 0x02
88:
89: /* note: "Create" returns type-specific queue header pointer cast to (void *) */
90: struct RF_DiskQueueSW_s {
1.3 ! oster 91: RF_DiskQueueType_t queueType;
! 92: void *(*Create) (RF_SectorCount_t, RF_AllocListElem_t *, RF_ShutdownList_t **); /* creation routine --
! 93: * one call per queue in
! 94: * system */
! 95: void (*Enqueue) (void *, RF_DiskQueueData_t *, int); /* enqueue routine */
! 96: RF_DiskQueueData_t *(*Dequeue) (void *); /* dequeue routine */
! 97: RF_DiskQueueData_t *(*Peek) (void *); /* peek at head of queue */
! 98:
! 99: /* the rest are optional: they improve performance, but the driver
! 100: * will deal with it if they don't exist */
! 101: int (*Promote) (void *, RF_StripeNum_t, RF_ReconUnitNum_t); /* promotes priority of
! 102: * tagged accesses */
1.1 oster 103: };
104:
105: struct RF_DiskQueue_s {
1.3 ! oster 106: RF_DiskQueueSW_t *qPtr; /* access point to queue functions */
! 107: void *qHdr; /* queue header, of whatever type */
! 108: RF_DECLARE_MUTEX(mutex) /* mutex locking data structures */
! 109: RF_DECLARE_COND(cond) /* condition variable for
! 110: * synchronization */
! 111: long numOutstanding; /* number of I/Os currently outstanding on
! 112: * disk */
! 113: long maxOutstanding; /* max # of I/Os that can be outstanding on a
! 114: * disk (in-kernel only) */
! 115: int curPriority; /* the priority of accs all that are currently
! 116: * outstanding */
! 117: long queueLength; /* number of requests in queue */
! 118: RF_DiskQueueData_t *nextLockingOp; /* a locking op that has
! 119: * arrived at the head of the
! 120: * queue & is waiting for
! 121: * drainage */
! 122: RF_DiskQueueData_t *unlockingOp; /* used at user level to
! 123: * communicate unlocking op
! 124: * b/w user (or dag exec) &
! 125: * disk threads */
! 126: int numWaiting; /* number of threads waiting on this variable.
! 127: * user-level only */
! 128: RF_DiskQueueFlags_t flags; /* terminate, locked */
! 129: RF_Raid_t *raidPtr; /* associated array */
! 130: dev_t dev; /* device number for kernel version */
! 131: RF_SectorNum_t last_deq_sector; /* last sector number dequeued or
! 132: * dispatched */
! 133: int row, col; /* debug only */
! 134: struct raidcinfo *rf_cinfo; /* disks component info.. */
1.1 oster 135: };
1.3 ! oster 136: #define RF_DQ_LOCKED 0x02 /* no new accs allowed until queue is
! 137: * explicitly unlocked */
1.1 oster 138:
139: /* macros setting & returning information about queues and requests */
140: #define RF_QUEUE_LOCKED(_q) ((_q)->flags & RF_DQ_LOCKED)
141: #define RF_QUEUE_EMPTY(_q) (((_q)->numOutstanding == 0) && ((_q)->nextLockingOp == NULL) && !RF_QUEUE_LOCKED(_q))
142: #define RF_QUEUE_FULL(_q) ((_q)->numOutstanding == (_q)->maxOutstanding)
143:
144: #define RF_LOCK_QUEUE(_q) (_q)->flags |= RF_DQ_LOCKED
145: #define RF_UNLOCK_QUEUE(_q) (_q)->flags &= ~RF_DQ_LOCKED
146:
147: #define RF_LOCK_QUEUE_MUTEX(_q_,_wh_) RF_LOCK_MUTEX((_q_)->mutex)
148: #define RF_UNLOCK_QUEUE_MUTEX(_q_,_wh_) RF_UNLOCK_MUTEX((_q_)->mutex)
149:
150: #define RF_LOCKING_REQ(_r) ((_r)->flags & RF_LOCK_DISK_QUEUE)
151: #define RF_UNLOCKING_REQ(_r) ((_r)->flags & RF_UNLOCK_DISK_QUEUE)
152:
153: /* whether it is ok to dispatch a regular request */
154: #define RF_OK_TO_DISPATCH(_q_,_r_) \
155: (RF_QUEUE_EMPTY(_q_) || \
156: (!RF_QUEUE_FULL(_q_) && ((_r_)->priority >= (_q_)->curPriority)))
157:
1.3 ! oster 158: int rf_ConfigureDiskQueueSystem(RF_ShutdownList_t ** listp);
1.1 oster 159:
1.3 ! oster 160: void rf_TerminateDiskQueues(RF_Raid_t * raidPtr);
1.1 oster 161:
1.3 ! oster 162: int
! 163: rf_ConfigureDiskQueues(RF_ShutdownList_t ** listp, RF_Raid_t * raidPtr,
! 164: RF_Config_t * cfgPtr);
1.1 oster 165:
1.3 ! oster 166: void rf_DiskIOEnqueue(RF_DiskQueue_t * queue, RF_DiskQueueData_t * req, int pri);
1.1 oster 167:
1.2 oster 168:
1.3 ! oster 169: void rf_DiskIOComplete(RF_DiskQueue_t * queue, RF_DiskQueueData_t * req, int status);
1.1 oster 170:
1.3 ! oster 171: int
! 172: rf_DiskIOPromote(RF_DiskQueue_t * queue, RF_StripeNum_t parityStripeID,
! 173: RF_ReconUnitNum_t which_ru);
1.1 oster 174:
1.3 ! oster 175: RF_DiskQueueData_t *
! 176: rf_CreateDiskQueueData(RF_IoType_t typ,
! 177: RF_SectorNum_t ssect, RF_SectorCount_t nsect, caddr_t buf,
! 178: RF_StripeNum_t parityStripeID, RF_ReconUnitNum_t which_ru,
! 179: int (*wakeF) (void *, int),
! 180: void *arg, RF_DiskQueueData_t * next, RF_AccTraceEntry_t * tracerec,
! 181: void *raidPtr, RF_DiskQueueDataFlags_t flags, void *kb_proc);
1.1 oster 182:
1.3 ! oster 183: RF_DiskQueueData_t *rf_CreateDiskQueueDataFull(RF_IoType_t typ,
! 184: RF_SectorNum_t ssect, RF_SectorCount_t nsect, caddr_t buf,
! 185: RF_StripeNum_t parityStripeID, RF_ReconUnitNum_t which_ru,
! 186: int (*wakeF) (void *, int),
! 187: void *arg, RF_DiskQueueData_t * next, RF_AccTraceEntry_t * tracerec,
! 188: int priority, int (*AuxFunc) (void *,...), caddr_t buf2,
! 189: void *raidPtr, RF_DiskQueueDataFlags_t flags, void *kb_proc);
1.1 oster 190:
1.3 ! oster 191: void rf_FreeDiskQueueData(RF_DiskQueueData_t * p);
1.1 oster 192:
1.3 ! oster 193: #endif /* !_RF__RF_DISKQUEUE_H_ */
CVSweb <webmaster@jp.NetBSD.org>