Debian Codegraph @

src/plugins/mdraid.h

raw
1 #include <glib.h>
2 #include <blockdev/utils.h>
3
4 #ifndef BD_MD
5 #define BD_MD
6
7 /* these defaults were determined empirically (taken from blivet) */
8 #define BD_MD_SUPERBLOCK_SIZE (2 MiB)
9 #define BD_MD_CHUNK_SIZE (512 KiB)
10
11 GQuark bd_md_error_quark (void);
12 #define BD_MD_ERROR bd_md_error_quark ()
13 typedef enum {
14 BD_MD_ERROR_TECH_UNAVAIL,
15 BD_MD_ERROR_FAIL,
16 BD_MD_ERROR_PARSE,
17 BD_MD_ERROR_BAD_FORMAT,
18 BD_MD_ERROR_NO_MATCH,
19 BD_MD_ERROR_INVAL,
20 } BDMDError;
21
22 typedef struct BDMDExamineData {
23 gchar *device;
24 gchar *level;
25 guint64 num_devices;
26 gchar *name;
27 guint64 size;
28 gchar *uuid;
29 guint64 update_time;
30 gchar *dev_uuid;
31 guint64 events;
32 gchar *metadata;
33 guint64 chunk_size;
34 } BDMDExamineData;
35
36 BDMDExamineData* bd_md_examine_data_copy (BDMDExamineData *data);
37 void bd_md_examine_data_free (BDMDExamineData *data);
38
39 typedef struct BDMDDetailData {
40 gchar *device;
41 gchar *metadata;
42 gchar *creation_time;
43 gchar *level;
44 gchar *name;
45 guint64 array_size;
46 guint64 use_dev_size;
47 guint64 raid_devices;
48 guint64 total_devices;
49 guint64 active_devices;
50 guint64 working_devices;
51 guint64 failed_devices;
52 guint64 spare_devices;
53 gboolean clean;
54 gchar *uuid;
55 gchar *container;
56 } BDMDDetailData;
57
58 void bd_md_detail_data_free (BDMDDetailData *data);
59 BDMDDetailData* bd_md_detail_data_copy (BDMDDetailData *data);
60
61 typedef enum {
62 BD_MD_TECH_MDRAID = 0,
63 } BDMDTech;
64
65 typedef enum {
66 BD_MD_TECH_MODE_CREATE = 1 << 0,
67 BD_MD_TECH_MODE_DELETE = 1 << 1,
68 BD_MD_TECH_MODE_MODIFY = 1 << 2,
69 BD_MD_TECH_MODE_QUERY = 1 << 3,
70 } BDMDTechMode;
71
72
73 /*
74 * If using the plugin as a standalone library, the following functions should
75 * be called to:
76 *
77 * init() - initialize the plugin, returning TRUE on success
78 * close() - clean after the plugin at the end or if no longer used
79 *
80 */
81 gboolean bd_md_init (void);
82 void bd_md_close (void);
83
84 gboolean bd_md_is_tech_avail (BDMDTech tech, guint64 mode, GError **error);
85
86 guint64 bd_md_get_superblock_size (guint64 member_size, const gchar *version, GError **error);
87 gboolean bd_md_create (const gchar *device_name, const gchar *level, const gchar **disks, guint64 spares, const gchar *version, const gchar *bitmap, guint64 chunk_size, const BDExtraArg **extra, GError **error);
88 gboolean bd_md_destroy (const gchar *device, GError **error);
89 gboolean bd_md_deactivate (const gchar *raid_spec, GError **error);
90 gboolean bd_md_activate (const gchar *raid_spec, const gchar **members, const gchar *uuid, gboolean start_degraded, const BDExtraArg **extra, GError **error);
91 gboolean bd_md_run (const gchar *raid_spec, GError **error);
92 gboolean bd_md_nominate (const gchar *device, GError **error);
93 gboolean bd_md_denominate (const gchar *device, GError **error);
94 gboolean bd_md_add (const gchar *raid_spec, const gchar *device, guint64 raid_devs, const BDExtraArg **extra, GError **error);
95 gboolean bd_md_remove (const gchar *raid_spec, const gchar *device, gboolean fail, const BDExtraArg **extra, GError **error);
96 BDMDExamineData* bd_md_examine (const gchar *device, GError **error);
97 BDMDDetailData* bd_md_detail (const gchar *raid_spec, GError **error);
98 gchar* bd_md_canonicalize_uuid (const gchar *uuid, GError **error);
99 gchar* bd_md_get_md_uuid (const gchar *uuid, GError **error);
100 gchar* bd_md_node_from_name (const gchar *name, GError **error);
101 gchar* bd_md_name_from_node (const gchar *node, GError **error);
102 gchar* bd_md_get_status (const gchar *raid_spec, GError **error);
103 gboolean bd_md_set_bitmap_location (const gchar *raid_spec, const gchar *location, GError **error);
104 gchar* bd_md_get_bitmap_location (const gchar *raid_spec, GError **error);
105 gboolean bd_md_request_sync_action (const gchar *raid_spec, const gchar *action, GError **error);
106
107 #endif /* BD_MD */