1 /* $NetBSD: rf_disks.h,v 1.4 1999/02/24 00:00:03 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@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 #ifndef _RF__RF_DISKS_H_ 34 #define _RF__RF_DISKS_H_ 35 36 #include <sys/types.h> 37 38 #include "rf_archs.h" 39 #include "rf_types.h" 40 41 /* 42 * A physical disk can be in one of several states: 43 * IF YOU ADD A STATE, CHECK TO SEE IF YOU NEED TO MODIFY RF_DEAD_DISK() BELOW. 44 */ 45 enum RF_DiskStatus_e { 46 rf_ds_optimal, /* no problems */ 47 rf_ds_failed, /* reconstruction ongoing */ 48 rf_ds_reconstructing, /* reconstruction complete to spare, dead disk 49 * not yet replaced */ 50 rf_ds_dist_spared, /* reconstruction complete to distributed 51 * spare space, dead disk not yet replaced */ 52 rf_ds_spared, /* reconstruction complete to distributed 53 * spare space, dead disk not yet replaced */ 54 rf_ds_spare, /* an available spare disk */ 55 rf_ds_used_spare /* a spare which has been used, and hence is 56 * not available */ 57 }; 58 typedef enum RF_DiskStatus_e RF_DiskStatus_t; 59 60 struct RF_RaidDisk_s { 61 char devname[56]; /* name of device file */ 62 RF_DiskStatus_t status; /* whether it is up or down */ 63 RF_RowCol_t spareRow; /* if in status "spared", this identifies the 64 * spare disk */ 65 RF_RowCol_t spareCol; /* if in status "spared", this identifies the 66 * spare disk */ 67 RF_SectorCount_t numBlocks; /* number of blocks, obtained via READ 68 * CAPACITY */ 69 int blockSize; 70 /* XXX the following is needed since we seem to need SIMULATE defined 71 * in order to get user-land stuff to compile, but we *don't* want this 72 * in the structure for the user-land utilities, as the kernel doesn't 73 * know about it!! (and it messes up the size of the structure, so 74 * there is a communication problem between the kernel and the 75 * userland utils :-( GO */ 76 #if RF_KEEP_DISKSTATS > 0 77 RF_uint64 nreads; 78 RF_uint64 nwrites; 79 #endif /* RF_KEEP_DISKSTATS > 0 */ 80 dev_t dev; 81 }; 82 /* 83 * An RF_DiskOp_t ptr is really a pointer to a UAGT_CCB, but I want 84 * to isolate the cam layer from all other layers, so I typecast to/from 85 * RF_DiskOp_t * (i.e. void *) at the interfaces. 86 */ 87 typedef void RF_DiskOp_t; 88 89 /* if a disk is in any of these states, it is inaccessible */ 90 #define RF_DEAD_DISK(_dstat_) (((_dstat_) == rf_ds_spared) || \ 91 ((_dstat_) == rf_ds_reconstructing) || ((_dstat_) == rf_ds_failed) || \ 92 ((_dstat_) == rf_ds_dist_spared)) 93 94 int 95 rf_ConfigureDisks(RF_ShutdownList_t ** listp, RF_Raid_t * raidPtr, 96 RF_Config_t * cfgPtr); 97 int 98 rf_ConfigureSpareDisks(RF_ShutdownList_t ** listp, RF_Raid_t * raidPtr, 99 RF_Config_t * cfgPtr); 100 int 101 rf_ConfigureDisk(RF_Raid_t * raidPtr, char *buf, RF_RaidDisk_t * diskPtr, 102 RF_RowCol_t row, RF_RowCol_t col); 103 #endif /* !_RF__RF_DISKS_H_ */ 104