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

1.30    ! oster       1: /*     $NetBSD: rf_diskqueue.h,v 1.29 2021/07/27 03:01:48 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.11      oster      41: #include <sys/queue.h>
                     42: 
1.6       oster      43: #include <dev/raidframe/raidframevar.h>
                     44: 
1.1       oster      45: #include "rf_threadstuff.h"
                     46: #include "rf_acctrace.h"
                     47: #include "rf_alloclist.h"
                     48: #include "rf_etimer.h"
                     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 */
1.22      christos   60:        void *buf;              /* buffer pointer */
1.3       oster      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 */
1.25      christos   65:        void    (*CompleteFunc) (void *, int);  /* function to be called upon
1.3       oster      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 buf *bp;         /* a bp to use to get this I/O done */
1.11      oster      78:        /* TAILQ bits for a queue for completed I/O requests */
1.20      perry      79:        TAILQ_ENTRY(RF_DiskQueueData_s) iodone_entries;
                     80:        int  error;             /* Indicate if an error occurred
1.11      oster      81:                                   on this I/O (1=yes, 0=no) */
1.1       oster      82: };
                     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: 
                     93:        /* the rest are optional:  they improve performance, but the driver
                     94:         * will deal with it if they don't exist */
                     95:        int     (*Promote) (void *, RF_StripeNum_t, RF_ReconUnitNum_t); /* promotes priority of
                     96:                                                                         * tagged accesses */
1.1       oster      97: };
                     98: 
                     99: struct RF_DiskQueue_s {
1.12      jdolecek  100:        const RF_DiskQueueSW_t *qPtr;   /* access point to queue functions */
1.3       oster     101:        void   *qHdr;           /* queue header, of whatever type */
1.24      mrg       102:        rf_declare_mutex2(mutex);/* mutex locking data structures */
1.3       oster     103:        long    numOutstanding; /* number of I/Os currently outstanding on
                    104:                                 * disk */
                    105:        long    maxOutstanding; /* max # of I/Os that can be outstanding on a
                    106:                                 * disk (in-kernel only) */
                    107:        int     curPriority;    /* the priority of accs all that are currently
                    108:                                 * outstanding */
                    109:        long    queueLength;    /* number of requests in queue */
                    110:        RF_DiskQueueFlags_t flags;      /* terminate, locked */
                    111:        RF_Raid_t *raidPtr;     /* associated array */
                    112:        dev_t   dev;            /* device number for kernel version */
                    113:        RF_SectorNum_t last_deq_sector; /* last sector number dequeued or
                    114:                                         * dispatched */
1.16      oster     115:        int     col;    /* debug only */
1.3       oster     116:        struct raidcinfo *rf_cinfo;     /* disks component info.. */
1.1       oster     117: };
1.3       oster     118: #define RF_DQ_LOCKED  0x02     /* no new accs allowed until queue is
                    119:                                 * explicitly unlocked */
1.1       oster     120: 
                    121: /* macros setting & returning information about queues and requests */
1.23      oster     122: #define RF_QUEUE_EMPTY(_q)                  ((_q)->numOutstanding == 0)
1.1       oster     123: #define RF_QUEUE_FULL(_q)                   ((_q)->numOutstanding == (_q)->maxOutstanding)
                    124: 
1.24      mrg       125: #define RF_LOCK_QUEUE_MUTEX(_q_,_wh_)   rf_lock_mutex2((_q_)->mutex)
                    126: #define RF_UNLOCK_QUEUE_MUTEX(_q_,_wh_) rf_unlock_mutex2((_q_)->mutex)
1.1       oster     127: 
                    128: /* whether it is ok to dispatch a regular request */
                    129: #define RF_OK_TO_DISPATCH(_q_,_r_) \
                    130:   (RF_QUEUE_EMPTY(_q_) || \
                    131:     (!RF_QUEUE_FULL(_q_) && ((_r_)->priority >= (_q_)->curPriority)))
                    132: 
1.27      oster     133: int rf_ConfigureDiskQueueSystem(RF_ShutdownList_t **, RF_Raid_t *, RF_Config_t *);
1.16      oster     134: int rf_ConfigureDiskQueues(RF_ShutdownList_t **, RF_Raid_t *, RF_Config_t *);
                    135: void rf_DiskIOEnqueue(RF_DiskQueue_t *, RF_DiskQueueData_t *, int);
                    136: void rf_DiskIOComplete(RF_DiskQueue_t *, RF_DiskQueueData_t *, int);
                    137: int rf_DiskIOPromote(RF_DiskQueue_t *, RF_StripeNum_t,  RF_ReconUnitNum_t);
                    138: RF_DiskQueueData_t *rf_CreateDiskQueueData(RF_IoType_t, RF_SectorNum_t,
1.22      christos  139:                                           RF_SectorCount_t , void *,
1.16      oster     140:                                           RF_StripeNum_t, RF_ReconUnitNum_t,
1.25      christos  141:                                           void (*wakeF) (void *, int),
1.19      oster     142:                                           void *,
1.17      oster     143:                                           RF_AccTraceEntry_t *, RF_Raid_t *,
1.20      perry     144:                                           RF_DiskQueueDataFlags_t,
1.29      oster     145:                                           const struct buf *);
1.16      oster     146: void rf_FreeDiskQueueData(RF_DiskQueueData_t *);
                    147: int rf_ConfigureDiskQueue(RF_Raid_t *, RF_DiskQueue_t *,
                    148:                          RF_RowCol_t, const RF_DiskQueueSW_t *,
1.20      perry     149:                          RF_SectorCount_t, dev_t, int,
1.16      oster     150:                          RF_ShutdownList_t **,
                    151:                          RF_AllocListElem_t *);
1.30    ! oster     152: int rf_UpdateDiskQueue(RF_DiskQueue_t *, RF_RaidDisk_t *);
1.1       oster     153: 
1.3       oster     154: #endif                         /* !_RF__RF_DISKQUEUE_H_ */

CVSweb <webmaster@jp.NetBSD.org>