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