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

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

hr: add option to silently fail an extent

  • Property mode set to 100644
File size: 3.0 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_MAXDEVS 4
45
46#define HR_DEVNAME_LEN 32
47
48typedef enum hr_level {
49 HR_LVL_0 = 0x00, /* striping, no redundancy */
50 HR_LVL_1 = 0x01, /* n-way mirroring */
51 HR_LVL_4 = 0x04, /* dedicated parity */
52 HR_LVL_5 = 0x05, /* distributed parity */
53 HR_LVL_UNKNOWN = 0xFF
54} hr_level_t;
55
56typedef enum hr_vol_status {
57 HR_VOL_ONLINE, /* OK, OPTIMAL */
58 HR_VOL_FAULTY,
59 HR_VOL_WEAKENED /* used for partial, but usable mirror */
60} hr_vol_status_t;
61
62typedef enum hr_ext_status {
63 HR_EXT_ONLINE, /* OK */
64 HR_EXT_MISSING,
65 HR_EXT_FAILED
66} hr_ext_status_t;
67
68typedef struct hr {
69 async_sess_t *sess;
70} hr_t;
71
72typedef struct hr_config {
73 char devname[HR_DEVNAME_LEN];
74 service_id_t devs[HR_MAXDEVS];
75 size_t dev_no;
76 hr_level_t level;
77} hr_config_t;
78
79typedef struct hr_extent {
80 service_id_t svc_id;
81 hr_ext_status_t status;
82} hr_extent_t;
83
84typedef struct hr_vol_info {
85 hr_extent_t extents[HR_MAXDEVS];
86 size_t extent_no;
87 service_id_t svc_id;
88 hr_level_t level;
89 uint64_t nblocks;
90 uint32_t strip_size;
91 size_t bsize;
92 hr_vol_status_t status;
93} hr_vol_info_t;
94
95extern errno_t hr_sess_init(hr_t **);
96extern void hr_sess_destroy(hr_t *);
97
98extern errno_t hr_create(hr_t *, hr_config_t *, bool);
99extern errno_t hr_stop(const char *, long);
100extern errno_t hr_print_status(void);
101
102extern const char *hr_get_vol_status_msg(hr_vol_status_t);
103extern const char *hr_get_ext_status_msg(hr_ext_status_t);
104
105#endif
106
107/** @}
108 */
Note: See TracBrowser for help on using the repository browser.