1.\" $NetBSD: raid.4,v 1.29 2004/03/05 14:43:01 wiz Exp $ 2.\" 3.\" Copyright (c) 1998 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Greg Oster 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.\" 38.\" Copyright (c) 1995 Carnegie-Mellon University. 39.\" All rights reserved. 40.\" 41.\" Author: Mark Holland 42.\" 43.\" Permission to use, copy, modify and distribute this software and 44.\" its documentation is hereby granted, provided that both the copyright 45.\" notice and this permission notice appear in all copies of the 46.\" software, derivative works or modified versions, and any portions 47.\" thereof, and that both notices appear in supporting documentation. 48.\" 49.\" CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 50.\" CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 51.\" FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 52.\" 53.\" Carnegie Mellon requests users of this software to return to 54.\" 55.\" Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 56.\" School of Computer Science 57.\" Carnegie Mellon University 58.\" Pittsburgh PA 15213-3890 59.\" 60.\" any improvements or extensions that they make and grant Carnegie the 61.\" rights to redistribute these changes. 62.\" 63.Dd February 29, 2004 64.Dt RAID 4 65.Os 66.Sh NAME 67.Nm raid 68.Nd RAIDframe disk driver 69.Sh SYNOPSIS 70.Cd options RAID_AUTOCONFIG 71.Cd options RAID_DIAGNOSTIC 72.Cd options RF_ACC_TRACE=n 73.Cd options RF_DEBUG_MAP=n 74.Cd options RF_DEBUG_PSS=n 75.Cd options RF_DEBUG_QUEUE=n 76.Cd options RF_DEBUG_QUIESCE=n 77.Cd options RF_DEBUG_RECON=n 78.Cd options RF_DEBUG_STRIPELOCK=n 79.Cd options RF_DEBUG_VALIDATE_DAG=n 80.Cd options RF_DEBUG_VERIFYPARITY=n 81.Cd options RF_INCLUDE_CHAINDECLUSTER=n 82.Cd options RF_INCLUDE_EVENODD=n 83.Cd options RF_INCLUDE_INTERDECLUSTER=n 84.Cd options RF_INCLUDE_PARITY_DECLUSTERING=n 85.Cd options RF_INCLUDE_PARITY_DECLUSTERING_DS=n 86.Cd options RF_INCLUDE_PARITYLOGGING=n 87.Cd options RF_INCLUDE_RAID5_RS=n 88.Pp 89.Cd "pseudo-device raid" Op Ar count 90.Sh DESCRIPTION 91The 92.Nm 93driver provides RAID 0, 1, 4, and 5 (and more!) capabilities to 94.Nx . 95This 96document assumes that the reader has at least some familiarity with RAID 97and RAID concepts. The reader is also assumed to know how to configure 98disks and pseudo-devices into kernels, how to generate kernels, and how 99to partition disks. 100.Pp 101RAIDframe provides a number of different RAID levels including: 102.Bl -tag -width indent 103.It RAID 0 104provides simple data striping across the components. 105.It RAID 1 106provides mirroring. 107.It RAID 4 108provides data striping across the components, with parity 109stored on a dedicated drive (in this case, the last component). 110.It RAID 5 111provides data striping across the components, with parity 112distributed across all the components. 113.El 114.Pp 115There are a wide variety of other RAID levels supported by RAIDframe. 116The configuration file options to enable them are briefly outlined 117at the end of this section. 118.Pp 119Depending on the parity level configured, the device driver can 120support the failure of component drives. The number of failures 121allowed depends on the parity level selected. If the driver is able 122to handle drive failures, and a drive does fail, then the system is 123operating in "degraded mode". In this mode, all missing data must be 124reconstructed from the data and parity present on the other 125components. This results in much slower data accesses, but 126does mean that a failure need not bring the system to a complete halt. 127.Pp 128The RAID driver supports and enforces the use of 129.Sq component labels . 130A 131.Sq component label 132contains important information about the component, including a 133user-specified serial number, the row and column of that component in 134the RAID set, and whether the data (and parity) on the component is 135.Sq clean . 136If the driver determines that the labels are very inconsistent with 137respect to each other (e.g. two or more serial numbers do not match) 138or that the component label is not consistent with its assigned place 139in the set (e.g. the component label claims the component should be 140the 3rd one in a 6-disk set, but the RAID set has it as the 3rd component 141in a 5-disk set) then the device will fail to configure. If the 142driver determines that exactly one component label seems to be 143incorrect, and the RAID set is being configured as a set that supports 144a single failure, then the RAID set will be allowed to configure, but 145the incorrectly labeled component will be marked as 146.Sq failed , 147and the RAID set will begin operation in degraded mode. 148If all of the components are consistent among themselves, the RAID set 149will configure normally. 150.Pp 151Component labels are also used to support the auto-detection and 152autoconfiguration of RAID sets. A RAID set can be flagged as 153autoconfigurable, in which case it will be configured automatically 154during the kernel boot process. RAID file systems which are 155automatically configured are also eligible to be the root file system. 156There is currently only limited support (alpha and pmax architectures) 157for booting a kernel directly from a RAID 1 set, and no support for 158booting from any other RAID sets. To use a RAID set as the root 159file system, a kernel is usually obtained from a small non-RAID 160partition, after which any autoconfiguring RAID set can be used for the 161root file system. See 162.Xr raidctl 8 163for more information on autoconfiguration of RAID sets. 164Note that with autoconfiguration of RAID sets, it is no longer 165necessary to hard-code SCSI IDs of drives. 166The autoconfiguration code will 167correctly configure a device even after any number of the components 168have had their device IDs changed or device names changed. 169.Pp 170The driver supports 171.Sq hot spares , 172disks which are on-line, but are not 173actively used in an existing file system. Should a disk fail, the 174driver is capable of reconstructing the failed disk onto a hot spare 175or back onto a replacement drive. 176If the components are hot swappable, the failed disk can then be 177removed, a new disk put in its place, and a copyback operation 178performed. The copyback operation, as its name indicates, will copy 179the reconstructed data from the hot spare to the previously failed 180(and now replaced) disk. Hot spares can also be hot-added using 181.Xr raidctl 8 . 182.Pp 183If a component cannot be detected when the RAID device is configured, 184that component will be simply marked as 'failed'. 185.Pp 186The user-land utility for doing all 187.Nm 188configuration and other operations 189is 190.Xr raidctl 8 . 191Most importantly, 192.Xr raidctl 8 193must be used with the 194.Fl i 195option to initialize all RAID sets. In particular, this 196initialization includes re-building the parity data. This rebuilding 197of parity data is also required when either a) a new RAID device is 198brought up for the first time or b) after an un-clean shutdown of a 199RAID device. By using the 200.Fl P 201option to 202.Xr raidctl 8 , 203and performing this on-demand recomputation of all parity 204before doing a 205.Xr fsck 8 206or a 207.Xr newfs 8 , 208file system integrity and parity integrity can be ensured. It bears 209repeating again that parity recomputation is 210.Ar required 211before any file systems are created or used on the RAID device. If the 212parity is not correct, then missing data cannot be correctly recovered. 213.Pp 214RAID levels may be combined in a hierarchical fashion. For example, a RAID 0 215device can be constructed out of a number of RAID 5 devices (which, in turn, 216may be constructed out of the physical disks, or of other RAID devices). 217.Pp 218The first step to using the 219.Nm 220driver is to ensure that it is suitably configured in the kernel. This is 221done by adding a line similar to: 222.Bd -unfilled -offset indent 223pseudo-device raid 4 # RAIDframe disk device 224.Ed 225.Pp 226to the kernel configuration file. The 227.Sq count 228argument ( 229.Sq 4 , 230in this case), specifies the number of RAIDframe drivers to configure. 231To turn on component auto-detection and autoconfiguration of RAID 232sets, simply add: 233.Bd -unfilled -offset indent 234options RAID_AUTOCONFIG 235.Ed 236.Pp 237to the kernel configuration file. 238.Pp 239All component partitions must be of the type 240.Dv FS_BSDFFS 241(e.g. 4.2BSD) or 242.Dv FS_RAID . 243The use of the latter is strongly encouraged, and is required if 244autoconfiguration of the RAID set is desired. Since RAIDframe leaves 245room for disklabels, RAID components can be simply raw disks, or 246partitions which use an entire disk. 247.Pp 248A more detailed treatment of actually using a 249.Nm 250device is found in 251.Xr raidctl 8 . 252It is highly recommended that the steps to reconstruct, copyback, and 253re-compute parity are well understood by the system administrator(s) 254.Ar before 255a component failure. Doing the wrong thing when a component fails may 256result in data loss. 257.Pp 258Additional internal consistency checking can be enabled by specifying: 259.Bd -unfilled -offset indent 260options RAID_DIAGNOSTIC 261.Ed 262.Pp 263These assertions are disabled by default in order to improve 264performance. 265.Pp 266RAIDframe supports an access tracing facility for tracking both 267requests made and performance of various parts of the RAID systems 268as the request is processed. 269To enable this tracing the following option may be specified: 270.Bd -unfilled -offset indent 271options RF_ACC_TRACE=1 272.Ed 273.Pp 274For extensive debugging there are a number of kernel options which 275will aid in performing extra diagnosis of various parts of the 276RAIDframe sub-systems. 277Note that in order to make full use of these options it is often 278necessary to enable one or more debugging options as listed in 279.Pa src/sys/dev/raidframe/rf_options.h . 280As well, these options are also only typically useful for people who wish 281to debug various parts of RAIDframe. 282The options include: 283.Pp 284For debugging the code which maps RAID addresses to physical 285addresses: 286.Bd -unfilled -offset indent 287options RF_DEBUG_MAP=1 288.Ed 289.Pp 290Parity stripe status debugging is enabled with: 291.Bd -unfilled -offset indent 292options RF_DEBUG_PSS=1 293.Ed 294.Pp 295Additional debugging for queuing is enabled with: 296.Bd -unfilled -offset indent 297options RF_DEBUG_QUEUE=1 298.Ed 299.Pp 300Problems with non-quiescent file systems should be easier to debug if 301the following is enabled: 302.Bd -unfilled -offset indent 303options RF_DEBUG_QUIESCE=1 304.Ed 305.Pp 306Stripelock debugging is enabled with: 307.Bd -unfilled -offset indent 308options RF_DEBUG_STRIPELOCK=1 309.Ed 310.Pp 311Additional diagnostic checks during reconstruction are enabled with: 312.Bd -unfilled -offset indent 313options RF_DEBUG_RECON=1 314.Ed 315.Pp 316Validation of the DAGs (Directed Acyclic Graphs) used to describe an 317I/O access can be performed when the following is enabled: 318.Bd -unfilled -offset indent 319options RF_DEBUG_VALIDATE_DAG=1 320.Ed 321.Pp 322Additional diagnostics during parity verification are enabled with: 323.Bd -unfilled -offset indent 324options RF_DEBUG_VERIFYPARITY=1 325.Ed 326.Pp 327There are a number of less commonly used RAID levels supported by 328RAIDframe. 329These additional RAID types should be considered experimental, and 330may not be ready for production use. 331The various types and the options to enable them are shown here: 332.Pp 333For Even-Odd parity: 334.Bd -unfilled -offset indent 335options RF_INCLUDE_EVENODD=1 336.Ed 337.Pp 338For RAID level 5 with rotated sparing: 339.Bd -unfilled -offset indent 340options RF_INCLUDE_RAID5_RS=1 341.Ed 342.Pp 343For Parity Logging (highly experimental): 344.Bd -unfilled -offset indent 345options RF_INCLUDE_PARITYLOGGING=1 346.Ed 347.Pp 348For Chain Declustering: 349.Bd -unfilled -offset indent 350options RF_INCLUDE_CHAINDECLUSTER=1 351.Ed 352.Pp 353For Interleaved Declustering: 354.Bd -unfilled -offset indent 355options RF_INCLUDE_INTERDECLUSTER=1 356.Ed 357.Pp 358For Parity Declustering: 359.Bd -unfilled -offset indent 360options RF_INCLUDE_PARITY_DECLUSTERING=1 361.Ed 362.Pp 363For Parity Declustering with Distributed Spares: 364.Bd -unfilled -offset indent 365options RF_INCLUDE_PARITY_DECLUSTERING_DS=1 366.Ed 367.Pp 368The reader is referred to the RAIDframe documentation mentioned in the 369.Sx HISTORY 370section for more detail on these various RAID configurations. 371.Sh WARNINGS 372Certain RAID levels (1, 4, 5, 6, and others) can protect against some 373data loss due to component failure. However the loss of two 374components of a RAID 4 or 5 system, or the loss of a single component 375of a RAID 0 system, will result in the entire file systems on that RAID 376device being lost. 377RAID is 378.Ar NOT 379a substitute for good backup practices. 380.Pp 381Recomputation of parity 382.Ar MUST 383be performed whenever there is a chance that it may have been 384compromised. This includes after system crashes, or before a RAID 385device has been used for the first time. Failure to keep parity 386correct will be catastrophic should a component ever fail -- it is 387better to use RAID 0 and get the additional space and speed, than it 388is to use parity, but not keep the parity correct. At least with RAID 3890 there is no perception of increased data security. 390.Sh FILES 391.Bl -tag -width /dev/XXrXraidX -compact 392.It Pa /dev/{,r}raid* 393.Nm 394device special files. 395.El 396.Sh SEE ALSO 397.Xr sd 4 , 398.Xr MAKEDEV 8 , 399.Xr config 8 , 400.Xr fsck 8 , 401.Xr mount 8 , 402.Xr newfs 8 , 403.Xr raidctl 8 404.Sh HISTORY 405The 406.Nm 407driver in 408.Nx 409is a port of RAIDframe, a framework for rapid prototyping of RAID 410structures developed by the folks at the Parallel Data Laboratory at 411Carnegie Mellon University (CMU). RAIDframe, as originally distributed 412by CMU, provides a RAID simulator for a number of different 413architectures, and a user-level device driver and a kernel device 414driver for Digital Unix. The 415.Nm 416driver is a kernelized version of RAIDframe v1.1. 417.Pp 418A more complete description of the internals and functionality of 419RAIDframe is found in the paper "RAIDframe: A Rapid Prototyping Tool 420for RAID Systems", by William V. Courtright II, Garth Gibson, Mark 421Holland, LeAnn Neal Reilly, and Jim Zelenka, and published by the 422Parallel Data Laboratory of Carnegie Mellon University. 423The 424.Nm 425driver first appeared in 426.Nx 1.4 . 427.Sh COPYRIGHT 428.Bd -unfilled 429The RAIDframe Copyright is as follows: 430.Pp 431Copyright (c) 1994-1996 Carnegie-Mellon University. 432All rights reserved. 433.Pp 434Permission to use, copy, modify and distribute this software and 435its documentation is hereby granted, provided that both the copyright 436notice and this permission notice appear in all copies of the 437software, derivative works or modified versions, and any portions 438thereof, and that both notices appear in supporting documentation. 439.Pp 440CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 441CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 442FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 443.Pp 444Carnegie Mellon requests users of this software to return to 445.Pp 446 Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 447 School of Computer Science 448 Carnegie Mellon University 449 Pittsburgh PA 15213-3890 450.Pp 451any improvements or extensions that they make and grant Carnegie the 452rights to redistribute these changes. 453.Ed 454