[BACK]Return to rf_diskqueue.h CVS log [TXT][DIR] Up to [local] / sys / dev / raidframe

Annotation of sys/dev/raidframe/rf_diskqueue.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: rf_diskqueue.h,v 1.5 2002/12/16 07:01:03 tdeval Exp $ */
                      2: /*     $NetBSD: rf_diskqueue.h,v 1.5 2000/02/13 04:53:57 oster Exp $   */
                      3:
                      4: /*
                      5:  * Copyright (c) 1995 Carnegie-Mellon University.
                      6:  * All rights reserved.
                      7:  *
                      8:  * Author: Mark Holland
                      9:  *
                     10:  * Permission to use, copy, modify and distribute this software and
                     11:  * its documentation is hereby granted, provided that both the copyright
                     12:  * notice and this permission notice appear in all copies of the
                     13:  * software, derivative works or modified versions, and any portions
                     14:  * thereof, and that both notices appear in supporting documentation.
                     15:  *
                     16:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     17:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
                     18:  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     19:  *
                     20:  * Carnegie Mellon requests users of this software to return to
                     21:  *
                     22:  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
                     23:  *  School of Computer Science
                     24:  *  Carnegie Mellon University
                     25:  *  Pittsburgh PA 15213-3890
                     26:  *
                     27:  * any improvements or extensions that they make and grant Carnegie the
                     28:  * rights to redistribute these changes.
                     29:  */
                     30:
                     31: /*****************************************************************************
                     32:  *
                     33:  * rf_diskqueue.h -- Header file for disk queues.
                     34:  *
                     35:  * See comments in rf_diskqueue.c
                     36:  *
                     37:  *****************************************************************************/
                     38:
                     39:
                     40: #ifndef        _RF__RF_DISKQUEUE_H_
                     41: #define        _RF__RF_DISKQUEUE_H_
                     42:
                     43: #include "rf_threadstuff.h"
                     44: #include "rf_acctrace.h"
                     45: #include "rf_alloclist.h"
                     46: #include "rf_types.h"
                     47: #include "rf_etimer.h"
                     48:
                     49:
                     50: #if    defined(__NetBSD__)
                     51: #include "rf_netbsd.h"
                     52: #elif  defined(__OpenBSD__)
                     53: #include "rf_openbsd.h"
                     54: #endif
                     55:
                     56:
                     57: #define        RF_IO_NORMAL_PRIORITY   1
                     58: #define        RF_IO_LOW_PRIORITY      0
                     59:
                     60: /* The data held by a disk queue entry. */
                     61: struct RF_DiskQueueData_s {
                     62:        RF_SectorNum_t    sectorOffset; /* Sector offset into the disk. */
                     63:        RF_SectorCount_t  numSector;    /* Number of sectors to read/write. */
                     64:        RF_IoType_t       type;         /* Read/write/nop. */
                     65:        caddr_t           buf;          /* Buffer pointer. */
                     66:        RF_StripeNum_t    parityStripeID;
                     67:                                        /*
                     68:                                         * The RAID parity stripe ID this
                     69:                                         * access is for.
                     70:                                         */
                     71:        RF_ReconUnitNum_t which_ru;     /* Which RU within this parity stripe */
                     72:        int               priority;     /* The priority of this request. */
                     73:        int             (*CompleteFunc) (void *, int);
                     74:                                        /*
                     75:                                         * Function to be called upon
                     76:                                         * completion.
                     77:                                         */
                     78:        int             (*AuxFunc) (void *,...);
                     79:                                        /*
                     80:                                         * Function called upon completion
                     81:                                         * of the first I/O of a Read_Op_Write
                     82:                                         * pair.
                     83:                                         */
                     84:        void             *argument;     /*
                     85:                                         * Argument to be passed to
                     86:                                         * CompleteFunc.
                     87:                                         */
                     88:        RF_Raid_t        *raidPtr;      /* Needed for simulation. */
                     89:        RF_AccTraceEntry_t *tracerec;   /* Perf mon only. */
                     90:        RF_Etimer_t       qtime;        /*
                     91:                                         * Perf mon only - time request is
                     92:                                         * in queue.
                     93:                                         */
                     94:        long              entryTime;
                     95:        RF_DiskQueueData_t *next;
                     96:        RF_DiskQueueData_t *prev;
                     97:        caddr_t           buf2;         /* For read-op-write. */
                     98:        dev_t             dev;          /*
                     99:                                         * The device number for in-kernel
                    100:                                         * version.
                    101:                                         */
                    102:        RF_DiskQueue_t   *queue;        /*
                    103:                                         * The disk queue to which this req
                    104:                                         * is targeted.
                    105:                                         */
                    106:        RF_DiskQueueDataFlags_t flags;  /* Flags controlling operation. */
                    107:
                    108:        struct proc      *b_proc;       /*
                    109:                                         * The b_proc from the original bp
                    110:                                         * passed into the driver for this I/O.
                    111:                                         */
                    112:        struct buf       *bp;           /* A bp to use to get this I/O done. */
                    113: };
                    114: #define        RF_LOCK_DISK_QUEUE      0x01
                    115: #define        RF_UNLOCK_DISK_QUEUE    0x02
                    116:
                    117: /*
                    118:  * Note: "Create" returns type-specific queue header pointer cast to (void *).
                    119:  */
                    120: struct RF_DiskQueueSW_s {
                    121:        RF_DiskQueueType_t queueType;
                    122:        void            *(*Create) (RF_SectorCount_t, RF_AllocListElem_t *,
                    123:                            RF_ShutdownList_t **);
                    124:                                        /*
                    125:                                         * Creation routine -- one call per
                    126:                                         * queue in system.
                    127:                                         */
                    128:        void             (*Enqueue) (void *, RF_DiskQueueData_t *, int);
                    129:                                        /* Enqueue routine. */
                    130:        RF_DiskQueueData_t *(*Dequeue) (void *);
                    131:                                        /* Dequeue routine. */
                    132:        RF_DiskQueueData_t *(*Peek) (void *);
                    133:                                        /* Peek at head of queue. */
                    134:
                    135:        /*
                    136:         * The rest are optional:  they improve performance, but the driver
                    137:         * will deal with it if they don't exist.
                    138:         */
                    139:        int              (*Promote) (void *, RF_StripeNum_t, RF_ReconUnitNum_t);
                    140:                                        /*
                    141:                                         * Promotes priority of tagged
                    142:                                         * accesses.
                    143:                                         */
                    144: };
                    145:
                    146: struct RF_DiskQueue_s {
                    147:        RF_DiskQueueSW_t  *qPtr;        /* Access point to queue functions. */
                    148:        void              *qHdr;        /* Queue header, of whatever type. */
                    149:        RF_DECLARE_MUTEX(mutex);        /* Mutex locking data structures. */
                    150:        RF_DECLARE_COND(cond);          /*
                    151:                                         * Condition variable for
                    152:                                         * synchronization.
                    153:                                         */
                    154:        long               numOutstanding;
                    155:                                        /*
                    156:                                         * Number of I/Os currently
                    157:                                         * outstanding on disk.
                    158:                                         */
                    159:        long               maxOutstanding;
                    160:                                        /*
                    161:                                         * Max number of I/Os that can be
                    162:                                         * outstanding on a disk.
                    163:                                         * (in-kernel only)
                    164:                                         */
                    165:        int                curPriority; /*
                    166:                                         * The priority of accs all that are
                    167:                                         * currently outstanding.
                    168:                                         */
                    169:        long               queueLength; /* Number of requests in queue. */
                    170:        RF_DiskQueueData_t *nextLockingOp;
                    171:                                        /*
                    172:                                         * A locking op that has arrived at
                    173:                                         * the head of the queue & is waiting
                    174:                                         * for drainage.
                    175:                                         */
                    176:        RF_DiskQueueData_t *unlockingOp;/*
                    177:                                         * Used at user level to communicate
                    178:                                         * unlocking op b/w user (or dag exec)
                    179:                                         * & disk threads.
                    180:                                         */
                    181:        int                numWaiting;  /*
                    182:                                         * Number of threads waiting on
                    183:                                         * this variable.
                    184:                                         * (user-level only)
                    185:                                         */
                    186:        RF_DiskQueueFlags_t flags;      /* Terminate, locked. */
                    187:        RF_Raid_t         *raidPtr;     /* Associated array. */
                    188:        dev_t              dev;         /* Device number for kernel version. */
                    189:        RF_SectorNum_t     last_deq_sector;
                    190:                                        /*
                    191:                                         * Last sector number dequeued or
                    192:                                         * dispatched.
                    193:                                         */
                    194:        int                row, col;    /* Debug only. */
                    195:        struct raidcinfo  *rf_cinfo;    /* Disks component info... */
                    196: };
                    197:
                    198: /* No new accs allowed until queue is explicitly unlocked. */
                    199: #define        RF_DQ_LOCKED    0x02
                    200:
                    201: /* Macros setting & returning information about queues and requests. */
                    202: #define        RF_QUEUE_LOCKED(_q)             ((_q)->flags & RF_DQ_LOCKED)
                    203: #define        RF_QUEUE_EMPTY(_q)              (((_q)->numOutstanding == 0) && \
                    204:                                         ((_q)->nextLockingOp == NULL) && \
                    205:                                         !RF_QUEUE_LOCKED(_q))
                    206: #define        RF_QUEUE_FULL(_q)               ((_q)->numOutstanding ==        \
                    207:                                         (_q)->maxOutstanding)
                    208:
                    209: #define        RF_LOCK_QUEUE(_q)               (_q)->flags |= RF_DQ_LOCKED
                    210: #define        RF_UNLOCK_QUEUE(_q)             (_q)->flags &= ~RF_DQ_LOCKED
                    211:
                    212: #define        RF_LOCK_QUEUE_MUTEX(_q_,_wh_)   RF_LOCK_MUTEX((_q_)->mutex)
                    213: #define        RF_UNLOCK_QUEUE_MUTEX(_q_,_wh_) RF_UNLOCK_MUTEX((_q_)->mutex)
                    214:
                    215: #define        RF_LOCKING_REQ(_r)              ((_r)->flags & RF_LOCK_DISK_QUEUE)
                    216: #define        RF_UNLOCKING_REQ(_r)            ((_r)->flags & RF_UNLOCK_DISK_QUEUE)
                    217:
                    218: /* Whether it is ok to dispatch a regular request. */
                    219: #define        RF_OK_TO_DISPATCH(_q_,_r_)                                      \
                    220:        (RF_QUEUE_EMPTY(_q_) ||                                         \
                    221:        ( !RF_QUEUE_FULL(_q_) && ((_r_)->priority >= (_q_)->curPriority)))
                    222:
                    223: int  rf_ConfigureDiskQueueSystem(RF_ShutdownList_t **);
                    224:
                    225: void rf_TerminateDiskQueues(RF_Raid_t *);
                    226:
                    227: int  rf_ConfigureDiskQueues(RF_ShutdownList_t **, RF_Raid_t *, RF_Config_t *);
                    228:
                    229: void rf_DiskIOEnqueue(RF_DiskQueue_t *, RF_DiskQueueData_t *, int);
                    230:
                    231: void rf_DiskIOComplete(RF_DiskQueue_t *, RF_DiskQueueData_t *, int);
                    232:
                    233: int  rf_DiskIOPromote(RF_DiskQueue_t *, RF_StripeNum_t, RF_ReconUnitNum_t);
                    234:
                    235: RF_DiskQueueData_t *rf_CreateDiskQueueData(RF_IoType_t, RF_SectorNum_t,
                    236:        RF_SectorCount_t, caddr_t, RF_StripeNum_t, RF_ReconUnitNum_t,
                    237:        int (*) (void *, int), void *, RF_DiskQueueData_t *,
                    238:        RF_AccTraceEntry_t *, void *, RF_DiskQueueDataFlags_t, void *);
                    239:
                    240: RF_DiskQueueData_t *rf_CreateDiskQueueDataFull(RF_IoType_t, RF_SectorNum_t,
                    241:        RF_SectorCount_t, caddr_t, RF_StripeNum_t, RF_ReconUnitNum_t,
                    242:        int (*) (void *, int), void *, RF_DiskQueueData_t *,
                    243:        RF_AccTraceEntry_t *, int, int (*) (void *,...), caddr_t, void *,
                    244:        RF_DiskQueueDataFlags_t, void *);
                    245:
                    246: void rf_FreeDiskQueueData(RF_DiskQueueData_t *);
                    247:
                    248: int  rf_ConfigureDiskQueue(RF_Raid_t *, RF_DiskQueue_t *, RF_RowCol_t,
                    249:        RF_RowCol_t, RF_DiskQueueSW_t *, RF_SectorCount_t, dev_t, int,
                    250:        RF_ShutdownList_t **, RF_AllocListElem_t *);
                    251:
                    252: #endif /* ! _RF__RF_DISKQUEUE_H_ */

CVSweb