Home | History | Annotate | Line # | Download | only in raidframe
rf_raid.h revision 1.2
      1  1.2  oster /*	$NetBSD: rf_raid.h,v 1.2 1999/01/26 02:34:00 oster Exp $	*/
      2  1.1  oster /*
      3  1.1  oster  * Copyright (c) 1995 Carnegie-Mellon University.
      4  1.1  oster  * All rights reserved.
      5  1.1  oster  *
      6  1.1  oster  * Author: Mark Holland
      7  1.1  oster  *
      8  1.1  oster  * Permission to use, copy, modify and distribute this software and
      9  1.1  oster  * its documentation is hereby granted, provided that both the copyright
     10  1.1  oster  * notice and this permission notice appear in all copies of the
     11  1.1  oster  * software, derivative works or modified versions, and any portions
     12  1.1  oster  * thereof, and that both notices appear in supporting documentation.
     13  1.1  oster  *
     14  1.1  oster  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     15  1.1  oster  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     16  1.1  oster  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     17  1.1  oster  *
     18  1.1  oster  * Carnegie Mellon requests users of this software to return to
     19  1.1  oster  *
     20  1.1  oster  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     21  1.1  oster  *  School of Computer Science
     22  1.1  oster  *  Carnegie Mellon University
     23  1.1  oster  *  Pittsburgh PA 15213-3890
     24  1.1  oster  *
     25  1.1  oster  * any improvements or extensions that they make and grant Carnegie the
     26  1.1  oster  * rights to redistribute these changes.
     27  1.1  oster  */
     28  1.1  oster 
     29  1.1  oster /**********************************************
     30  1.1  oster  * rf_raid.h -- main header file for RAID driver
     31  1.1  oster  **********************************************/
     32  1.1  oster 
     33  1.1  oster 
     34  1.1  oster #ifndef _RF__RF_RAID_H_
     35  1.1  oster #define _RF__RF_RAID_H_
     36  1.1  oster 
     37  1.1  oster #include "rf_archs.h"
     38  1.1  oster #include "rf_types.h"
     39  1.1  oster #include "rf_threadstuff.h"
     40  1.1  oster 
     41  1.1  oster #include "rf_netbsd.h"
     42  1.1  oster 
     43  1.1  oster #include <sys/disklabel.h>
     44  1.1  oster #include <sys/types.h>
     45  1.1  oster 
     46  1.1  oster #include "rf_alloclist.h"
     47  1.1  oster #include "rf_stripelocks.h"
     48  1.1  oster #include "rf_layout.h"
     49  1.1  oster #include "rf_disks.h"
     50  1.1  oster #include "rf_debugMem.h"
     51  1.1  oster #include "rf_diskqueue.h"
     52  1.1  oster #include "rf_reconstruct.h"
     53  1.1  oster #include "rf_acctrace.h"
     54  1.1  oster 
     55  1.1  oster #if RF_INCLUDE_PARITYLOGGING > 0
     56  1.1  oster #include "rf_paritylog.h"
     57  1.1  oster #endif /* RF_INCLUDE_PARITYLOGGING > 0 */
     58  1.1  oster 
     59  1.1  oster #define RF_MAX_DISKS 128 /* max disks per array */
     60  1.1  oster #define RF_DEV2RAIDID(_dev)  (DISKUNIT(_dev))
     61  1.1  oster 
     62  1.1  oster /*
     63  1.1  oster  * Each row in the array is a distinct parity group, so
     64  1.1  oster  * each has it's own status, which is one of the following.
     65  1.1  oster  */
     66  1.1  oster typedef enum RF_RowStatus_e {
     67  1.1  oster   rf_rs_optimal,
     68  1.1  oster   rf_rs_degraded,
     69  1.1  oster   rf_rs_reconstructing,
     70  1.1  oster   rf_rs_reconfigured
     71  1.1  oster } RF_RowStatus_t;
     72  1.1  oster 
     73  1.1  oster struct RF_CumulativeStats_s {
     74  1.1  oster   struct timeval start;     /* the time when the stats were last started*/
     75  1.1  oster   struct timeval stop;      /* the time when the stats were last stopped */
     76  1.1  oster   long sum_io_us;           /* sum of all user response times (us) */
     77  1.1  oster   long num_ios;             /* total number of I/Os serviced */
     78  1.1  oster   long num_sect_moved;      /* total number of sectors read or written */
     79  1.1  oster };
     80  1.1  oster 
     81  1.1  oster struct RF_ThroughputStats_s {
     82  1.1  oster   RF_DECLARE_MUTEX(mutex)/* a mutex used to lock the configuration stuff */
     83  1.1  oster   struct timeval start;  /* timer started when numOutstandingRequests moves from 0 to 1 */
     84  1.1  oster   struct timeval stop;   /* timer stopped when numOutstandingRequests moves from 1 to 0 */
     85  1.1  oster   RF_uint64 sum_io_us;   /* total time timer is enabled */
     86  1.1  oster   RF_uint64 num_ios;     /* total number of ios processed by RAIDframe */
     87  1.1  oster   long num_out_ios;      /* number of outstanding ios */
     88  1.1  oster };
     89  1.1  oster 
     90  1.1  oster struct RF_Raid_s {
     91  1.1  oster   /* This portion never changes, and can be accessed without locking */
     92  1.1  oster   /* an exception is Disks[][].status, which requires locking when it is changed */
     93  1.1  oster   u_int numRow;             /* number of rows of disks, typically == # of ranks */
     94  1.1  oster   u_int numCol;             /* number of columns of disks, typically == # of disks/rank */
     95  1.1  oster   u_int numSpare;           /* number of spare disks */
     96  1.1  oster   int   maxQueueDepth;      /* max disk queue depth */
     97  1.1  oster   RF_SectorCount_t  totalSectors;   /* total number of sectors in the array */
     98  1.1  oster   RF_SectorCount_t  sectorsPerDisk; /* number of sectors on each disk */
     99  1.1  oster   u_int logBytesPerSector;  /* base-2 log of the number of bytes in a sector */
    100  1.1  oster   u_int bytesPerSector;     /* bytes in a sector */
    101  1.1  oster   RF_int32  sectorMask;     /* mask of bytes-per-sector */
    102  1.1  oster 
    103  1.1  oster   RF_RaidLayout_t   Layout; /* all information related to layout */
    104  1.1  oster   RF_RaidDisk_t   **Disks;  /* all information related to physical disks */
    105  1.1  oster   RF_DiskQueue_t  **Queues; /* all information related to disk queues */
    106  1.1  oster      /* NOTE:  This is an anchor point via which the queues can be accessed,
    107  1.1  oster       * but the enqueue/dequeue routines in diskqueue.c use a local copy of
    108  1.1  oster       * this pointer for the actual accesses.
    109  1.1  oster       */
    110  1.1  oster   /* The remainder of the structure can change, and therefore requires locking on reads and updates */
    111  1.1  oster   RF_DECLARE_MUTEX(mutex)        /* mutex used to serialize access to the fields below */
    112  1.1  oster   RF_RowStatus_t  *status;       /* the status of each row in the array */
    113  1.1  oster   int              valid;        /* indicates successful configuration */
    114  1.1  oster   RF_LockTableEntry_t *lockTable;   /* stripe-lock table */
    115  1.1  oster   RF_LockTableEntry_t *quiesceLock; /* quiesnce table */
    116  1.1  oster   int                  numFailures; /* total number of failures in the array */
    117  1.1  oster 
    118  1.1  oster   /*
    119  1.1  oster    * Cleanup stuff
    120  1.1  oster    */
    121  1.1  oster   RF_ShutdownList_t  *shutdownList; /* shutdown activities */
    122  1.1  oster   RF_AllocListElem_t *cleanupList;  /* memory to be freed at shutdown time */
    123  1.1  oster 
    124  1.1  oster   /*
    125  1.1  oster    * Recon stuff
    126  1.1  oster    */
    127  1.1  oster   RF_HeadSepLimit_t headSepLimit;
    128  1.1  oster   int numFloatingReconBufs;
    129  1.1  oster   int reconInProgress;
    130  1.1  oster   RF_DECLARE_COND(waitForReconCond)
    131  1.1  oster   RF_RaidReconDesc_t *reconDesc; /* reconstruction descriptor */
    132  1.1  oster   RF_ReconCtrl_t **reconControl; /* reconstruction control structure pointers for each row in the array */
    133  1.1  oster 
    134  1.1  oster   /*
    135  1.1  oster    * Array-quiescence stuff
    136  1.1  oster    */
    137  1.1  oster   RF_DECLARE_MUTEX(access_suspend_mutex)
    138  1.1  oster   RF_DECLARE_COND(quiescent_cond)
    139  1.1  oster   RF_IoCount_t accesses_suspended;
    140  1.1  oster   RF_IoCount_t accs_in_flight;
    141  1.1  oster   int access_suspend_release;
    142  1.1  oster   int waiting_for_quiescence;
    143  1.1  oster   RF_CallbackDesc_t *quiesce_wait_list;
    144  1.1  oster 
    145  1.1  oster   /*
    146  1.1  oster    * Statistics
    147  1.1  oster    */
    148  1.2  oster #if !defined(_KERNEL) && !defined(SIMULATE)
    149  1.1  oster   RF_ThroughputStats_t throughputstats;
    150  1.1  oster #endif /* !KERNEL && !SIMULATE */
    151  1.1  oster   RF_CumulativeStats_t userstats;
    152  1.1  oster 
    153  1.1  oster   /*
    154  1.1  oster    * Engine thread control
    155  1.1  oster    */
    156  1.1  oster   RF_DECLARE_MUTEX(node_queue_mutex)
    157  1.1  oster   RF_DECLARE_COND(node_queue_cond)
    158  1.1  oster   RF_DagNode_t *node_queue;
    159  1.1  oster   RF_Thread_t engine_thread;
    160  1.1  oster   RF_ThreadGroup_t engine_tg;
    161  1.1  oster   int shutdown_engine;
    162  1.1  oster   int dags_in_flight; /* debug */
    163  1.1  oster 
    164  1.1  oster   /*
    165  1.1  oster    * PSS (Parity Stripe Status) stuff
    166  1.1  oster    */
    167  1.1  oster   RF_FreeList_t *pss_freelist;
    168  1.1  oster   long pssTableSize;
    169  1.1  oster 
    170  1.1  oster   /*
    171  1.1  oster    * Reconstruction stuff
    172  1.1  oster    */
    173  1.1  oster   int procsInBufWait;
    174  1.1  oster   int numFullReconBuffers;
    175  1.1  oster   RF_AccTraceEntry_t *recon_tracerecs;
    176  1.1  oster   unsigned long accumXorTimeUs;
    177  1.1  oster   RF_ReconDoneProc_t *recon_done_procs;
    178  1.1  oster   RF_DECLARE_MUTEX(recon_done_proc_mutex)
    179  1.1  oster 
    180  1.1  oster   /*
    181  1.1  oster    * nAccOutstanding, waitShutdown protected by desc freelist lock
    182  1.1  oster    * (This may seem strange, since that's a central serialization point
    183  1.1  oster    * for a per-array piece of data, but otherwise, it'd be an extra
    184  1.1  oster    * per-array lock, and that'd only be less efficient...)
    185  1.1  oster    */
    186  1.1  oster   RF_DECLARE_COND(outstandingCond)
    187  1.1  oster   int waitShutdown;
    188  1.1  oster   int nAccOutstanding;
    189  1.1  oster 
    190  1.1  oster   RF_DiskId_t **diskids;
    191  1.1  oster   RF_DiskId_t  *sparediskids;
    192  1.1  oster 
    193  1.1  oster 	int           raidid;
    194  1.1  oster 	RF_AccTotals_t  acc_totals;
    195  1.1  oster 	int           keep_acc_totals;
    196  1.1  oster 
    197  1.1  oster         struct raidcinfo **raid_cinfo; /* array of component info */
    198  1.1  oster         struct proc *proc; /* XXX shouldn't be needed here.. :-p */
    199  1.1  oster 
    200  1.1  oster   int terminate_disk_queues;
    201  1.1  oster 
    202  1.1  oster   /*
    203  1.1  oster    * XXX
    204  1.1  oster    *
    205  1.1  oster    * config-specific information should be moved
    206  1.1  oster    * somewhere else, or at least hung off this
    207  1.1  oster    * in some generic way
    208  1.1  oster    */
    209  1.1  oster 
    210  1.1  oster   /* used by rf_compute_workload_shift */
    211  1.1  oster   RF_RowCol_t hist_diskreq[RF_MAXROW][RF_MAXCOL];
    212  1.1  oster 
    213  1.1  oster   /* used by declustering */
    214  1.1  oster   int noRotate;
    215  1.1  oster 
    216  1.1  oster #if RF_INCLUDE_PARITYLOGGING > 0
    217  1.1  oster   /* used by parity logging */
    218  1.1  oster   RF_SectorCount_t          regionLogCapacity;
    219  1.1  oster   RF_ParityLogQueue_t       parityLogPool;       /* pool of unused parity logs */
    220  1.1  oster   RF_RegionInfo_t          *regionInfo;          /* array of region state */
    221  1.1  oster   int                       numParityLogs;
    222  1.1  oster   int                       numSectorsPerLog;
    223  1.1  oster   int                       regionParityRange;
    224  1.1  oster   int                       logsInUse;           /* debugging */
    225  1.1  oster   RF_ParityLogDiskQueue_t   parityLogDiskQueue;  /* state of parity logging disk work */
    226  1.1  oster   RF_RegionBufferQueue_t    regionBufferPool;    /* buffers for holding region log */
    227  1.1  oster   RF_RegionBufferQueue_t    parityBufferPool;    /* buffers for holding parity */
    228  1.1  oster   caddr_t                   parityLogBufferHeap; /* pool of unused parity logs */
    229  1.1  oster   RF_Thread_t               pLogDiskThreadHandle;
    230  1.1  oster 
    231  1.1  oster #endif /* RF_INCLUDE_PARITYLOGGING > 0 */
    232  1.1  oster };
    233  1.1  oster 
    234  1.1  oster #endif /* !_RF__RF_RAID_H_ */
    235