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

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

CVSweb <webmaster@jp.NetBSD.org>