Home | History | Annotate | Line # | Download | only in raidframe
rf_disks.h revision 1.1
      1 /*	$NetBSD: rf_disks.h,v 1.1 1998/11/13 04:20:29 oster Exp $	*/
      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 (at) 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  * rf_disks.h -- header file for code related to physical disks
     31  */
     32 
     33 /* :
     34  * Log: rf_disks.h,v
     35  * Revision 1.15  1996/08/20 23:05:13  jimz
     36  * add nreads, nwrites to RaidDisk
     37  *
     38  * Revision 1.14  1996/06/17  03:20:15  jimz
     39  * increase devname len to 56
     40  *
     41  * Revision 1.13  1996/06/10  11:55:47  jimz
     42  * Straightened out some per-array/not-per-array distinctions, fixed
     43  * a couple bugs related to confusion. Added shutdown lists. Removed
     44  * layout shutdown function (now subsumed by shutdown lists).
     45  *
     46  * Revision 1.12  1996/06/09  02:36:46  jimz
     47  * lots of little crufty cleanup- fixup whitespace
     48  * issues, comment #ifdefs, improve typing in some
     49  * places (esp size-related)
     50  *
     51  * Revision 1.11  1996/06/07  21:33:04  jimz
     52  * begin using consistent types for sector numbers,
     53  * stripe numbers, row+col numbers, recon unit numbers
     54  *
     55  * Revision 1.10  1996/05/30  11:29:41  jimz
     56  * Numerous bug fixes. Stripe lock release code disagreed with the taking code
     57  * about when stripes should be locked (I made it consistent: no parity, no lock)
     58  * There was a lot of extra serialization of I/Os which I've removed- a lot of
     59  * it was to calculate values for the cache code, which is no longer with us.
     60  * More types, function, macro cleanup. Added code to properly quiesce the array
     61  * on shutdown. Made a lot of stuff array-specific which was (bogusly) general
     62  * before. Fixed memory allocation, freeing bugs.
     63  *
     64  * Revision 1.9  1996/05/27  18:56:37  jimz
     65  * more code cleanup
     66  * better typing
     67  * compiles in all 3 environments
     68  *
     69  * Revision 1.8  1996/05/24  01:59:45  jimz
     70  * another checkpoint in code cleanup for release
     71  * time to sync kernel tree
     72  *
     73  * Revision 1.7  1996/05/18  19:51:34  jimz
     74  * major code cleanup- fix syntax, make some types consistent,
     75  * add prototypes, clean out dead code, et cetera
     76  *
     77  * Revision 1.6  1996/05/02  22:06:57  jimz
     78  * add RF_RaidDisk_t
     79  *
     80  * Revision 1.5  1995/12/01  15:56:53  root
     81  * added copyright info
     82  *
     83  */
     84 
     85 #ifndef _RF__RF_DISKS_H_
     86 #define _RF__RF_DISKS_H_
     87 
     88 #include <sys/types.h>
     89 
     90 #include "rf_archs.h"
     91 #include "rf_types.h"
     92 #ifdef SIMULATE
     93 #include "rf_geometry.h"
     94 #endif /* SIMULATE  */
     95 
     96 /*
     97  * A physical disk can be in one of several states:
     98  * IF YOU ADD A STATE, CHECK TO SEE IF YOU NEED TO MODIFY RF_DEAD_DISK() BELOW.
     99  */
    100 enum RF_DiskStatus_e {
    101   rf_ds_optimal,        /* no problems */
    102   rf_ds_failed,         /* reconstruction ongoing */
    103   rf_ds_reconstructing, /* reconstruction complete to spare, dead disk not yet replaced */
    104   rf_ds_dist_spared,    /* reconstruction complete to distributed spare space, dead disk not yet replaced */
    105   rf_ds_spared,         /* reconstruction complete to distributed spare space, dead disk not yet replaced */
    106   rf_ds_spare,          /* an available spare disk */
    107   rf_ds_used_spare      /* a spare which has been used, and hence is not available */
    108 };
    109 typedef enum RF_DiskStatus_e RF_DiskStatus_t;
    110 
    111 struct RF_RaidDisk_s {
    112   char              devname[56]; /* name of device file */
    113   RF_DiskStatus_t   status;      /* whether it is up or down */
    114   RF_RowCol_t       spareRow;    /* if in status "spared", this identifies the spare disk */
    115   RF_RowCol_t       spareCol;    /* if in status "spared", this identifies the spare disk */
    116   RF_SectorCount_t  numBlocks;   /* number of blocks, obtained via READ CAPACITY */
    117   int               blockSize;
    118 	/* XXX the folling is needed since we seem to need SIMULATE defined
    119 	   in order to get user-land stuff to compile, but we *don't* want
    120 	   this in the structure for the user-land utilities, as the
    121 	   kernel doesn't know about it!! (and it messes up the size of
    122 	   the structure, so there is a communication problem between
    123 	   the kernel and the userland utils :-(  GO */
    124 #if defined(SIMULATE) && !defined(RF_UTILITY)
    125   RF_DiskState_t    diskState;   /* the name of the disk as used in the disk module */
    126 #endif /* SIMULATE */
    127 #if RF_KEEP_DISKSTATS > 0
    128   RF_uint64         nreads;
    129   RF_uint64         nwrites;
    130 #endif /* RF_KEEP_DISKSTATS > 0 */
    131   dev_t             dev;
    132 };
    133 
    134 /*
    135  * An RF_DiskOp_t ptr is really a pointer to a UAGT_CCB, but I want
    136  * to isolate the cam layer from all other layers, so I typecast to/from
    137  * RF_DiskOp_t * (i.e. void *) at the interfaces.
    138  */
    139 typedef void RF_DiskOp_t;
    140 
    141 /* if a disk is in any of these states, it is inaccessible */
    142 #define RF_DEAD_DISK(_dstat_) (((_dstat_) == rf_ds_spared) || \
    143 	((_dstat_) == rf_ds_reconstructing) || ((_dstat_) == rf_ds_failed) || \
    144 	((_dstat_) == rf_ds_dist_spared))
    145 
    146 int rf_ConfigureDisks(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
    147 	RF_Config_t *cfgPtr);
    148 int rf_ConfigureSpareDisks(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
    149 	RF_Config_t *cfgPtr);
    150 int rf_ConfigureDisk(RF_Raid_t *raidPtr, char *buf, RF_RaidDisk_t *diskPtr,
    151 		     RF_DiskOp_t *rdcap_op, RF_DiskOp_t *tur_op, dev_t dev,
    152 		     RF_RowCol_t row, RF_RowCol_t col);
    153 
    154 #ifdef SIMULATE
    155 void rf_default_disk_names(void);
    156 void rf_set_disk_db_name(char *s);
    157 void rf_set_disk_type_name(char *s);
    158 #endif /* SIMULATE */
    159 
    160 #endif /* !_RF__RF_DISKS_H_ */
    161