source: mainline/uspace/lib/device/include/hr.h@ 37a9c1e

Last change on this file since 37a9c1e was 37a9c1e, checked in by Miroslav Cimerman <mc@…>, 7 months ago

hr: hr_volume_t: rename RLQ → layout

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 * Copyright (c) 2024 Miroslav Cimerman
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libdevice
30 * @{
31 */
32/**
33 * @file
34 */
35
36#ifndef LIBDEVICE_HR_H
37#define LIBDEVICE_HR_H
38
39#include <async.h>
40#include <errno.h>
41#include <loc.h>
42
43/* for now */
44#define HR_MAX_EXTENTS 4
45#define HR_MAX_HOTSPARES HR_MAX_EXTENTS
46
47#define HR_DEVNAME_LEN 32
48
49typedef enum hr_level {
50 HR_LVL_0 = 0x00, /* striping, no redundancy */
51 HR_LVL_1 = 0x01, /* n-way mirroring */
52 HR_LVL_4 = 0x04, /* dedicated parity */
53 HR_LVL_5 = 0x05, /* distributed parity */
54 HR_LVL_UNKNOWN = 0xFF
55} hr_level_t;
56
57/*
58 * SNIA
59 * Common RAID Disk Data Format
60 * Specification
61 * Version 2.0 Revision 19
62 */
63#define HR_RLQ_RAID4_0 0x00 /* RAID-4 Non-Rotating Parity 0 */
64#define HR_RLQ_RAID4_N 0x01 /* RAID-4 Non-Rotating Parity N */
65#define HR_RLQ_RAID5_0R 0x00 /* RAID-5 Rotating Parity 0 with Data Restart */
66#define HR_RLQ_RAID5_NR 0x02 /* RAID-5 Rotating Parity N with Data Restart */
67#define HR_RLQ_RAID5_NC 0x03 /* RAID-5 Rotating Parity N with Data Continuation */
68
69typedef enum hr_vol_status {
70 HR_VOL_ONLINE, /* OK, OPTIMAL */
71 HR_VOL_FAULTY,
72 HR_VOL_DEGRADED, /* also used for partial, but usable mirror */
73 HR_VOL_REBUILD
74} hr_vol_status_t;
75
76typedef enum hr_ext_status {
77 HR_EXT_ONLINE, /* OK */
78 HR_EXT_MISSING,
79 HR_EXT_FAILED,
80 HR_EXT_REBUILD,
81 HR_EXT_HOTSPARE
82} hr_ext_status_t;
83
84typedef struct hr {
85 async_sess_t *sess;
86} hr_t;
87
88typedef struct hr_config {
89 char devname[HR_DEVNAME_LEN];
90 service_id_t devs[HR_MAX_EXTENTS];
91 size_t dev_no;
92 hr_level_t level;
93} hr_config_t;
94
95typedef struct hr_extent {
96 service_id_t svc_id;
97 hr_ext_status_t status;
98} hr_extent_t;
99
100typedef struct hr_vol_info {
101 hr_extent_t extents[HR_MAX_EXTENTS];
102 hr_extent_t hotspares[HR_MAX_HOTSPARES];
103 size_t extent_no;
104 size_t hotspare_no;
105 service_id_t svc_id;
106 hr_level_t level;
107 uint64_t nblocks;
108 uint32_t strip_size;
109 size_t bsize;
110 hr_vol_status_t status;
111 uint8_t layout;
112} hr_vol_info_t;
113
114extern errno_t hr_sess_init(hr_t **);
115extern void hr_sess_destroy(hr_t *);
116
117extern errno_t hr_create(hr_t *, hr_config_t *, bool);
118extern errno_t hr_stop(const char *, long);
119extern errno_t hr_add_hotspare(service_id_t, service_id_t);
120extern errno_t hr_print_status(void);
121
122extern const char *hr_get_vol_status_msg(hr_vol_status_t);
123extern const char *hr_get_ext_status_msg(hr_ext_status_t);
124extern const char *hr_get_layout_str(hr_level_t, uint8_t);
125
126#endif
127
128/** @}
129 */
Note: See TracBrowser for help on using the repository browser.