1 /* $OpenBSD: rf_disks.h,v 1.5 2002/12/16 07:01:03 tdeval Exp $ */
2 /* $NetBSD: rf_disks.h,v 1.8 2000/03/27 03:25:17 oster Exp $ */
3
4 /*
5 * Copyright (c) 1995 Carnegie-Mellon University.
6 * All rights reserved.
7 *
8 * Author: Mark Holland
9 *
10 * Permission to use, copy, modify and distribute this software and
11 * its documentation is hereby granted, provided that both the copyright
12 * notice and this permission notice appear in all copies of the
13 * software, derivative works or modified versions, and any portions
14 * thereof, and that both notices appear in supporting documentation.
15 *
16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 *
20 * Carnegie Mellon requests users of this software to return to
21 *
22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
26 *
27 * any improvements or extensions that they make and grant Carnegie the
28 * rights to redistribute these changes.
29 */
30
31 /*
32 * rf_disks.h -- Header file for code related to physical disks.
33 */
34
35 #ifndef _RF__RF_DISKS_H_
36 #define _RF__RF_DISKS_H_
37
38 #include <sys/types.h>
39
40 #include "rf_archs.h"
41 #include "rf_types.h"
42
43 #if defined(__NetBSD__)
44 #include "rf_netbsd.h"
45 #elif defined(__OpenBSD__)
46 #include "rf_openbsd.h"
47 #endif
48
49 /*
50 * A physical disk can be in one of several states:
51 * IF YOU ADD A STATE, CHECK TO SEE IF YOU NEED TO MODIFY RF_DEAD_DISK() BELOW.
52 */
53 enum RF_DiskStatus_e {
54 rf_ds_optimal, /* No problems. */
55 rf_ds_failed, /* Reconstruction ongoing. */
56 rf_ds_reconstructing, /*
57 * Reconstruction complete to spare, dead disk
58 * not yet replaced.
59 */
60 rf_ds_dist_spared, /*
61 * Reconstruction complete to distributed
62 * spare space, dead disk not yet replaced.
63 */
64 rf_ds_spared, /*
65 * Reconstruction complete to distributed
66 * spare space, dead disk not yet replaced.
67 */
68 rf_ds_spare, /* An available spare disk. */
69 rf_ds_used_spare /*
70 * A spare which has been used, and hence is
71 * not available.
72 */
73 };
74 typedef enum RF_DiskStatus_e RF_DiskStatus_t;
75
76 struct RF_RaidDisk_s {
77 char devname[56]; /* Name of device file. */
78 RF_DiskStatus_t status; /* Whether it is up or down. */
79 RF_RowCol_t spareRow; /*
80 * If in status "spared", this
81 * identifies the spare disk.
82 */
83 RF_RowCol_t spareCol; /*
84 * If in status "spared", this
85 * identifies the spare disk.
86 */
87 RF_SectorCount_t numBlocks; /*
88 * Number of blocks, obtained via
89 * READ CAPACITY.
90 */
91 int blockSize;
92 RF_SectorCount_t partitionSize; /*
93 * The *actual* and *full* size of
94 * the partition, from the disklabel.
95 */
96 int auto_configured; /*
97 * 1 if this component was
98 * autoconfigured. 0 otherwise.
99 */
100 dev_t dev;
101 };
102
103 /*
104 * An RF_DiskOp_t ptr is really a pointer to a UAGT_CCB, but I want
105 * to isolate the CAM layer from all other layers, so I typecast to/from
106 * RF_DiskOp_t * (i.e. void *) at the interfaces.
107 */
108 typedef void RF_DiskOp_t;
109
110 /* If a disk is in any of these states, it is inaccessible. */
111 #define RF_DEAD_DISK(_dstat_) \
112 (((_dstat_) == rf_ds_spared) || \
113 ((_dstat_) == rf_ds_reconstructing) || \
114 ((_dstat_) == rf_ds_failed) || \
115 ((_dstat_) == rf_ds_dist_spared))
116
117 #ifdef _KERNEL
118 #if defined(__NetBSD__)
119 #include "rf_netbsd.h"
120 #elif defined(__OpenBSD__)
121 #include "rf_openbsd.h"
122 #endif
123
124 int rf_ConfigureDisks(RF_ShutdownList_t **, RF_Raid_t *, RF_Config_t *);
125 int rf_ConfigureSpareDisks(RF_ShutdownList_t **, RF_Raid_t *, RF_Config_t *);
126 int rf_ConfigureDisk(RF_Raid_t *, char *, RF_RaidDisk_t *,
127 RF_RowCol_t, RF_RowCol_t);
128 int rf_AutoConfigureDisks(RF_Raid_t *, RF_Config_t *, RF_AutoConfig_t *);
129 int rf_CheckLabels(RF_Raid_t *, RF_Config_t *);
130 int rf_add_hot_spare(RF_Raid_t *, RF_SingleComponent_t *);
131 int rf_remove_hot_spare(RF_Raid_t *, RF_SingleComponent_t *);
132 int rf_delete_component(RF_Raid_t *, RF_SingleComponent_t *);
133 int rf_incorporate_hot_spare(RF_Raid_t *, RF_SingleComponent_t *);
134 #endif /* _KERNEL */
135
136 #endif /* !_RF__RF_DISKS_H_ */