Annotation of src/sys/dev/raidframe/rf_diskqueue.h, revision 1.1

1.1     ! oster       1: /*     $NetBSD$        */
        !             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:  * :  
        !            39:  *
        !            40:  * Log: rf_diskqueue.h,v 
        !            41:  * Revision 1.31  1996/08/07 21:08:49  jimz
        !            42:  * b_proc -> kb_proc (IRIX complained)
        !            43:  *
        !            44:  * Revision 1.30  1996/06/18  20:53:11  jimz
        !            45:  * fix up disk queueing (remove configure routine,
        !            46:  * add shutdown list arg to create routines)
        !            47:  *
        !            48:  * Revision 1.29  1996/06/13  20:38:19  jimz
        !            49:  * fix queue type in DiskQueueData
        !            50:  *
        !            51:  * Revision 1.28  1996/06/10  11:55:47  jimz
        !            52:  * Straightened out some per-array/not-per-array distinctions, fixed
        !            53:  * a couple bugs related to confusion. Added shutdown lists. Removed
        !            54:  * layout shutdown function (now subsumed by shutdown lists).
        !            55:  *
        !            56:  * Revision 1.27  1996/06/07  22:26:27  jimz
        !            57:  * type-ify which_ru (RF_ReconUnitNum_t)
        !            58:  *
        !            59:  * Revision 1.26  1996/06/07  21:33:04  jimz
        !            60:  * begin using consistent types for sector numbers,
        !            61:  * stripe numbers, row+col numbers, recon unit numbers
        !            62:  *
        !            63:  * Revision 1.25  1996/06/06  17:29:12  jimz
        !            64:  * track arm position of last I/O dequeued
        !            65:  *
        !            66:  * Revision 1.24  1996/06/05  18:06:02  jimz
        !            67:  * Major code cleanup. The Great Renaming is now done.
        !            68:  * Better modularity. Better typing. Fixed a bunch of
        !            69:  * synchronization bugs. Made a lot of global stuff
        !            70:  * per-desc or per-array. Removed dead code.
        !            71:  *
        !            72:  * Revision 1.23  1996/06/02  17:31:48  jimz
        !            73:  * Moved a lot of global stuff into array structure, where it belongs.
        !            74:  * Fixed up paritylogging, pss modules in this manner. Some general
        !            75:  * code cleanup. Removed lots of dead code, some dead files.
        !            76:  *
        !            77:  * Revision 1.22  1996/05/30  23:22:16  jimz
        !            78:  * bugfixes of serialization, timing problems
        !            79:  * more cleanup
        !            80:  *
        !            81:  * Revision 1.21  1996/05/30  11:29:41  jimz
        !            82:  * Numerous bug fixes. Stripe lock release code disagreed with the taking code
        !            83:  * about when stripes should be locked (I made it consistent: no parity, no lock)
        !            84:  * There was a lot of extra serialization of I/Os which I've removed- a lot of
        !            85:  * it was to calculate values for the cache code, which is no longer with us.
        !            86:  * More types, function, macro cleanup. Added code to properly quiesce the array
        !            87:  * on shutdown. Made a lot of stuff array-specific which was (bogusly) general
        !            88:  * before. Fixed memory allocation, freeing bugs.
        !            89:  *
        !            90:  * Revision 1.20  1996/05/24  22:17:04  jimz
        !            91:  * continue code + namespace cleanup
        !            92:  * typed a bunch of flags
        !            93:  *
        !            94:  * Revision 1.19  1996/05/24  01:59:45  jimz
        !            95:  * another checkpoint in code cleanup for release
        !            96:  * time to sync kernel tree
        !            97:  *
        !            98:  * Revision 1.18  1996/05/23  21:46:35  jimz
        !            99:  * checkpoint in code cleanup (release prep)
        !           100:  * lots of types, function names have been fixed
        !           101:  *
        !           102:  * Revision 1.17  1996/05/23  00:33:23  jimz
        !           103:  * code cleanup: move all debug decls to rf_options.c, all extern
        !           104:  * debug decls to rf_options.h, all debug vars preceded by rf_
        !           105:  *
        !           106:  * Revision 1.16  1996/05/18  19:51:34  jimz
        !           107:  * major code cleanup- fix syntax, make some types consistent,
        !           108:  * add prototypes, clean out dead code, et cetera
        !           109:  *
        !           110:  * Revision 1.15  1996/05/10  19:39:31  jimz
        !           111:  * add prev pointer to DiskQueueData
        !           112:  *
        !           113:  * Revision 1.14  1996/05/10  16:24:04  jimz
        !           114:  * mark old defines as deprecated, add RF_ defines
        !           115:  *
        !           116:  * Revision 1.13  1995/12/01  15:59:04  root
        !           117:  * added copyright info
        !           118:  *
        !           119:  * Revision 1.12  1995/11/07  16:26:44  wvcii
        !           120:  * added Peek() function to diskqueuesw
        !           121:  *
        !           122:  * Revision 1.11  1995/10/05  02:33:15  jimz
        !           123:  * made queue lens longs (less instructions to read :-)
        !           124:  *
        !           125:  * Revision 1.10  1995/10/04  07:07:07  wvcii
        !           126:  * queue->numOutstanding now valid for user & sim
        !           127:  * user tested & verified, sim untested
        !           128:  *
        !           129:  * Revision 1.9  1995/09/12  00:21:37  wvcii
        !           130:  * added support for tracing disk queue time
        !           131:  *
        !           132:  * Revision 1.8  95/04/24  13:25:51  holland
        !           133:  * rewrite to move disk queues, recon, & atomic RMW to kernel
        !           134:  * 
        !           135:  * Revision 1.6.10.2  1995/04/03  20:13:56  holland
        !           136:  * added numOutstanding and maxOutstanding to support moving
        !           137:  * disk queues into kernel code
        !           138:  *
        !           139:  * Revision 1.6.10.1  1995/04/03  20:03:56  holland
        !           140:  * initial checkin on branch
        !           141:  *
        !           142:  * Revision 1.6  1995/03/03  18:34:33  rachad
        !           143:  * Simulator mechanism added
        !           144:  *
        !           145:  * Revision 1.5  1995/03/01  20:25:48  holland
        !           146:  * kernelization changes
        !           147:  *
        !           148:  * Revision 1.4  1995/02/03  22:31:36  holland
        !           149:  * many changes related to kernelization
        !           150:  *
        !           151:  * Revision 1.3  1995/02/01  14:25:19  holland
        !           152:  * began changes for kernelization:
        !           153:  *      changed all instances of mutex_t and cond_t to DECLARE macros
        !           154:  *      converted configuration code to use config structure
        !           155:  *
        !           156:  * Revision 1.2  1994/11/29  20:36:02  danner
        !           157:  * Added symbolic constants for io_type (e.g,IO_TYPE_READ)
        !           158:  * and support for READ_OP_WRITE
        !           159:  *
        !           160:  */
        !           161: 
        !           162: 
        !           163: #ifndef _RF__RF_DISKQUEUE_H_
        !           164: #define _RF__RF_DISKQUEUE_H_
        !           165: 
        !           166: #include "rf_threadstuff.h"
        !           167: #include "rf_acctrace.h"
        !           168: #include "rf_alloclist.h"
        !           169: #include "rf_types.h"
        !           170: #include "rf_etimer.h"
        !           171: 
        !           172: 
        !           173: #if defined(__NetBSD__) && defined(_KERNEL)
        !           174: #include "rf_netbsd.h"
        !           175: #endif
        !           176: 
        !           177: 
        !           178: #define RF_IO_NORMAL_PRIORITY 1
        !           179: #define RF_IO_LOW_PRIORITY    0
        !           180: 
        !           181: /* the data held by a disk queue entry */
        !           182: struct RF_DiskQueueData_s {
        !           183:   RF_SectorNum_t           sectorOffset;   /* sector offset into the disk */
        !           184:   RF_SectorCount_t         numSector;      /* number of sectors to read/write */
        !           185:   RF_IoType_t              type;           /* read/write/nop */
        !           186:   caddr_t                  buf;            /* buffer pointer */
        !           187:   RF_StripeNum_t           parityStripeID; /* the RAID parity stripe ID this access is for */
        !           188:   RF_ReconUnitNum_t        which_ru;       /* which RU within this parity stripe */
        !           189:   int                      priority;       /* the priority of this request */
        !           190:   int                    (*CompleteFunc)(void *,int);/* function to be called upon completion */
        !           191:   int                    (*AuxFunc)(void *,...); /* function called upon completion of the first I/O of a Read_Op_Write pair*/
        !           192:   void                    *argument;       /* argument to be passed to CompleteFunc */
        !           193: #ifdef SIMULATE
        !           194:   RF_Owner_t               owner;          /* which task is responsible for this request */
        !           195: #endif /* SIMULATE */
        !           196:   void                    *raidPtr;        /* needed for simulation */
        !           197:   RF_AccTraceEntry_t      *tracerec;       /* perf mon only */
        !           198:   RF_Etimer_t              qtime;          /* perf mon only - time request is in queue */
        !           199:   long                     entryTime;
        !           200:   RF_DiskQueueData_t      *next;
        !           201:   RF_DiskQueueData_t      *prev;
        !           202:   caddr_t                  buf2;   /* for read-op-write */
        !           203:   dev_t                    dev;    /* the device number for in-kernel version */
        !           204:   RF_DiskQueue_t          *queue;  /* the disk queue to which this req is targeted */
        !           205:   RF_DiskQueueDataFlags_t  flags;  /* flags controlling operation */
        !           206:   
        !           207: #ifdef KERNEL
        !           208:   struct proc             *b_proc;  /* the b_proc from the original bp passed into the driver for this I/O */
        !           209:   struct buf              *bp;      /* a bp to use to get this I/O done */
        !           210: #endif /* KERNEL */
        !           211: };
        !           212: 
        !           213: #define RF_LOCK_DISK_QUEUE   0x01
        !           214: #define RF_UNLOCK_DISK_QUEUE 0x02
        !           215: 
        !           216: /* note: "Create" returns type-specific queue header pointer cast to (void *) */
        !           217: struct RF_DiskQueueSW_s {
        !           218:   RF_DiskQueueType_t     queueType;
        !           219:   void                *(*Create)(RF_SectorCount_t, RF_AllocListElem_t *, RF_ShutdownList_t **);    /* creation routine -- one call per queue in system */
        !           220:   void                 (*Enqueue)(void *,RF_DiskQueueData_t * ,int);   /* enqueue routine */
        !           221:   RF_DiskQueueData_t  *(*Dequeue)(void *);   /* dequeue routine */
        !           222:   RF_DiskQueueData_t  *(*Peek)(void *);      /* peek at head of queue */
        !           223: 
        !           224:   /* the rest are optional:  they improve performance, but the driver will deal with it if they don't exist */
        !           225:   int                  (*Promote)(void *, RF_StripeNum_t, RF_ReconUnitNum_t);   /* promotes priority of tagged accesses */
        !           226: };
        !           227: 
        !           228: struct RF_DiskQueue_s {
        !           229:   RF_DiskQueueSW_t    *qPtr;             /* access point to queue functions */
        !           230:   void                *qHdr;             /* queue header, of whatever type */
        !           231:   RF_DECLARE_MUTEX(mutex)                /* mutex locking data structures */
        !           232:   RF_DECLARE_COND(cond)                  /* condition variable for synchronization */
        !           233:   long                 numOutstanding;   /* number of I/Os currently outstanding on disk */
        !           234:   long                 maxOutstanding;   /* max # of I/Os that can be outstanding on a disk (in-kernel only) */
        !           235:   int                  curPriority;      /* the priority of accs all that are currently outstanding */
        !           236:   long                 queueLength;      /* number of requests in queue */
        !           237:   RF_DiskQueueData_t  *nextLockingOp;    /* a locking op that has arrived at the head of the queue & is waiting for drainage */
        !           238:   RF_DiskQueueData_t  *unlockingOp;      /* used at user level to communicate unlocking op b/w user (or dag exec) & disk threads */
        !           239:   int                  numWaiting;       /* number of threads waiting on this variable.  user-level only */
        !           240:   RF_DiskQueueFlags_t  flags;            /* terminate, locked */
        !           241:   RF_Raid_t           *raidPtr;          /* associated array */
        !           242:   dev_t                dev;              /* device number for kernel version */
        !           243:   RF_SectorNum_t       last_deq_sector;  /* last sector number dequeued or dispatched */
        !           244:   int                  row, col;         /* debug only */
        !           245: #if defined(__NetBSD__) && defined(_KERNEL)
        !           246:   struct raidcinfo *rf_cinfo;      /* disks component info.. */
        !           247: #endif
        !           248: };
        !           249: 
        !           250: #define RF_DQ_LOCKED  0x02  /* no new accs allowed until queue is explicitly unlocked */
        !           251: 
        !           252: /* macros setting & returning information about queues and requests */
        !           253: #define RF_QUEUE_LOCKED(_q)                 ((_q)->flags & RF_DQ_LOCKED)
        !           254: #define RF_QUEUE_EMPTY(_q)                  (((_q)->numOutstanding == 0) && ((_q)->nextLockingOp == NULL) && !RF_QUEUE_LOCKED(_q))
        !           255: #define RF_QUEUE_FULL(_q)                   ((_q)->numOutstanding == (_q)->maxOutstanding)
        !           256: 
        !           257: #define RF_LOCK_QUEUE(_q)                   (_q)->flags |= RF_DQ_LOCKED
        !           258: #define RF_UNLOCK_QUEUE(_q)                 (_q)->flags &= ~RF_DQ_LOCKED
        !           259: 
        !           260: #define RF_LOCK_QUEUE_MUTEX(_q_,_wh_)   RF_LOCK_MUTEX((_q_)->mutex)
        !           261: #define RF_UNLOCK_QUEUE_MUTEX(_q_,_wh_) RF_UNLOCK_MUTEX((_q_)->mutex)
        !           262: 
        !           263: #define RF_LOCKING_REQ(_r)                  ((_r)->flags & RF_LOCK_DISK_QUEUE)
        !           264: #define RF_UNLOCKING_REQ(_r)                ((_r)->flags & RF_UNLOCK_DISK_QUEUE)
        !           265: 
        !           266: /* whether it is ok to dispatch a regular request */
        !           267: #define RF_OK_TO_DISPATCH(_q_,_r_) \
        !           268:   (RF_QUEUE_EMPTY(_q_) || \
        !           269:     (!RF_QUEUE_FULL(_q_) && ((_r_)->priority >= (_q_)->curPriority)))
        !           270: 
        !           271: int rf_ConfigureDiskQueueSystem(RF_ShutdownList_t **listp);
        !           272: 
        !           273: void rf_TerminateDiskQueues(RF_Raid_t *raidPtr);
        !           274: 
        !           275: int rf_ConfigureDiskQueues(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
        !           276:        RF_Config_t *cfgPtr);
        !           277: 
        !           278: void rf_DiskIOEnqueue(RF_DiskQueue_t *queue, RF_DiskQueueData_t *req, int pri);
        !           279: 
        !           280: #if !defined(KERNEL) && !defined(SIMULATE)
        !           281: void rf_BroadcastOnQueue(RF_DiskQueue_t *queue);
        !           282: #endif /* !KERNEL && !SIMULATE */
        !           283: 
        !           284: #ifndef KERNEL
        !           285: RF_DiskQueueData_t *rf_DiskIODequeue(RF_DiskQueue_t *queue);
        !           286: #else /* !KERNEL */
        !           287: void rf_DiskIOComplete(RF_DiskQueue_t *queue, RF_DiskQueueData_t *req, int status);
        !           288: #endif /* !KERNEL */
        !           289: 
        !           290: int rf_DiskIOPromote(RF_DiskQueue_t *queue, RF_StripeNum_t parityStripeID,
        !           291:        RF_ReconUnitNum_t which_ru);
        !           292: 
        !           293: RF_DiskQueueData_t *rf_CreateDiskQueueData(RF_IoType_t typ,
        !           294:        RF_SectorNum_t ssect, RF_SectorCount_t nsect, caddr_t buf,
        !           295:        RF_StripeNum_t parityStripeID, RF_ReconUnitNum_t which_ru, 
        !           296:         int (*wakeF)(void *, int),
        !           297:        void *arg, RF_DiskQueueData_t *next, RF_AccTraceEntry_t *tracerec,
        !           298:        void *raidPtr, RF_DiskQueueDataFlags_t flags, void *kb_proc);
        !           299: 
        !           300: RF_DiskQueueData_t *rf_CreateDiskQueueDataFull(RF_IoType_t typ,
        !           301:        RF_SectorNum_t ssect, RF_SectorCount_t nsect, caddr_t buf,
        !           302:        RF_StripeNum_t parityStripeID, RF_ReconUnitNum_t which_ru, 
        !           303:         int (*wakeF)(void *, int),
        !           304:        void *arg, RF_DiskQueueData_t *next, RF_AccTraceEntry_t *tracerec,
        !           305:        int priority, int (*AuxFunc)(void *,...), caddr_t buf2,
        !           306:        void *raidPtr, RF_DiskQueueDataFlags_t flags, void *kb_proc);
        !           307: 
        !           308: void rf_FreeDiskQueueData(RF_DiskQueueData_t *p);
        !           309: 
        !           310: #endif /* !_RF__RF_DISKQUEUE_H_ */

CVSweb <webmaster@jp.NetBSD.org>