Debian Codegraph @

src/lib/plugin_apis/lvm.api

raw
1 #include <glib.h>
2 #include <glib-object.h>
3 #include <blockdev/utils.h>
4
5 #ifndef BD_LVM_API
6 #define BD_LVM_API
7
8 GQuark bd_lvm_error_quark (void) {
9 return g_quark_from_static_string ("g-bd-lvm-error-quark");
10 }
11
12 #define BD_LVM_ERROR bd_lvm_error_quark ()
13 typedef enum {
14 BD_LVM_ERROR_TECH_UNAVAIL,
15 BD_LVM_ERROR_FAIL,
16 BD_LVM_ERROR_PARSE,
17 BD_LVM_ERROR_NOEXIST,
18 BD_LVM_ERROR_DM_ERROR,
19 BD_LVM_ERROR_NOT_ROOT,
20 BD_LVM_ERROR_CACHE_INVAL,
21 BD_LVM_ERROR_CACHE_NOCACHE,
22 BD_LVM_ERROR_NOT_SUPPORTED,
23 BD_LVM_ERROR_VDO_POLICY_INVAL,
24 BD_LVM_ERROR_DEVICES_DISABLED,
25 } BDLVMError;
26
27 typedef enum {
28 BD_LVM_CACHE_POOL_STRIPED = 1 << 0,
29 BD_LVM_CACHE_POOL_RAID1 = 1 << 1,
30 BD_LVM_CACHE_POOL_RAID5 = 1 << 2,
31 BD_LVM_CACHE_POOL_RAID6 = 1 << 3,
32 BD_LVM_CACHE_POOL_RAID10 = 1 << 4,
33
34 BD_LVM_CACHE_POOL_META_STRIPED = 1 << 10,
35 BD_LVM_CACHE_POOL_META_RAID1 = 1 << 11,
36 BD_LVM_CACHE_POOL_META_RAID5 = 1 << 12,
37 BD_LVM_CACHE_POOL_META_RAID6 = 1 << 13,
38 BD_LVM_CACHE_POOL_META_RAID10 = 1 << 14,
39 } BDLVMCachePoolFlags;
40
41 typedef enum {
42 BD_LVM_CACHE_MODE_UNKNOWN,
43 BD_LVM_CACHE_MODE_WRITETHROUGH,
44 BD_LVM_CACHE_MODE_WRITEBACK,
45 } BDLVMCacheMode;
46
47 typedef enum {
48 BD_LVM_VDO_MODE_UNKNOWN,
49 BD_LVM_VDO_MODE_RECOVERING,
50 BD_LVM_VDO_MODE_READ_ONLY,
51 BD_LVM_VDO_MODE_NORMAL,
52 } BDLVMVDOOperatingMode;
53
54 typedef enum {
55 BD_LVM_VDO_COMPRESSION_UNKNOWN,
56 BD_LVM_VDO_COMPRESSION_ONLINE,
57 BD_LVM_VDO_COMPRESSION_OFFLINE,
58 } BDLVMVDOCompressionState;
59
60 typedef enum {
61 BD_LVM_VDO_INDEX_UNKNOWN,
62 BD_LVM_VDO_INDEX_ERROR,
63 BD_LVM_VDO_INDEX_CLOSED,
64 BD_LVM_VDO_INDEX_OPENING,
65 BD_LVM_VDO_INDEX_CLOSING,
66 BD_LVM_VDO_INDEX_OFFLINE,
67 BD_LVM_VDO_INDEX_ONLINE,
68 } BDLVMVDOIndexState;
69
70 typedef enum {
71 BD_LVM_VDO_WRITE_POLICY_UNKNOWN,
72 BD_LVM_VDO_WRITE_POLICY_AUTO,
73 BD_LVM_VDO_WRITE_POLICY_SYNC,
74 BD_LVM_VDO_WRITE_POLICY_ASYNC,
75 } BDLVMVDOWritePolicy;
76
77
78 #define BD_LVM_TYPE_PVDATA (bd_lvm_pvdata_get_type ())
79 GType bd_lvm_pvdata_get_type();
80
81 /**
82 * BDLVMPVdata:
83 * @pv_name: name of the PV
84 * @pv_uuid: UUID of the PV
85 * @pv_free: size of the free space in the PV
86 * @pv_size: size of the PV
87 * @pe_start: start of the physical extents area (i.e. offset of the first PE)
88 * @vg_name: name of the VG the PV belongs to
89 * @vg_uuid: UUID of the VG the PV belongs to
90 * @vg_size: size of the VG the PV belongs to
91 * @vg_free: size of the free space in the PV's VG
92 * @vg_extent_size: extent size used by the PV's VG
93 * @vg_extent_count: number of extents in the PV's VG
94 * @vg_free_count: number of free extents in the PV's VG
95 * @vg_pv_count: number of PVs that belong to this PV's VG
96 * @pv_tags: (array zero-terminated=1): list of LVM tags for this PV
97 * @missing: whether this PV is missing from the system or not
98 */
99 typedef struct BDLVMPVdata {
100 gchar *pv_name;
101 gchar *pv_uuid;
102 guint64 pv_free;
103 guint64 pv_size;
104 guint64 pe_start;
105 gchar *vg_name;
106 gchar *vg_uuid;
107 guint64 vg_size;
108 guint64 vg_free;
109 guint64 vg_extent_size;
110 guint64 vg_extent_count;
111 guint64 vg_free_count;
112 guint64 vg_pv_count;
113 gchar **pv_tags;
114 gboolean missing;
115 } BDLVMPVdata;
116
117 /**
118 * bd_lvm_pvdata_copy: (skip)
119 * @data: (nullable): %BDLVMPVdata to copy
120 *
121 * Creates a new copy of @data.
122 */
123 BDLVMPVdata* bd_lvm_pvdata_copy (BDLVMPVdata *data) {
124 if (data == NULL)
125 return NULL;
126
127 BDLVMPVdata *new_data = g_new0 (BDLVMPVdata, 1);
128
129 new_data->pv_name = g_strdup (data->pv_name);
130 new_data->pv_uuid = g_strdup (data->pv_uuid);
131 new_data->pv_free = data->pv_free;
132 new_data->pv_size = data->pv_size;
133 new_data->pe_start = data->pe_start;
134 new_data->vg_name = g_strdup (data->vg_name);
135 new_data->vg_uuid = g_strdup (data->vg_uuid);
136 new_data->vg_size = data->vg_size;
137 new_data->vg_free = data->vg_free;
138 new_data->vg_extent_size = data->vg_extent_size;
139 new_data->vg_extent_count = data->vg_extent_count;
140 new_data->vg_free_count = data->vg_free_count;
141 new_data->vg_pv_count = data->vg_pv_count;
142 new_data->pv_tags = g_strdupv (data->pv_tags);
143 new_data->missing = data->missing;
144
145 return new_data;
146 }
147
148 /**
149 * bd_lvm_pvdata_free: (skip)
150 * @data: (nullable): %BDLVMPVdata to free
151 *
152 * Frees @data.
153 */
154 void bd_lvm_pvdata_free (BDLVMPVdata *data) {
155 if (data == NULL)
156 return;
157
158 g_free (data->pv_name);
159 g_free (data->pv_uuid);
160 g_free (data->vg_name);
161 g_free (data->vg_uuid);
162 g_strfreev (data->pv_tags);
163 g_free (data);
164 }
165
166 GType bd_lvm_pvdata_get_type () {
167 static GType type = 0;
168
169 if (G_UNLIKELY(type == 0)) {
170 type = g_boxed_type_register_static("BDLVMPVdata",
171 (GBoxedCopyFunc) bd_lvm_pvdata_copy,
172 (GBoxedFreeFunc) bd_lvm_pvdata_free);
173 }
174
175 return type;
176 }
177
178 #define BD_LVM_TYPE_VGDATA (bd_lvm_vgdata_get_type ())
179 GType bd_lvm_vgdata_get_type();
180
181 /**
182 * BDLVMVGdata:
183 * @name: name of the VG
184 * @uuid: UUID of the VG
185 * @size: size of the VG
186 * @free: size of the free space in the VG
187 * @extent_size: extent size used by the VG
188 * @extent_count: number of extents in the VG
189 * @free_count: number of free extents in the VG
190 * @pv_count: number of PVs that belong to the VG
191 * @exported: whether the VG is exported or not
192 * @vg_tags: (array zero-terminated=1): list of LVM tags for this VG
193 */
194 typedef struct BDLVMVGdata {
195 gchar *name;
196 gchar *uuid;
197 guint64 size;
198 guint64 free;
199 guint64 extent_size;
200 guint64 extent_count;
201 guint64 free_count;
202 guint64 pv_count;
203 gboolean exported;
204 gchar **vg_tags;
205 } BDLVMVGdata;
206
207 /**
208 * bd_lvm_vgdata_copy: (skip)
209 * @data: (nullable): %BDLVMVGdata to copy
210 *
211 * Creates a new copy of @data.
212 */
213 BDLVMVGdata* bd_lvm_vgdata_copy (BDLVMVGdata *data) {
214 if (data == NULL)
215 return NULL;
216
217 BDLVMVGdata *new_data = g_new0 (BDLVMVGdata, 1);
218
219 new_data->name = g_strdup (data->name);
220 new_data->uuid = g_strdup (data->uuid);
221 new_data->size = data->size;
222 new_data->free = data->free;
223 new_data->extent_size = data->extent_size;
224 new_data->extent_count = data->extent_count;
225 new_data->free_count = data->free_count;
226 new_data->pv_count = data->pv_count;
227 new_data->exported = data->exported;
228 new_data->vg_tags = g_strdupv (data->vg_tags);
229
230 return new_data;
231 }
232
233 /**
234 * bd_lvm_vgdata_free: (skip)
235 * @data: (nullable): %BDLVMVGdata to free
236 *
237 * Frees @data.
238 */
239 void bd_lvm_vgdata_free (BDLVMVGdata *data) {
240 if (data == NULL)
241 return;
242
243 g_free (data->name);
244 g_free (data->uuid);
245 g_strfreev (data->vg_tags);
246 g_free (data);
247 }
248
249 GType bd_lvm_vgdata_get_type () {
250 static GType type = 0;
251
252 if (G_UNLIKELY(type == 0)) {
253 type = g_boxed_type_register_static("BDLVMVGdata",
254 (GBoxedCopyFunc) bd_lvm_vgdata_copy,
255 (GBoxedFreeFunc) bd_lvm_vgdata_free);
256 }
257
258 return type;
259 }
260
261 #define BD_LVM_TYPE_SEGDATA (bd_lvm_segdata_get_type ())
262 GType bd_lvm_segdata_get_type();
263
264 /**
265 * BDLVMSEGdata:
266 * @size_pe: Size of this segment in extents
267 * @pv_start_pe: Where it starts in the physical volume in extents
268 * @pvdev: Device name of the physical volume or NULL
269 */
270 typedef struct BDLVMSEGdata {
271 guint64 size_pe;
272 guint64 pv_start_pe;
273 gchar *pvdev;
274 } BDLVMSEGdata;
275
276 /**
277 * bd_lvm_segdata_copy: (skip)
278 * @data: (nullable): %BDLVMSEGdata to copy
279 *
280 * Creates a new copy of @data.
281 */
282 BDLVMSEGdata* bd_lvm_segdata_copy (BDLVMSEGdata *data) {
283 if (data == NULL)
284 return NULL;
285
286 BDLVMSEGdata *new_data = g_new0 (BDLVMSEGdata, 1);
287
288 new_data->size_pe = data->size_pe;
289 new_data->pv_start_pe = data->pv_start_pe;
290 new_data->pvdev = g_strdup (data->pvdev);
291 return new_data;
292 }
293
294 /**
295 * bd_lvm_segdata_free: (skip)
296 * @data: (nullable): %BDLVMSEGdata to free
297 *
298 * Frees @data.
299 */
300 void bd_lvm_segdata_free (BDLVMSEGdata *data) {
301 if (data == NULL)
302 return;
303
304 g_free (data->pvdev);
305 g_free (data);
306 }
307
308 GType bd_lvm_segdata_get_type () {
309 static GType type = 0;
310
311 if (G_UNLIKELY(type == 0)) {
312 type = g_boxed_type_register_static("BDLVMSEGdata",
313 (GBoxedCopyFunc) bd_lvm_segdata_copy,
314 (GBoxedFreeFunc) bd_lvm_segdata_free) ;
315 }
316
317 return type;
318 }
319
320 static BDLVMSEGdata **copy_segs (BDLVMSEGdata **segs) {
321 int i, len;
322 BDLVMSEGdata **new_segs;
323
324 if (segs == NULL)
325 return NULL;
326
327 for (len = 0; segs[len]; len++)
328 ;
329
330 new_segs = g_new0 (BDLVMSEGdata *, len+1);
331 for (i = 0; i < len; i++)
332 new_segs[i] = bd_lvm_segdata_copy (segs[i]);
333
334 return new_segs;
335 }
336
337 static void free_segs (BDLVMSEGdata **segs) {
338 int i;
339
340 if (segs == NULL)
341 return;
342
343 for (i = 0; segs[i]; i++)
344 bd_lvm_segdata_free (segs[i]);
345 (g_free) (segs);
346 }
347
348 #define BD_LVM_TYPE_LVDATA (bd_lvm_lvdata_get_type ())
349 GType bd_lvm_lvdata_get_type();
350
351 /**
352 * BDLVMLVdata:
353 * @lv_name: name of the LV
354 * @vg_name: name of the VG the LV belongs to
355 * @uuid: UUID of the LV
356 * @size: size of the LV
357 * @attr: attributes of the LV
358 * @segtype: segment type of the LV
359 * @origin: origin of the LV (for snapshots, etc.)
360 * @pool_lv: pool LV of the LV (for thin and cached LVs)
361 * @data_lv: data LV of the LV (for thin and cache pools)
362 * @metadata_lv: metadata LV of the LV (for thin and cache pools)
363 * @roles: comma separated list of this LV's roles
364 * @move_pv: source physical volume of a temporary logical volume created with the pvmove command
365 * @data_percent: available data space in a thin pool
366 * @metadata_percent: available metadata space in a thin pool
367 * @copy_percent: synchronization percentage of a mirrored logical volume
368 * @lv_tags: (array zero-terminated=1): list of LVM tags for this LV
369 * @data_lvs: (nullable) (array zero-terminated=1): list of data sub-LVs this LV (for raids, etc).
370 * @metadata_lvs: (nullable) (array zero-terminated=1): list of metadata sub-LVS for this LV (for raids, etc).
371 * @segs: (nullable) (array zero-terminated=1): The segments of this LV.
372 *
373 * The @segs, @data_lvs, and @metadata_lvs fields are only filled by a
374 * call to bd_lvm_lvinfo_tree or bd_lvm_lvs_tree. They are all NULL
375 * normally. If they are filled, they follow these rules:
376 *
377 * A LV is either stored directly on physical volumes, or is made up
378 * of sub-LVs. If it is stored on PVs, the @segs list is non-empty
379 * and the @data_lvs and @metadata_lvs fields are both NULL. If it is
380 * made up of sub-LVs, then @segs is NULL, @data_lvs is non-empty and
381 * @metadata_lvs might or might not be empty but is non-NULL. The
382 * sub-LVs contained in @data_lv and @metadata_lv are always included
383 * in @data_lvs and @metadata_lvs, respectively.
384 *
385 * For a partial LV, the @segs list might not be complete; i.e., the
386 * sum of the sizes of the listed segments might not be equal to the
387 * size reported for the LV itself.
388 *
389 * Also, the order of entries in @segs must be assumed to be random;
390 * it does not correspond to the order of segments in the logical
391 * volume itself.
392 */
393 typedef struct BDLVMLVdata {
394 gchar *lv_name;
395 gchar *vg_name;
396 gchar *uuid;
397 guint64 size;
398 gchar *attr;
399 gchar *segtype;
400 gchar *origin;
401 gchar *pool_lv;
402 gchar *data_lv;
403 gchar *metadata_lv;
404 gchar *roles;
405 gchar *move_pv;
406 guint64 data_percent;
407 guint64 metadata_percent;
408 guint64 copy_percent;
409 gchar **lv_tags;
410 gchar **data_lvs;
411 gchar **metadata_lvs;
412 BDLVMSEGdata **segs;
413 } BDLVMLVdata;
414
415 /**
416 * bd_lvm_lvdata_copy: (skip)
417 * @data: (nullable): %BDLVMLVdata to copy
418 *
419 * Creates a new copy of @data.
420 */
421 BDLVMLVdata* bd_lvm_lvdata_copy (BDLVMLVdata *data) {
422 if (data == NULL)
423 return NULL;
424
425 BDLVMLVdata *new_data = g_new0 (BDLVMLVdata, 1);
426
427 new_data->lv_name = g_strdup (data->lv_name);
428 new_data->vg_name = g_strdup (data->vg_name);
429 new_data->uuid = g_strdup (data->uuid);
430 new_data->size = data->size;
431 new_data->attr = g_strdup (data->attr);
432 new_data->segtype = g_strdup (data->segtype);
433 new_data->origin = g_strdup (data->origin);
434 new_data->pool_lv = g_strdup (data->pool_lv);
435 new_data->data_lv = g_strdup (data->data_lv);
436 new_data->metadata_lv = g_strdup (data->metadata_lv);
437 new_data->roles = g_strdup (data->roles);
438 new_data->move_pv = g_strdup (data->move_pv);
439 new_data->data_percent = data->data_percent;
440 new_data->metadata_percent = data->metadata_percent;
441 new_data->copy_percent = data->copy_percent;
442 new_data->lv_tags = g_strdupv (data->lv_tags);
443 new_data->data_lvs = g_strdupv (data->data_lvs);
444 new_data->metadata_lvs = g_strdupv (data->metadata_lvs);
445 new_data->segs = copy_segs (data->segs);
446 return new_data;
447 }
448
449 /**
450 * bd_lvm_lvdata_free: (skip)
451 * @data: (nullable): %BDLVMLVdata to free
452 *
453 * Frees @data.
454 */
455 void bd_lvm_lvdata_free (BDLVMLVdata *data) {
456 if (data == NULL)
457 return;
458
459 g_free (data->lv_name);
460 g_free (data->vg_name);
461 g_free (data->uuid);
462 g_free (data->attr);
463 g_free (data->segtype);
464 g_free (data->origin);
465 g_free (data->pool_lv);
466 g_free (data->data_lv);
467 g_free (data->metadata_lv);
468 g_free (data->roles);
469 g_free (data->move_pv);
470 g_strfreev (data->lv_tags);
471 g_strfreev (data->data_lvs);
472 g_strfreev (data->metadata_lvs);
473 free_segs (data->segs);
474 g_free (data);
475 }
476
477 GType bd_lvm_lvdata_get_type () {
478 static GType type = 0;
479
480 if (G_UNLIKELY(type == 0)) {
481 type = g_boxed_type_register_static("BDLVMLVdata",
482 (GBoxedCopyFunc) bd_lvm_lvdata_copy,
483 (GBoxedFreeFunc) bd_lvm_lvdata_free);
484 }
485
486 return type;
487 }
488
489 #define BD_LVM_TYPE_VDOPOOLDATA (bd_lvm_vdopooldata_get_type ())
490 GType bd_lvm_vdopooldata_get_type();
491
492 /**
493 * BDLVMVDOPooldata:
494 * @operating_mode: operating mode of the VDO pool (e.g. %BD_LVM_VDO_MODE_NORMAL)
495 * @compression_state: state of the compression
496 * @index_state: state of the VDO index
497 * @write_policy: write policy of the VDO LV
498 * @used_size: currently used space
499 * @saving_percent: percentage of physical blocks saved
500 * @index_memory_size: index memory size of the VDO volume
501 * @deduplication: whether deduplication is enabled
502 * @compression: whether compression is enabled
503 */
504
505 typedef struct BDLVMVDOPooldata {
506 BDLVMVDOOperatingMode operating_mode;
507 BDLVMVDOCompressionState compression_state;
508 BDLVMVDOIndexState index_state;
509 BDLVMVDOWritePolicy write_policy;
510 guint64 used_size;
511 gint32 saving_percent;
512 guint64 index_memory_size;
513 gboolean deduplication;
514 gboolean compression;
515 } BDLVMVDOPooldata;
516
517 /**
518 * bd_lvm_vdopooldata_copy: (skip)
519 * @data: (nullable): %BDLVMVDOPooldata to copy
520 *
521 * Creates a new copy of @data.
522 */
523 BDLVMVDOPooldata* bd_lvm_vdopooldata_copy (BDLVMVDOPooldata *data) {
524 if (data == NULL)
525 return NULL;
526
527 BDLVMVDOPooldata *new_data = g_new0 (BDLVMVDOPooldata, 1);
528
529 new_data->operating_mode = data->operating_mode;
530 new_data->compression_state = data->compression_state;
531 new_data->index_state = data->index_state;
532 new_data->write_policy = data->write_policy;
533 new_data->used_size = data->used_size;
534 new_data->saving_percent = data->saving_percent;
535 new_data->index_memory_size = data->index_memory_size;
536 new_data->deduplication = data->deduplication;
537 new_data->compression = data->compression;
538 return new_data;
539 }
540
541 /**
542 * bd_lvm_vdopooldata_free: (skip)
543 * @data: (nullable): %BDLVMVDOPooldata to free
544 *
545 * Frees @data.
546 */
547 void bd_lvm_vdopooldata_free (BDLVMVDOPooldata *data) {
548 if (data == NULL)
549 return;
550
551 g_free (data);
552 }
553
554 GType bd_lvm_vdopooldata_get_type () {
555 static GType type = 0;
556
557 if (G_UNLIKELY(type == 0)) {
558 type = g_boxed_type_register_static("BDLVMVDOPooldata",
559 (GBoxedCopyFunc) bd_lvm_vdopooldata_copy,
560 (GBoxedFreeFunc) bd_lvm_vdopooldata_free);
561 }
562
563 return type;
564 }
565
566 #define BD_LVM_TYPE_VDO_STATS (bd_lvm_vdo_stats_get_type ())
567 GType bd_lvm_vdo_stats_get_type();
568
569 /**
570 * BDLVMVDOStats:
571 * @block_size: The block size of a VDO volume, in bytes.
572 * @logical_block_size: The logical block size, in bytes.
573 * @physical_blocks: The total number of physical blocks allocated for a VDO volume.
574 * @data_blocks_used: The number of physical blocks currently in use by a VDO volume
575 * to store data.
576 * @overhead_blocks_used: The number of physical blocks currently in use by a VDO volume
577 * to store VDO metadata.
578 * @logical_blocks_used: The number of logical blocks currently mapped.
579 * @used_percent: The percentage of physical blocks used on a VDO volume
580 * (= used blocks / allocated blocks * 100).
581 * @saving_percent: The percentage of physical blocks saved on a VDO volume
582 * (= [logical blocks used - physical blocks used] / logical blocks used).
583 * @write_amplification_ratio: The average number of block writes to the underlying storage
584 * per block written to the VDO device.
585 */
586 typedef struct BDLVMVDOStats {
587 gint64 block_size;
588 gint64 logical_block_size;
589 gint64 physical_blocks;
590 gint64 data_blocks_used;
591 gint64 overhead_blocks_used;
592 gint64 logical_blocks_used;
593 gint64 used_percent;
594 gint64 saving_percent;
595 gdouble write_amplification_ratio;
596 } BDLVMVDOStats;
597
598 /**
599 * bd_lvm_vdo_stats_copy: (skip)
600 * @stats: (nullable): %BDLVMVDOStats to copy
601 *
602 * Creates a new copy of @stats.
603 */
604 BDLVMVDOStats* bd_lvm_vdo_stats_copy (BDLVMVDOStats *stats) {
605 if (stats == NULL)
606 return NULL;
607
608 BDLVMVDOStats *new_stats = g_new0 (BDLVMVDOStats, 1);
609
610 new_stats->block_size = stats->block_size;
611 new_stats->logical_block_size = stats->logical_block_size;
612 new_stats->physical_blocks = stats->physical_blocks;
613 new_stats->data_blocks_used = stats->data_blocks_used;
614 new_stats->overhead_blocks_used = stats->overhead_blocks_used;
615 new_stats->logical_blocks_used = stats->logical_blocks_used;
616 new_stats->used_percent = stats->used_percent;
617 new_stats->saving_percent = stats->saving_percent;
618 new_stats->write_amplification_ratio = stats->write_amplification_ratio;
619 return new_stats;
620 }
621
622 /**
623 * bd_lvm_vdo_stats_free: (skip)
624 * @stats: (nullable): %BDLVMVDOStats to free
625 *
626 * Frees @stats.
627 */
628 void bd_lvm_vdo_stats_free (BDLVMVDOStats *stats) {
629 if (stats == NULL)
630 return;
631
632 g_free (stats);
633 }
634
635 GType bd_lvm_vdo_stats_get_type () {
636 static GType type = 0;
637
638 if (G_UNLIKELY(type == 0)) {
639 type = g_boxed_type_register_static("BDLVMVDOStats",
640 (GBoxedCopyFunc) bd_lvm_vdo_stats_copy,
641 (GBoxedFreeFunc) bd_lvm_vdo_stats_free);
642 }
643
644 return type;
645 }
646
647 #define BD_LVM_TYPE_CACHE_STATS (bd_lvm_cache_stats_get_type ())
648 GType bd_lvm_cache_stats_get_type();
649
650 /**
651 * BDLVMCacheStats:
652 * @block_size: block size used by the cache
653 * @cache_size: size of the cache
654 * @cache_used: size of the used space in the cache
655 * @md_block_size: block size used for cache metadata
656 * @md_size: size of the metadata space of the cache
657 * @md_used: size of the used metadata space in the cache
658 * @read_hits: number of read hits
659 * @read_misses: number of read misses
660 * @write_hits: number of write hits
661 * @write_misses: number of write misses
662 * @mode: mode the cache is operating in
663 */
664 typedef struct BDLVMCacheStats {
665 guint64 block_size;
666 guint64 cache_size;
667 guint64 cache_used;
668 guint64 md_block_size;
669 guint64 md_size;
670 guint64 md_used;
671 guint64 read_hits;
672 guint64 read_misses;
673 guint64 write_hits;
674 guint64 write_misses;
675 BDLVMCacheMode mode;
676 } BDLVMCacheStats;
677
678 /**
679 * bd_lvm_cache_stats_copy: (skip)
680 * @data: (nullable): %BDLVMCacheStats to copy
681 *
682 * Creates a new copy of @data.
683 */
684 BDLVMCacheStats* bd_lvm_cache_stats_copy (BDLVMCacheStats *data) {
685 if (data == NULL)
686 return NULL;
687
688 BDLVMCacheStats *new = g_new0 (BDLVMCacheStats, 1);
689
690 new->block_size = data->block_size;
691 new->cache_size = data->cache_size;
692 new->cache_used = data->cache_used;
693 new->md_block_size = data->md_block_size;
694 new->md_size = data->md_size;
695 new->md_used = data->md_used;
696 new->read_hits = data->read_hits;
697 new->read_misses = data->read_misses;
698 new->write_hits = data->write_hits;
699 new->write_misses = data->write_misses;
700 new->mode = data->mode;
701
702 return new;
703 }
704
705 /**
706 * bd_lvm_cache_stats_free: (skip)
707 * @data: (nullable): %BDLVMCacheStats to free
708 *
709 * Frees @data.
710 */
711 void bd_lvm_cache_stats_free (BDLVMCacheStats *data) {
712 if (data == NULL)
713 return;
714 g_free (data);
715 }
716
717 GType bd_lvm_cache_stats_get_type () {
718 static GType type = 0;
719
720 if (G_UNLIKELY(type == 0)) {
721 type = g_boxed_type_register_static("BDLVMCacheStats",
722 (GBoxedCopyFunc) bd_lvm_cache_stats_copy,
723 (GBoxedFreeFunc) bd_lvm_cache_stats_free);
724 }
725
726 return type;
727 }
728
729 typedef enum {
730 BD_LVM_TECH_BASIC = 0,
731 BD_LVM_TECH_BASIC_SNAP,
732 BD_LVM_TECH_THIN,
733 BD_LVM_TECH_CACHE,
734 BD_LVM_TECH_CALCS,
735 BD_LVM_TECH_THIN_CALCS,
736 BD_LVM_TECH_CACHE_CALCS,
737 BD_LVM_TECH_GLOB_CONF,
738 BD_LVM_TECH_VDO,
739 BD_LVM_TECH_WRITECACHE,
740 BD_LVM_TECH_DEVICES,
741 BD_LVM_TECH_SHARED,
742 BD_LVM_TECH_CONFIG,
743 BD_LVM_TECH_VG_CFG_BACKUP_RESTORE,
744 } BDLVMTech;
745
746 typedef enum {
747 BD_LVM_TECH_MODE_CREATE = 1 << 0,
748 BD_LVM_TECH_MODE_REMOVE = 1 << 2,
749 BD_LVM_TECH_MODE_MODIFY = 1 << 3,
750 BD_LVM_TECH_MODE_QUERY = 1 << 4,
751 } BDLVMTechMode;
752
753
754 /**
755 * bd_lvm_is_tech_avail:
756 * @tech: the queried tech
757 * @mode: a bit mask of queried modes of operation (#BDLVMTechMode) for @tech
758 * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available)
759 *
760 * Returns: whether the @tech-@mode combination is available -- supported by the
761 * plugin implementation and having all the runtime dependencies available
762 */
763 gboolean bd_lvm_is_tech_avail (BDLVMTech tech, guint64 mode, GError **error);
764
765 /**
766 * bd_lvm_is_supported_pe_size:
767 * @size: size (in bytes) to test
768 * @error: (out) (optional): place to store error (if any)
769 *
770 * Returns: whether the given size is supported physical extent size or not
771 *
772 * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
773 */
774 gboolean bd_lvm_is_supported_pe_size (guint64 size, GError **error);
775
776 /**
777 * bd_lvm_get_supported_pe_sizes:
778 * @error: (out) (optional): place to store error (if any)
779 *
780 * Returns: (transfer full) (array fixed-size=25): list of supported PE sizes
781 *
782 * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
783 */
784 guint64 *bd_lvm_get_supported_pe_sizes (GError **error);
785
786 /**
787 * bd_lvm_get_max_lv_size:
788 * @error: (out) (optional): place to store error (if any)
789 *
790 * Returns: maximum LV size in bytes
791 *
792 * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
793 */
794 guint64 bd_lvm_get_max_lv_size (GError **error);
795
796 /**
797 * bd_lvm_round_size_to_pe:
798 * @size: size to be rounded
799 * @pe_size: physical extent (PE) size or 0 to use the default
800 * @roundup: whether to round up or down (ceil or floor)
801 * @error: (out) (optional): place to store error (if any)
802 *
803 * Returns: @size rounded to @pe_size according to the @roundup
804 *
805 * Rounds given @size up/down to a multiple of @pe_size according to the value
806 * of the @roundup parameter. If the rounded value is too big to fit in the
807 * return type, the result is rounded down (floored) regardless of the @roundup
808 * parameter.
809 *
810 * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
811 */
812 guint64 bd_lvm_round_size_to_pe (guint64 size, guint64 pe_size, gboolean roundup, GError **error);
813
814 /**
815 * bd_lvm_get_lv_physical_size:
816 * @lv_size: LV size
817 * @pe_size: PE size
818 * @error: (out) (optional): place to store error (if any)
819 *
820 * Returns: space taken on disk(s) by the LV with given @size
821 *
822 * Gives number of bytes needed for an LV with the size @lv_size on an LVM stack
823 * using given @pe_size.
824 *
825 * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
826 */
827 guint64 bd_lvm_get_lv_physical_size (guint64 lv_size, guint64 pe_size, GError **error);
828
829 /**
830 * bd_lvm_get_thpool_padding:
831 * @size: size of the thin pool
832 * @pe_size: PE size or 0 if the default value should be used
833 * @included: if padding is already included in the size
834 * @error: (out) (optional): place to store error (if any)
835 *
836 * Returns: size of the padding needed for a thin pool with the given @size
837 * according to the @pe_size and @included
838 *
839 * Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored)
840 */
841 guint64 bd_lvm_get_thpool_padding (guint64 size, guint64 pe_size, gboolean included, GError **error);
842
843 /**
844 * bd_lvm_get_thpool_meta_size:
845 * @size: size of the thin pool
846 * @chunk_size: chunk size of the thin pool or 0 to use the default
847 * @n_snapshots: ignored
848 * @error: (out) (optional): place to store error (if any)
849 *
850 * Note: This function will be changed in 3.0: the @n_snapshots parameter
851 * is currently not used and will be removed.
852 *
853 * Returns: recommended size of the metadata space for the specified pool
854 *
855 * Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored)
856 */
857 guint64 bd_lvm_get_thpool_meta_size (guint64 size, guint64 chunk_size, guint64 n_snapshots, GError **error);
858
859 /**
860 * bd_lvm_is_valid_thpool_md_size:
861 * @size: the size to be tested
862 * @error: (out) (optional): place to store error (if any)
863 *
864 * Returns: whether the given size is a valid thin pool metadata size or not
865 *
866 * Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored)
867 */
868 gboolean bd_lvm_is_valid_thpool_md_size (guint64 size, GError **error);
869
870 /**
871 * bd_lvm_is_valid_thpool_chunk_size:
872 * @size: the size to be tested
873 * @discard: whether discard/TRIM is required to be supported or not
874 * @error: (out) (optional): place to store error (if any)
875 *
876 * Returns: whether the given size is a valid thin pool chunk size or not
877 *
878 * Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored)
879 */
880 gboolean bd_lvm_is_valid_thpool_chunk_size (guint64 size, gboolean discard, GError **error);
881
882 /**
883 * bd_lvm_pvcreate:
884 * @device: the device to make PV from
885 * @data_alignment: data (first PE) alignment or 0 to use the default
886 * @metadata_size: size of the area reserved for metadata or 0 to use the default
887 * @extra: (nullable) (array zero-terminated=1): extra options for the PV creation
888 * (just passed to LVM as is)
889 * @error: (out) (optional): place to store error (if any)
890 *
891 * Returns: whether the PV was successfully created or not
892 *
893 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_CREATE
894 */
895 gboolean bd_lvm_pvcreate (const gchar *device, guint64 data_alignment, guint64 metadata_size, const BDExtraArg **extra, GError **error);
896
897 /**
898 * bd_lvm_pvresize:
899 * @device: the device to resize
900 * @size: the new requested size of the PV or 0 if it should be adjusted to device's size
901 * @extra: (nullable) (array zero-terminated=1): extra options for the PV resize
902 * (just passed to LVM as is)
903 * @error: (out) (optional): place to store error (if any)
904 *
905 * Returns: whether the PV's size was successfully changed or not
906 *
907 * If given @size different from 0, sets the PV's size to the given value (see
908 * pvresize(8)). If given @size 0, adjusts the PV's size to the underlying
909 * block device's size.
910 *
911 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
912 */
913 gboolean bd_lvm_pvresize (const gchar *device, guint64 size, const BDExtraArg **extra, GError **error);
914
915 /**
916 * bd_lvm_pvremove:
917 * @device: the PV device to be removed/destroyed
918 * @extra: (nullable) (array zero-terminated=1): extra options for the PV removal
919 * (just passed to LVM as is)
920 * @error: (out) (optional): place to store error (if any)
921 *
922 * Returns: whether the PV was successfully removed/destroyed or not
923 *
924 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_REMOVE
925 */
926 gboolean bd_lvm_pvremove (const gchar *device, const BDExtraArg **extra, GError **error);
927
928 /**
929 * bd_lvm_pvmove:
930 * @src: the PV device to move extents off of
931 * @dest: (nullable): the PV device to move extents onto or %NULL
932 * @extra: (nullable) (array zero-terminated=1): extra options for the PV move
933 * (just passed to LVM as is)
934 * @error: (out) (optional): place to store error (if any)
935 *
936 * Returns: whether the extents from the @src PV where successfully moved or not
937 *
938 * If @dest is %NULL, VG allocation rules are used for the extents from the @src
939 * PV (see pvmove(8)).
940 *
941 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
942 */
943 gboolean bd_lvm_pvmove (const gchar *src, const gchar *dest, const BDExtraArg **extra, GError **error);
944
945 /**
946 * bd_lvm_pvscan:
947 * @device: (nullable): the device to scan for PVs or %NULL
948 * @update_cache: whether to update the lvmetad cache or not
949 * @extra: (nullable) (array zero-terminated=1): extra options for the PV scan
950 * (just passed to LVM as is)
951 * @error: (out) (optional): place to store error (if any)
952 *
953 * Returns: whether the system or @device was successfully scanned for PVs or not
954 *
955 * The @device argument is used only if @update_cache is %TRUE. Otherwise the
956 * whole system is scanned for PVs.
957 *
958 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
959 */
960 gboolean bd_lvm_pvscan (const gchar *device, gboolean update_cache, const BDExtraArg **extra, GError **error);
961
962 /**
963 * bd_lvm_add_pv_tags:
964 * @device: the device to set PV tags for
965 * @tags: (array zero-terminated=1): list of tags to add
966 * @error: (out) (optional): place to store error (if any)
967 *
968 * Returns: whether the tags were successfully added to @device or not
969 *
970 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
971 */
972 gboolean bd_lvm_add_pv_tags (const gchar *device, const gchar **tags, GError **error);
973
974 /**
975 * bd_lvm_delete_pv_tags:
976 * @device: the device to set PV tags for
977 * @tags: (array zero-terminated=1): list of tags to remove
978 * @error: (out) (optional): place to store error (if any)
979 *
980 * Returns: whether the tags were successfully removed from @device or not
981 *
982 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
983 */
984 gboolean bd_lvm_delete_pv_tags (const gchar *device, const gchar **tags, GError **error);
985
986 /**
987 * bd_lvm_pvinfo:
988 * @device: a PV to get information about or %NULL
989 * @error: (out) (optional): place to store error (if any)
990 *
991 * Returns: (transfer full): information about the PV on the given @device or
992 * %NULL in case of error (the @error) gets populated in those cases)
993 *
994 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
995 */
996 BDLVMPVdata* bd_lvm_pvinfo (const gchar *device, GError **error);
997
998 /**
999 * bd_lvm_pvs:
1000 * @error: (out) (optional): place to store error (if any)
1001 *
1002 * Returns: (array zero-terminated=1): information about PVs found in the system
1003 *
1004 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
1005 */
1006 BDLVMPVdata** bd_lvm_pvs (GError **error);
1007
1008 /**
1009 * bd_lvm_vgcreate:
1010 * @name: name of the newly created VG
1011 * @pv_list: (array zero-terminated=1): list of PVs the newly created VG should use
1012 * @pe_size: PE size or 0 if the default value should be used
1013 * @extra: (nullable) (array zero-terminated=1): extra options for the VG creation
1014 * (just passed to LVM as is)
1015 * @error: (out) (optional): place to store error (if any)
1016 *
1017 * Returns: whether the VG @name was successfully created or not
1018 *
1019 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_CREATE
1020 */
1021 gboolean bd_lvm_vgcreate (const gchar *name, const gchar **pv_list, guint64 pe_size, const BDExtraArg **extra, GError **error);
1022
1023 /**
1024 * bd_lvm_vgremove:
1025 * @vg_name: name of the to be removed VG
1026 * @extra: (nullable) (array zero-terminated=1): extra options for the VG removal
1027 * (just passed to LVM as is)
1028 * @error: (out) (optional): place to store error (if any)
1029 *
1030 * Returns: whether the VG was successfully removed or not
1031 *
1032 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_REMOVE
1033 */
1034 gboolean bd_lvm_vgremove (const gchar *vg_name, const BDExtraArg **extra, GError **error);
1035
1036 /**
1037 * bd_lvm_vgrename:
1038 * @old_vg_name: old name of the VG to rename
1039 * @new_vg_name: new name for the @old_vg_name VG
1040 * @extra: (nullable) (array zero-terminated=1): extra options for the VG rename
1041 * (just passed to LVM as is)
1042 * @error: (out) (optional): place to store error (if any)
1043 *
1044 * Returns: whether the VG was successfully renamed or not
1045 *
1046 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
1047 */
1048 gboolean bd_lvm_vgrename (const gchar *old_vg_name, const gchar *new_vg_name, const BDExtraArg **extra, GError **error);
1049
1050 /**
1051 * bd_lvm_vgactivate:
1052 * @vg_name: name of the to be activated VG
1053 * @extra: (nullable) (array zero-terminated=1): extra options for the VG activation
1054 * (just passed to LVM as is)
1055 * @error: (out) (optional): place to store error (if any)
1056 *
1057 * Returns: whether the VG was successfully activated or not
1058 *
1059 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
1060 */
1061 gboolean bd_lvm_vgactivate (const gchar *vg_name, const BDExtraArg **extra, GError **error);
1062
1063 /**
1064 * bd_lvm_vgdeactivate:
1065 * @vg_name: name of the to be deactivated VG
1066 * @extra: (nullable) (array zero-terminated=1): extra options for the VG deactivation
1067 * (just passed to LVM as is)
1068 * @error: (out) (optional): place to store error (if any)
1069 *
1070 * Returns: whether the VG was successfully deactivated or not
1071 *
1072 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
1073 */
1074 gboolean bd_lvm_vgdeactivate (const gchar *vg_name, const BDExtraArg **extra, GError **error);
1075
1076 /**
1077 * bd_lvm_vgextend:
1078 * @vg_name: name of the to be extended VG
1079 * @device: PV device to extend the @vg_name VG with
1080 * @extra: (nullable) (array zero-terminated=1): extra options for the VG extension
1081 * (just passed to LVM as is)
1082 * @error: (out) (optional): place to store error (if any)
1083 *
1084 * Returns: whether the VG @vg_name was successfully extended with the given @device or not.
1085 *
1086 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
1087 */
1088 gboolean bd_lvm_vgextend (const gchar *vg_name, const gchar *device, const BDExtraArg **extra, GError **error);
1089
1090 /**
1091 * bd_lvm_vgreduce:
1092 * @vg_name: name of the to be reduced VG
1093 * @device: (nullable): PV device the @vg_name VG should be reduced of or %NULL
1094 * if the VG should be reduced of the missing PVs
1095 * @extra: (nullable) (array zero-terminated=1): extra options for the VG reduction
1096 * (just passed to LVM as is)
1097 * @error: (out) (optional): place to store error (if any)
1098 *
1099 * Returns: whether the VG @vg_name was successfully reduced of the given @device or not
1100 *
1101 * Note: This function does not move extents off of the PV before removing
1102 * it from the VG. You must do that first by calling #bd_lvm_pvmove.
1103 *
1104 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
1105 */
1106 gboolean bd_lvm_vgreduce (const gchar *vg_name, const gchar *device, const BDExtraArg **extra, GError **error);
1107
1108 /**
1109 * bd_lvm_add_vg_tags:
1110 * @vg_name: the VG to set tags on
1111 * @tags: (array zero-terminated=1): list of tags to add
1112 * @error: (out) (optional): place to store error (if any)
1113 *
1114 * Returns: whether the tags were successfully added to @vg_name or not
1115 *
1116 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
1117 */
1118 gboolean bd_lvm_add_vg_tags (const gchar *vg_name, const gchar **tags, GError **error);
1119
1120 /**
1121 * bd_lvm_delete_vg_tags:
1122 * @vg_name: the VG to set tags on
1123 * @tags: (array zero-terminated=1): list of tags to remove
1124 * @error: (out) (optional): place to store error (if any)
1125 *
1126 * Returns: whether the tags were successfully removed from @vg_name or not
1127 *
1128 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
1129 */
1130 gboolean bd_lvm_delete_vg_tags (const gchar *vg_name, const gchar **tags, GError **error);
1131
1132 /**
1133 * bd_lvm_vglock_start:
1134 * @vg_name: a shared VG to start the lockspace in lvmlockd
1135 * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
1136 * (just passed to LVM as is)
1137 * @error: (out) (optional): place to store error (if any)
1138 *
1139 * Returns: whether the lock was successfully started for @vg_name or not
1140 *
1141 * Tech category: %BD_LVM_TECH_SHARED-%BD_LVM_TECH_MODE_MODIFY
1142 */
1143 gboolean bd_lvm_vglock_start (const gchar *vg_name, const BDExtraArg **extra, GError **error);
1144
1145 /**
1146 * bd_lvm_vglock_stop:
1147 * @vg_name: a shared VG to stop the lockspace in lvmlockd
1148 * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
1149 * (just passed to LVM as is)
1150 * @error: (out) (optional): place to store error (if any)
1151 *
1152 * Returns: whether the lock was successfully stopped for @vg_name or not
1153 *
1154 * Tech category: %BD_LVM_TECH_SHARED-%BD_LVM_TECH_MODE_MODIFY
1155 */
1156 gboolean bd_lvm_vglock_stop (const gchar *vg_name, const BDExtraArg **extra, GError **error);
1157
1158 /**
1159 * bd_lvm_vginfo:
1160 * @vg_name: a VG to get information about
1161 * @error: (out) (optional): place to store error (if any)
1162 *
1163 * Returns: (transfer full): information about the @vg_name VG or %NULL in case
1164 * of error (the @error) gets populated in those cases)
1165 *
1166 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
1167 */
1168 BDLVMVGdata* bd_lvm_vginfo (const gchar *vg_name, GError **error);
1169
1170 /**
1171 * bd_lvm_vgs:
1172 * @error: (out) (optional): place to store error (if any)
1173 *
1174 * Returns: (array zero-terminated=1): information about VGs found in the system
1175 *
1176 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
1177 */
1178 BDLVMVGdata** bd_lvm_vgs (GError **error);
1179
1180 /**
1181 * bd_lvm_lvorigin:
1182 * @vg_name: name of the VG containing the queried LV
1183 * @lv_name: name of the queried LV
1184 * @error: (out) (optional): place to store error (if any)
1185 *
1186 * Returns: (transfer full): the origin volume for the @vg_name/@lv_name LV or
1187 * %NULL if failed to determine (@error) is set in those cases)
1188 *
1189 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
1190 */
1191 gchar* bd_lvm_lvorigin (const gchar *vg_name, const gchar *lv_name, GError **error);
1192
1193 /**
1194 * bd_lvm_lvcreate:
1195 * @vg_name: name of the VG to create a new LV in
1196 * @lv_name: name of the to-be-created LV
1197 * @size: requested size of the new LV
1198 * @type: (nullable): type of the new LV ("striped", "raid1",..., see lvcreate (8))
1199 * @pv_list: (nullable) (array zero-terminated=1): list of PVs the newly created LV should use or %NULL
1200 * if not specified
1201 * @extra: (nullable) (array zero-terminated=1): extra options for the LV creation
1202 * (just passed to LVM as is)
1203 * @error: (out) (optional): place to store error (if any)
1204 *
1205 * Returns: whether the given @vg_name/@lv_name LV was successfully created or not
1206 *
1207 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_CREATE
1208 */
1209 gboolean bd_lvm_lvcreate (const gchar *vg_name, const gchar *lv_name, guint64 size, const gchar *type, const gchar **pv_list, const BDExtraArg **extra, GError **error);
1210
1211 /**
1212 * bd_lvm_lvremove:
1213 * @vg_name: name of the VG containing the to-be-removed LV
1214 * @lv_name: name of the to-be-removed LV
1215 * @force: whether to force removal or not
1216 * @extra: (nullable) (array zero-terminated=1): extra options for the LV removal
1217 * (just passed to LVM as is)
1218 * @error: (out) (optional): place to store error (if any)
1219 *
1220 * Returns: whether the @vg_name/@lv_name LV was successfully removed or not
1221 *
1222 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_REMOVE
1223 */
1224 gboolean bd_lvm_lvremove (const gchar *vg_name, const gchar *lv_name, gboolean force, const BDExtraArg **extra, GError **error);
1225
1226 /**
1227 * bd_lvm_lvrename:
1228 * @vg_name: name of the VG containing the to-be-renamed LV
1229 * @lv_name: name of the to-be-renamed LV
1230 * @new_name: new name for the @vg_name/@lv_name LV
1231 * @extra: (nullable) (array zero-terminated=1): extra options for the LV rename
1232 * (just passed to LVM as is)
1233 * @error: (out) (optional): place to store error (if any)
1234 *
1235 * Returns: whether the @vg_name/@lv_name LV was successfully renamed to
1236 * @vg_name/@new_name or not
1237 *
1238 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
1239 */
1240 gboolean bd_lvm_lvrename (const gchar *vg_name, const gchar *lv_name, const gchar *new_name, const BDExtraArg **extra, GError **error);
1241
1242 /**
1243 * bd_lvm_lvresize:
1244 * @vg_name: name of the VG containing the to-be-resized LV
1245 * @lv_name: name of the to-be-resized LV
1246 * @size: the requested new size of the LV
1247 * @extra: (nullable) (array zero-terminated=1): extra options for the LV resize
1248 * (just passed to LVM as is)
1249 * @error: (out) (optional): place to store error (if any)
1250 *
1251 * Returns: whether the @vg_name/@lv_name LV was successfully resized or not
1252 *
1253 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
1254 */
1255 gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 size, const BDExtraArg **extra, GError **error);
1256
1257 /**
1258 * bd_lvm_lvrepair:
1259 * @vg_name: name of the VG containing the to-be-repaired LV
1260 * @lv_name: name of the to-be-repaired LV
1261 * @pv_list: (array zero-terminated=1): list of PVs to be used for the repair
1262 * @extra: (nullable) (array zero-terminated=1): extra options for the LV repair
1263 * (just passed to LVM as is)
1264 * @error: (out) (optional): place to store error (if any)
1265 *
1266 * Returns: whether the @vg_name/@lv_name LV was successfully repaired or not
1267 *
1268 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
1269 */
1270 gboolean bd_lvm_lvrepair (const gchar *vg_name, const gchar *lv_name, const gchar **pv_list, const BDExtraArg **extra, GError **error);
1271
1272 /**
1273 * bd_lvm_lvactivate:
1274 * @vg_name: name of the VG containing the to-be-activated LV
1275 * @lv_name: name of the to-be-activated LV
1276 * @ignore_skip: whether to ignore the skip flag or not
1277 * @shared: whether to activate the LV in shared mode (used for shared LVM setups with lvmlockd,
1278 * use %FALSE if not sure)
1279 * @extra: (nullable) (array zero-terminated=1): extra options for the LV activation
1280 * (just passed to LVM as is)
1281 * @error: (out) (optional): place to store error (if any)
1282 *
1283 * Returns: whether the @vg_name/@lv_name LV was successfully activated or not
1284 *
1285 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
1286 */
1287 gboolean bd_lvm_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error);
1288
1289 /**
1290 * bd_lvm_lvdeactivate:
1291 * @vg_name: name of the VG containing the to-be-deactivated LV
1292 * @lv_name: name of the to-be-deactivated LV
1293 * @extra: (nullable) (array zero-terminated=1): extra options for the LV deactivation
1294 * (just passed to LVM as is)
1295 * @error: (out) (optional): place to store error (if any)
1296 *
1297 * Returns: whether the @vg_name/@lv_name LV was successfully deactivated or not
1298 *
1299 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
1300 */
1301 gboolean bd_lvm_lvdeactivate (const gchar *vg_name, const gchar *lv_name, const BDExtraArg **extra, GError **error);
1302
1303 /**
1304 * bd_lvm_lvsnapshotcreate:
1305 * @vg_name: name of the VG containing the LV a new snapshot should be created of
1306 * @origin_name: name of the LV a new snapshot should be created of
1307 * @snapshot_name: name of the to-be-created snapshot
1308 * @size: requested size for the snapshot
1309 * @extra: (nullable) (array zero-terminated=1): extra options for the LV snapshot creation
1310 * (just passed to LVM as is)
1311 * @error: (out) (optional): place to store error (if any)
1312 *
1313 * Returns: whether the @snapshot_name snapshot of the @vg_name/@origin_name LV
1314 * was successfully created or not.
1315 *
1316 * Tech category: %BD_LVM_TECH_BASIC_SNAP-%BD_LVM_TECH_MODE_CREATE
1317 */
1318 gboolean bd_lvm_lvsnapshotcreate (const gchar *vg_name, const gchar *origin_name, const gchar *snapshot_name, guint64 size, const BDExtraArg **extra, GError **error);
1319
1320 /**
1321 * bd_lvm_lvsnapshotmerge:
1322 * @vg_name: name of the VG containing the to-be-merged LV snapshot
1323 * @snapshot_name: name of the to-be-merged LV snapshot
1324 * @extra: (nullable) (array zero-terminated=1): extra options for the LV snapshot merge
1325 * (just passed to LVM as is)
1326 * @error: (out) (optional): place to store error (if any)
1327 *
1328 * Returns: whether the @vg_name/@snapshot_name LV snapshot was successfully merged or not
1329 *
1330 * Tech category: %BD_LVM_TECH_BASIC_SNAP-%BD_LVM_TECH_MODE_MODIFY
1331 */
1332 gboolean bd_lvm_lvsnapshotmerge (const gchar *vg_name, const gchar *snapshot_name, const BDExtraArg **extra, GError **error);
1333
1334 /**
1335 * bd_lvm_add_lv_tags:
1336 * @vg_name: name of the VG that contains the LV to set tags on
1337 * @lv_name: name of the LV to set tags on
1338 * @tags: (array zero-terminated=1): list of tags to add
1339 * @error: (out) (optional): place to store error (if any)
1340 *
1341 * Returns: whether the tags were successfully added to @device or not
1342 *
1343 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
1344 */
1345 gboolean bd_lvm_add_lv_tags (const gchar *vg_name, const gchar *lv_name, const gchar **tags, GError **error);
1346
1347 /**
1348 * bd_lvm_delete_lv_tags:
1349 * @vg_name: name of the VG that contains the LV to set tags on
1350 * @lv_name: name of the LV to set tags on
1351 * @tags: (array zero-terminated=1): list of tags to remove
1352 * @error: (out) (optional): place to store error (if any)
1353 *
1354 * Returns: whether the tags were successfully removed from @device or not
1355 *
1356 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
1357 */
1358 gboolean bd_lvm_delete_lv_tags (const gchar *vg_name, const gchar *lv_name, const gchar **tags, GError **error);
1359
1360 /**
1361 * bd_lvm_lvinfo:
1362 * @vg_name: name of the VG that contains the LV to get information about
1363 * @lv_name: name of the LV to get information about
1364 * @error: (out) (optional): place to store error (if any)
1365 *
1366 * Returns: (transfer full): information about the @vg_name/@lv_name LV or %NULL in case
1367 * of error (the @error) gets populated in those cases)
1368 *
1369 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
1370 */
1371 BDLVMLVdata* bd_lvm_lvinfo (const gchar *vg_name, const gchar *lv_name, GError **error);
1372
1373 /**
1374 * bd_lvm_lvinfo_tree:
1375 * @vg_name: name of the VG that contains the LV to get information about
1376 * @lv_name: name of the LV to get information about
1377 * @error: (out) (optional): place to store error (if any)
1378 *
1379 * This function will fill out the data_lvs, metadata_lvs, and segs fields as well.
1380 *
1381 * Returns: (transfer full): information about the @vg_name/@lv_name LV or %NULL in case
1382 * of error (the @error) gets populated in those cases)
1383 *
1384 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
1385 */
1386 BDLVMLVdata* bd_lvm_lvinfo_tree (const gchar *vg_name, const gchar *lv_name, GError **error);
1387
1388 /**
1389 * bd_lvm_lvs:
1390 * @vg_name: (nullable): name of the VG to get information about LVs from
1391 * @error: (out) (optional): place to store error (if any)
1392 *
1393 * Returns: (array zero-terminated=1): information about LVs found in the given
1394 * @vg_name VG or in system if @vg_name is %NULL
1395 *
1396 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
1397 */
1398 BDLVMLVdata** bd_lvm_lvs (const gchar *vg_name, GError **error);
1399
1400 /**
1401 * bd_lvm_lvs_tree:
1402 * @vg_name: (nullable): name of the VG to get information about LVs from
1403 * @error: (out) (optional): place to store error (if any)
1404 *
1405 * This function will fill out the data_lvs, metadata_lvs, and segs fields as well.
1406 *
1407 * Returns: (array zero-terminated=1): information about LVs found in the given
1408 * @vg_name VG or in system if @vg_name is %NULL.
1409 *
1410 * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY
1411 */
1412 BDLVMLVdata** bd_lvm_lvs_tree (const gchar *vg_name, GError **error);
1413
1414 /**
1415 * bd_lvm_thpoolcreate:
1416 * @vg_name: name of the VG to create a thin pool in
1417 * @lv_name: name of the to-be-created pool LV
1418 * @size: requested size of the to-be-created pool
1419 * @md_size: requested metadata size or 0 to use the default
1420 * @chunk_size: requested chunk size or 0 to use the default
1421 * @profile: (nullable): profile to use (see lvm(8) for more information) or %NULL to use
1422 * the default
1423 * @extra: (nullable) (array zero-terminated=1): extra options for the thin pool creation
1424 * (just passed to LVM as is)
1425 * @error: (out) (optional): place to store error (if any)
1426 *
1427 * Returns: whether the @vg_name/@lv_name thin pool was successfully created or not
1428 *
1429 * Tech category: %BD_LVM_TECH_THIN-%BD_LVM_TECH_MODE_CREATE
1430 */
1431 gboolean bd_lvm_thpoolcreate (const gchar *vg_name, const gchar *lv_name, guint64 size, guint64 md_size, guint64 chunk_size, const gchar *profile, const BDExtraArg **extra, GError **error);
1432
1433 /**
1434 * bd_lvm_thlvcreate:
1435 * @vg_name: name of the VG containing the thin pool providing extents for the to-be-created thin LV
1436 * @pool_name: name of the pool LV providing extents for the to-be-created thin LV
1437 * @lv_name: name of the to-be-created thin LV
1438 * @size: requested virtual size of the to-be-created thin LV
1439 * @extra: (nullable) (array zero-terminated=1): extra options for the thin LV creation
1440 * (just passed to LVM as is)
1441 * @error: (out) (optional): place to store error (if any)
1442 *
1443 * Returns: whether the @vg_name/@lv_name thin LV was successfully created or not
1444 *
1445 * Tech category: %BD_LVM_TECH_THIN-%BD_LVM_TECH_MODE_CREATE
1446 */
1447 gboolean bd_lvm_thlvcreate (const gchar *vg_name, const gchar *pool_name, const gchar *lv_name, guint64 size, const BDExtraArg **extra, GError **error);
1448
1449 /**
1450 * bd_lvm_thlvpoolname:
1451 * @vg_name: name of the VG containing the queried thin LV
1452 * @lv_name: name of the queried thin LV
1453 * @error: (out) (optional): place to store error (if any)
1454 *
1455 * Returns: (transfer full): the name of the pool volume for the @vg_name/@lv_name
1456 * thin LV or %NULL if failed to determine (@error) is set in those cases)
1457 *
1458 * Tech category: %BD_LVM_TECH_THIN-%BD_LVM_TECH_MODE_QUERY
1459 */
1460 gchar* bd_lvm_thlvpoolname (const gchar *vg_name, const gchar *lv_name, GError **error);
1461
1462 /**
1463 * bd_lvm_thsnapshotcreate:
1464 * @vg_name: name of the VG containing the thin LV a new snapshot should be created of
1465 * @origin_name: name of the thin LV a new snapshot should be created of
1466 * @snapshot_name: name of the to-be-created snapshot
1467 * @pool_name: (nullable): name of the thin pool to create the snapshot in or %NULL if not specified
1468 * @extra: (nullable) (array zero-terminated=1): extra options for the thin LV snapshot creation
1469 * (just passed to LVM as is)
1470 * @error: (out) (optional): place to store error (if any)
1471 *
1472 * Returns: whether the @snapshot_name snapshot of the @vg_name/@origin_name
1473 * thin LV was successfully created or not.
1474 *
1475 * Tech category: %BD_LVM_TECH_THIN-%BD_LVM_TECH_MODE_CREATE
1476 */
1477 gboolean bd_lvm_thsnapshotcreate (const gchar *vg_name, const gchar *origin_name, const gchar *snapshot_name, const gchar *pool_name, const BDExtraArg **extra, GError **error);
1478
1479 /**
1480 * bd_lvm_set_global_config:
1481 * @new_config: (nullable): string representation of the new global libblockdev LVM
1482 * configuration to set or %NULL to reset to default
1483 * @error: (out) (optional): place to store error (if any)
1484 *
1485 *
1486 * Note: This function sets configuration options for LVM calls internally
1487 * in libblockdev, it doesn't change the global lvm.conf config file.
1488 * Calling this function with `backup {backup=0 archive=0}` for example
1489 * means `--config=backup {backup=0 archive=0}"` will be added to all
1490 * calls libblockdev makes.
1491 *
1492 * Returns: whether the new requested global config @new_config was successfully
1493 * set or not
1494 *
1495 * Tech category: %BD_LVM_TECH_GLOB_CONF no mode (it is ignored)
1496 */
1497 gboolean bd_lvm_set_global_config (const gchar *new_config, GError **error);
1498
1499 /**
1500 * bd_lvm_get_global_config:
1501 * @error: (out) (optional): place to store error (if any)
1502 *
1503 * Returns: (transfer full): a copy of a string representation of the currently
1504 * set libblockdev LVM global configuration
1505 *
1506 * Note: This function does not change the global `lvm.conf` config
1507 * file, see %bd_lvm_set_global_config for details.
1508 *
1509 * Tech category: %BD_LVM_TECH_GLOB_CONF no mode (it is ignored)
1510 */
1511 gchar* bd_lvm_get_global_config (GError **error);
1512
1513 /**
1514 * bd_lvm_set_devices_filter:
1515 * @devices: (nullable) (array zero-terminated=1): list of devices for lvm commands to work on
1516 * @error: (out) (optional): place to store error (if any)
1517 *
1518 * Returns: whether the devices filter was successfully set or not
1519 *
1520 * Tech category: %BD_LVM_TECH_DEVICES no mode (it is ignored)
1521 */
1522 gboolean bd_lvm_set_devices_filter (const gchar **devices, GError **error);
1523
1524 /**
1525 * bd_lvm_get_devices_filter:
1526 * @error: (out) (optional): place to store error (if any)
1527 *
1528 * Returns: (transfer full) (array zero-terminated=1): a copy of a string representation of
1529 * the currently set LVM devices filter
1530 *
1531 * Tech category: %BD_LVM_TECH_DEVICES no mode (it is ignored)
1532 */
1533 gchar** bd_lvm_get_devices_filter (GError **error);
1534
1535 /**
1536 * bd_lvm_cache_get_default_md_size:
1537 * @cache_size: size of the cache to determine MD size for
1538 * @error: (out) (optional): place to store error (if any)
1539 *
1540 * Returns: recommended default size of the cache metadata LV or 0 in case of error
1541 *
1542 * Tech category: %BD_LVM_TECH_CACHE_CALCS no mode (it is ignored)
1543 */
1544 guint64 bd_lvm_cache_get_default_md_size (guint64 cache_size, GError **error);
1545
1546 /**
1547 * bd_lvm_cache_get_mode_str:
1548 * @mode: mode to get the string representation for
1549 * @error: (out) (optional): place to store error (if any)
1550 *
1551 * Returns: string representation of @mode or %NULL in case of error
1552 *
1553 * Tech category: always provided/supported
1554 */
1555 const gchar* bd_lvm_cache_get_mode_str (BDLVMCacheMode mode, GError **error);
1556
1557 /**
1558 * bd_lvm_cache_get_mode_from_str:
1559 * @mode_str: string representation of a cache mode
1560 * @error: (out) (optional): place to store error (if any)
1561 *
1562 * Returns: cache mode for the @mode_str or %BD_LVM_CACHE_MODE_UNKNOWN if
1563 * failed to determine
1564 *
1565 * Tech category: always provided/supported
1566 */
1567 BDLVMCacheMode bd_lvm_cache_get_mode_from_str (const gchar *mode_str, GError **error);
1568
1569 /**
1570 * bd_lvm_cache_create_pool:
1571 * @vg_name: name of the VG to create @pool_name in
1572 * @pool_name: name of the cache pool LV to create
1573 * @pool_size: desired size of the cache pool @pool_name
1574 * @md_size: desired size of the @pool_name cache pool's metadata LV or 0 to
1575 * use the default
1576 * @mode: cache mode of the @pool_name cache pool
1577 * @flags: a combination of (ORed) #BDLVMCachePoolFlags
1578 * @fast_pvs: (array zero-terminated=1): list of (fast) PVs to create the @pool_name
1579 * cache pool (and the metadata LV)
1580 * @error: (out) (optional): place to store error (if any)
1581 *
1582 * Returns: whether the cache pool @vg_name/@pool_name was successfully created or not
1583 *
1584 * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_CREATE
1585 */
1586 gboolean bd_lvm_cache_create_pool (const gchar *vg_name, const gchar *pool_name, guint64 pool_size, guint64 md_size, BDLVMCacheMode mode, BDLVMCachePoolFlags flags, const gchar **fast_pvs, GError **error);
1587
1588 /**
1589 * bd_lvm_cache_attach:
1590 * @vg_name: name of the VG containing the @data_lv and the @cache_pool_lv LVs
1591 * @data_lv: data LV to attach the @cache_pool_lv to
1592 * @cache_pool_lv: cache pool LV to attach to the @data_lv
1593 * @extra: (nullable) (array zero-terminated=1): extra options for the cache attachment
1594 * (just passed to LVM as is)
1595 * @error: (out) (optional): place to store error (if any)
1596 *
1597 * Returns: whether the @cache_pool_lv was successfully attached to the @data_lv or not
1598 *
1599 * Note: Both @data_lv and @cache_lv will be deactivated before the operation.
1600 *
1601 * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_MODIFY
1602 */
1603 gboolean bd_lvm_cache_attach (const gchar *vg_name, const gchar *data_lv, const gchar *cache_pool_lv, const BDExtraArg **extra, GError **error);
1604
1605 /**
1606 * bd_lvm_cache_detach:
1607 * @vg_name: name of the VG containing the @cached_lv
1608 * @cached_lv: name of the cached LV to detach its cache from
1609 * @destroy: whether to destroy the cache after detach or not
1610 * @extra: (nullable) (array zero-terminated=1): extra options for the cache detachment
1611 * (just passed to LVM as is)
1612 * @error: (out) (optional): place to store error (if any)
1613 *
1614 * Returns: whether the cache was successfully detached from the @cached_lv or not
1615 *
1616 * Note: synces the cache first
1617 *
1618 * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_MODIFY
1619 */
1620 gboolean bd_lvm_cache_detach (const gchar *vg_name, const gchar *cached_lv, gboolean destroy, const BDExtraArg **extra, GError **error);
1621
1622 /**
1623 * bd_lvm_cache_create_cached_lv:
1624 * @vg_name: name of the VG to create a cached LV in
1625 * @lv_name: name of the cached LV to create
1626 * @data_size: size of the data LV
1627 * @cache_size: size of the cache (or cached LV more precisely)
1628 * @md_size: size of the cache metadata LV or 0 to use the default
1629 * @mode: cache mode for the cached LV
1630 * @flags: a combination of (ORed) #BDLVMCachePoolFlags
1631 * @slow_pvs: (array zero-terminated=1): list of slow PVs (used for the data LV)
1632 * @fast_pvs: (array zero-terminated=1): list of fast PVs (used for the cache LV)
1633 * @error: (out) (optional): place to store error (if any)
1634 *
1635 * Returns: whether the cached LV @lv_name was successfully created or not
1636 *
1637 * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_CREATE
1638 */
1639 gboolean bd_lvm_cache_create_cached_lv (const gchar *vg_name, const gchar *lv_name, guint64 data_size, guint64 cache_size, guint64 md_size, BDLVMCacheMode mode, BDLVMCachePoolFlags flags, const gchar **slow_pvs, const gchar **fast_pvs, GError **error);
1640
1641 /**
1642 * bd_lvm_cache_pool_name:
1643 * @vg_name: name of the VG containing the @cached_lv
1644 * @cached_lv: cached LV to get the name of the its pool LV for
1645 * @error: (out) (optional): place to store error (if any)
1646 *
1647 * Returns: name of the cache pool LV used by the @cached_lv or %NULL in case of error
1648 *
1649 * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_QUERY
1650 */
1651 gchar* bd_lvm_cache_pool_name (const gchar *vg_name, const gchar *cached_lv, GError **error);
1652
1653 /**
1654 * bd_lvm_cache_stats:
1655 * @vg_name: name of the VG containing the @cached_lv
1656 * @cached_lv: cached LV to get stats for
1657 * @error: (out) (optional): place to store error (if any)
1658 *
1659 * Returns: stats for the @cached_lv or %NULL in case of error
1660 *
1661 * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_QUERY
1662 */
1663 BDLVMCacheStats* bd_lvm_cache_stats (const gchar *vg_name, const gchar *cached_lv, GError **error);
1664
1665 /**
1666 * bd_lvm_writecache_attach:
1667 * @vg_name: name of the VG containing the @data_lv and the @cache_pool_lv LVs
1668 * @data_lv: data LV to attach the @cache_lv to
1669 * @cache_lv: cache (fast) LV to attach to the @data_lv
1670 * @extra: (nullable) (array zero-terminated=1): extra options for the cache attachment
1671 * (just passed to LVM as is)
1672 * @error: (out) (optional): place to store error (if any)
1673 *
1674 * Returns: whether the @cache_lv was successfully attached to the @data_lv or not
1675 *
1676 * Tech category: %BD_LVM_TECH_WRITECACHE-%BD_LVM_TECH_MODE_MODIFY
1677 */
1678 gboolean bd_lvm_writecache_attach (const gchar *vg_name, const gchar *data_lv, const gchar *cache_lv, const BDExtraArg **extra, GError **error);
1679
1680 /**
1681 * bd_lvm_writecache_detach:
1682 * @vg_name: name of the VG containing the @cached_lv
1683 * @cached_lv: name of the cached LV to detach its cache from
1684 * @destroy: whether to destroy the cache after detach or not
1685 * @extra: (nullable) (array zero-terminated=1): extra options for the cache detachment
1686 * (just passed to LVM as is)
1687 * @error: (out) (optional): place to store error (if any)
1688 *
1689 * Returns: whether the cache was successfully detached from the @cached_lv or not
1690 *
1691 * Note: synces the cache first
1692 *
1693 * Tech category: %BD_LVM_TECH_WRITECACHE-%BD_LVM_TECH_MODE_MODIFY
1694 */
1695 gboolean bd_lvm_writecache_detach (const gchar *vg_name, const gchar *cached_lv, gboolean destroy, const BDExtraArg **extra, GError **error);
1696
1697 /**
1698 * bd_lvm_writecache_create_cached_lv:
1699 * @vg_name: name of the VG to create a cached LV in
1700 * @lv_name: name of the cached LV to create
1701 * @data_size: size of the data LV
1702 * @cache_size: size of the cache (or cached LV more precisely)
1703 * @slow_pvs: (array zero-terminated=1): list of slow PVs (used for the data LV)
1704 * @fast_pvs: (array zero-terminated=1): list of fast PVs (used for the cache LV)
1705 * @error: (out) (optional): place to store error (if any)
1706 *
1707 * Returns: whether the cached LV @lv_name was successfully created or not
1708 *
1709 * Tech category: %BD_LVM_TECH_WRITECACHE-%BD_LVM_TECH_MODE_CREATE
1710 */
1711 gboolean bd_lvm_writecache_create_cached_lv (const gchar *vg_name, const gchar *lv_name, guint64 data_size, guint64 cache_size, const gchar **slow_pvs, const gchar **fast_pvs, GError **error);
1712
1713 /**
1714 * bd_lvm_thpool_convert:
1715 * @vg_name: name of the VG to create the new thin pool in
1716 * @data_lv: name of the LV that should become the data part of the new pool
1717 * @metadata_lv: name of the LV that should become the metadata part of the new pool
1718 * @name: (nullable): name for the thin pool (if %NULL, the name @data_lv is inherited)
1719 * @extra: (nullable) (array zero-terminated=1): extra options for the thin pool creation
1720 * (just passed to LVM as is)
1721 * @error: (out) (optional): place to store error (if any)
1722 *
1723 * Converts the @data_lv and @metadata_lv into a new thin pool in the @vg_name
1724 * VG.
1725 *
1726 * Returns: whether the new thin pool was successfully created from @data_lv and
1727 * @metadata_lv or not
1728 *
1729 * Tech category: %BD_LVM_TECH_THIN-%BD_LVM_TECH_MODE_CREATE
1730 */
1731 gboolean bd_lvm_thpool_convert (const gchar *vg_name, const gchar *data_lv, const gchar *metadata_lv, const gchar *name, const BDExtraArg **extra, GError **error);
1732
1733 /**
1734 * bd_lvm_cache_pool_convert:
1735 * @vg_name: name of the VG to create the new thin pool in
1736 * @data_lv: name of the LV that should become the data part of the new pool
1737 * @metadata_lv: name of the LV that should become the metadata part of the new pool
1738 * @name: (nullable): name for the thin pool (if %NULL, the name @data_lv is inherited)
1739 * @extra: (nullable) (array zero-terminated=1): extra options for the thin pool creation
1740 * (just passed to LVM as is)
1741 * @error: (out) (optional): place to store error (if any)
1742 *
1743 * Converts the @data_lv and @metadata_lv into a new cache pool in the @vg_name
1744 * VG.
1745 *
1746 * Returns: whether the new cache pool was successfully created from @data_lv and
1747 * @metadata_lv or not
1748 *
1749 * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_CREATE
1750 */
1751 gboolean bd_lvm_cache_pool_convert (const gchar *vg_name, const gchar *data_lv, const gchar *metadata_lv, const gchar *name, const BDExtraArg **extra, GError **error);
1752
1753 /**
1754 * bd_lvm_vdo_pool_create:
1755 * @vg_name: name of the VG to create a new LV in
1756 * @lv_name: name of the to-be-created VDO LV
1757 * @pool_name: (nullable): name of the to-be-created VDO pool LV or %NULL for default name
1758 * @data_size: requested size of the data VDO LV (physical size of the @pool_name VDO pool LV)
1759 * @virtual_size: requested virtual_size of the @lv_name VDO LV
1760 * @index_memory: amount of index memory (in bytes) or 0 for default
1761 * @compression: whether to enable compression or not
1762 * @deduplication: whether to enable deduplication or not
1763 * @write_policy: write policy for the volume
1764 * @extra: (nullable) (array zero-terminated=1): extra options for the VDO LV creation
1765 * (just passed to LVM as is)
1766 * @error: (out) (optional): place to store error (if any)
1767 *
1768 * Returns: whether the given @vg_name/@lv_name VDO LV was successfully created or not
1769 *
1770 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_CREATE
1771 */
1772 gboolean bd_lvm_vdo_pool_create (const gchar *vg_name, const gchar *lv_name, const gchar *pool_name, guint64 data_size, guint64 virtual_size, guint64 index_memory, gboolean compression, gboolean deduplication, BDLVMVDOWritePolicy write_policy, const BDExtraArg **extra, GError **error);
1773
1774 /**
1775 * bd_lvm_vdo_enable_compression:
1776 * @vg_name: name of the VG containing the to-be-changed VDO pool LV
1777 * @pool_name: name of the VDO pool LV to enable compression on
1778 * @extra: (nullable) (array zero-terminated=1): extra options for the VDO change
1779 * (just passed to LVM as is)
1780 * @error: (out) (optional): place to store error (if any)
1781 *
1782 * Returns: whether compression was successfully enabled on @vg_name/@pool_name LV or not
1783 *
1784 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_MODIFY
1785 */
1786 gboolean bd_lvm_vdo_enable_compression (const gchar *vg_name, const gchar *pool_name, const BDExtraArg **extra, GError **error);
1787
1788 /**
1789 * bd_lvm_vdo_disable_compression:
1790 * @vg_name: name of the VG containing the to-be-changed VDO pool LV
1791 * @pool_name: name of the VDO pool LV to disable compression on
1792 * @extra: (nullable) (array zero-terminated=1): extra options for the VDO change
1793 * (just passed to LVM as is)
1794 * @error: (out) (optional): place to store error (if any)
1795 *
1796 * Returns: whether compression was successfully disabled on @vg_name/@pool_name LV or not
1797 *
1798 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_MODIFY
1799 */
1800 gboolean bd_lvm_vdo_disable_compression (const gchar *vg_name, const gchar *pool_name, const BDExtraArg **extra, GError **error);
1801
1802 /**
1803 * bd_lvm_vdo_enable_deduplication:
1804 * @vg_name: name of the VG containing the to-be-changed VDO pool LV
1805 * @pool_name: name of the VDO pool LV to enable deduplication on
1806 * @extra: (nullable) (array zero-terminated=1): extra options for the VDO change
1807 * (just passed to LVM as is)
1808 * @error: (out) (optional): place to store error (if any)
1809 *
1810 * Returns: whether deduplication was successfully enabled on @vg_name/@pool_name LV or not
1811 *
1812 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_MODIFY
1813 */
1814 gboolean bd_lvm_vdo_enable_deduplication (const gchar *vg_name, const gchar *pool_name, const BDExtraArg **extra, GError **error);
1815
1816 /**
1817 * bd_lvm_vdo_disable_deduplication:
1818 * @vg_name: name of the VG containing the to-be-changed VDO pool LV
1819 * @pool_name: name of the VDO pool LV to disable deduplication on
1820 * @extra: (nullable) (array zero-terminated=1): extra options for the VDO change
1821 * (just passed to LVM as is)
1822 * @error: (out) (optional): place to store error (if any)
1823 *
1824 * Returns: whether deduplication was successfully disabled on @vg_name/@pool_name LV or not
1825 *
1826 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_MODIFY
1827 */
1828 gboolean bd_lvm_vdo_disable_deduplication (const gchar *vg_name, const gchar *pool_name, const BDExtraArg **extra, GError **error);
1829
1830 /**
1831 * bd_lvm_vdo_info:
1832 * @vg_name: name of the VG that contains the LV to get information about
1833 * @lv_name: name of the LV to get information about
1834 * @error: (out) (optional): place to store error (if any)
1835 *
1836 * Returns: (transfer full): information about the @vg_name/@lv_name LV or %NULL in case
1837 * of error (the @error) gets populated in those cases)
1838 *
1839 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_QUERY
1840 */
1841 BDLVMVDOPooldata* bd_lvm_vdo_info (const gchar *vg_name, const gchar *lv_name, GError **error);
1842
1843 /**
1844 * bd_lvm_vdo_resize:
1845 * @vg_name: name of the VG containing the to-be-resized VDO LV
1846 * @lv_name: name of the to-be-resized VDO LV
1847 * @size: the requested new size of the VDO LV
1848 * @extra: (nullable) (array zero-terminated=1): extra options for the VDO LV resize
1849 * (just passed to LVM as is)
1850 * @error: (out) (optional): place to store error (if any)
1851 *
1852 * Returns: whether the @vg_name/@lv_name VDO LV was successfully resized or not
1853 *
1854 * Note: Reduction needs to process TRIM for reduced disk area to unmap used data blocks
1855 * from the VDO pool LV and it may take a long time.
1856 *
1857 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_MODIFY
1858 */
1859 gboolean bd_lvm_vdo_resize (const gchar *vg_name, const gchar *lv_name, guint64 size, const BDExtraArg **extra, GError **error);
1860
1861 /**
1862 * bd_lvm_vdo_pool_resize:
1863 * @vg_name: name of the VG containing the to-be-resized VDO pool LV
1864 * @pool_name: name of the to-be-resized VDO pool LV
1865 * @size: the requested new size of the VDO pool LV
1866 * @extra: (nullable) (array zero-terminated=1): extra options for the VDO pool LV resize
1867 * (just passed to LVM as is)
1868 * @error: (out) (optional): place to store error (if any)
1869 *
1870 * Returns: whether the @vg_name/@pool_name VDO pool LV was successfully resized or not
1871 *
1872 * Note: Size of the VDO pool LV can be only extended, not reduced.
1873 *
1874 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_MODIFY
1875 */
1876 gboolean bd_lvm_vdo_pool_resize (const gchar *vg_name, const gchar *pool_name, guint64 size, const BDExtraArg **extra, GError **error);
1877
1878 /**
1879 * bd_lvm_vdo_pool_convert:
1880 * @vg_name: name of the VG that contains @pool_lv
1881 * @pool_lv: name of the LV that should become the new VDO pool LV
1882 * @name: (nullable): name for the VDO LV or %NULL for default name
1883 * @virtual_size: virtual size for the new VDO LV
1884 * @index_memory: amount of index memory (in bytes) or 0 for default
1885 * @compression: whether to enable compression or not
1886 * @deduplication: whether to enable deduplication or not
1887 * @write_policy: write policy for the volume
1888 * @extra: (nullable) (array zero-terminated=1): extra options for the VDO pool creation
1889 * (just passed to LVM as is)
1890 * @error: (out) (optional): place to store error (if any)
1891 *
1892 * Converts the @pool_lv into a new VDO pool LV in the @vg_name VG and creates a new
1893 * @name VDO LV with size @virtual_size.
1894 *
1895 * Note: All data on @pool_lv will be irreversibly destroyed.
1896 *
1897 * Returns: whether the new VDO pool LV was successfully created from @pool_lv and or not
1898 *
1899 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_CREATE&%BD_LVM_TECH_MODE_MODIFY
1900 */
1901 gboolean bd_lvm_vdo_pool_convert (const gchar *vg_name, const gchar *pool_lv, const gchar *name, guint64 virtual_size, guint64 index_memory, gboolean compression, gboolean deduplication, BDLVMVDOWritePolicy write_policy, const BDExtraArg **extra, GError **error);
1902
1903 /**
1904 * bd_lvm_vdolvpoolname:
1905 * @vg_name: name of the VG containing the queried VDO LV
1906 * @lv_name: name of the queried VDO LV
1907 * @error: (out) (optional): place to store error (if any)
1908 *
1909 * Returns: (transfer full): the name of the pool volume for the @vg_name/@lv_name
1910 * VDO LV or %NULL if failed to determine (@error) is set in those cases)
1911 *
1912 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_QUERY
1913 */
1914 gchar* bd_lvm_vdolvpoolname (const gchar *vg_name, const gchar *lv_name, GError **error);
1915
1916 /**
1917 * bd_lvm_get_vdo_operating_mode_str:
1918 * @mode: mode to get the string representation for
1919 * @error: (out) (optional): place to store error (if any)
1920 *
1921 * Returns: string representation of @mode or %NULL in case of error
1922 *
1923 * Tech category: always provided/supported
1924 */
1925 const gchar* bd_lvm_get_vdo_operating_mode_str (BDLVMVDOOperatingMode mode, GError **error);
1926
1927 /**
1928 * bd_lvm_get_vdo_compression_state_str:
1929 * @state: state to get the string representation for
1930 * @error: (out) (optional): place to store error (if any)
1931 *
1932 * Returns: string representation of @state or %NULL in case of error
1933 *
1934 * Tech category: always provided/supported
1935 */
1936 const gchar* bd_lvm_get_vdo_compression_state_str (BDLVMVDOCompressionState state, GError **error);
1937
1938 /**
1939 * bd_lvm_get_vdo_index_state_str:
1940 * @state: state to get the string representation for
1941 * @error: (out) (optional): place to store error (if any)
1942 *
1943 * Returns: string representation of @state or %NULL in case of error
1944 *
1945 * Tech category: always provided/supported
1946 */
1947 const gchar* bd_lvm_get_vdo_index_state_str (BDLVMVDOIndexState state, GError **error);
1948
1949 /**
1950 * bd_lvm_get_vdo_write_policy_str:
1951 * @policy: policy to get the string representation for
1952 * @error: (out) (optional): place to store error (if any)
1953 *
1954 * Returns: string representation of @policy or %NULL in case of error
1955 *
1956 * Tech category: always provided/supported
1957 */
1958 const gchar* bd_lvm_get_vdo_write_policy_str (BDLVMVDOWritePolicy policy, GError **error);
1959
1960 /**
1961 * bd_lvm_get_vdo_write_policy_from_str:
1962 * @policy_str: string representation of a policy
1963 * @error: (out) (optional): place to store error (if any)
1964 *
1965 * Returns: write policy for the @policy_str or %BD_LVM_VDO_WRITE_POLICY_UNKNOWN if
1966 * failed to determine
1967 *
1968 * Tech category: always provided/supported
1969 */
1970 BDLVMVDOWritePolicy bd_lvm_get_vdo_write_policy_from_str (const gchar *policy_str, GError **error);
1971
1972 /**
1973 * bd_lvm_vdo_get_stats_full:
1974 * @vg_name: name of the VG that contains @pool_name VDO pool
1975 * @pool_name: name of the VDO pool to get statistics for
1976 * @error: (out) (optional): place to store error (if any)
1977 *
1978 * Returns: (transfer full) (element-type utf8 utf8): hashtable of type string - string of available
1979 * statistics or %NULL in case of error
1980 * (@error gets populated in those cases)
1981 *
1982 * Statistics are collected from the values exposed by the kernel `dm-vdo` module.
1983 *
1984 * Some of the keys are computed to mimic the information produced by the vdo tools.
1985 * Please note the contents of the hashtable may vary depending on the actual dm-vdo module version.
1986 *
1987 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_QUERY
1988 */
1989 GHashTable* bd_lvm_vdo_get_stats_full (const gchar *vg_name, const gchar *pool_name, GError **error);
1990
1991 /**
1992 * bd_lvm_vdo_get_stats:
1993 * @vg_name: name of the VG that contains @pool_name VDO pool
1994 * @pool_name: name of the VDO pool to get statistics for
1995 * @error: (out) (optional): place to store error (if any)
1996 *
1997 * Returns: (transfer full): a structure containing selected statistics or %NULL in case of error
1998 * (@error gets populated in those cases)
1999 *
2000 * In contrast to @bd_lvm_vdo_get_stats_full this function will only return selected statistics
2001 * in a fixed structure. In case a value is not available, -1 would be returned.
2002 *
2003 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_QUERY
2004 */
2005 BDLVMVDOStats* bd_lvm_vdo_get_stats (const gchar *vg_name, const gchar *pool_name, GError **error);
2006
2007 /**
2008 * bd_lvm_devices_add:
2009 * @device: device (PV) to add to the devices file
2010 * @devices_file: (nullable): LVM devices file or %NULL for default
2011 * @extra: (nullable) (array zero-terminated=1): extra options for the lvmdevices command
2012 * @error: (out) (optional): place to store error (if any)
2013 *
2014 * Returns: whether the @device was successfully added to @devices_file or not
2015 *
2016 * Tech category: %BD_LVM_TECH_DEVICES no mode (it is ignored)
2017 */
2018 gboolean bd_lvm_devices_add (const gchar *device, const gchar *devices_file, const BDExtraArg **extra, GError **error);
2019
2020 /**
2021 * bd_lvm_devices_delete:
2022 * @device: device (PV) to delete from the devices file
2023 * @devices_file: (nullable): LVM devices file or %NULL for default
2024 * @extra: (nullable) (array zero-terminated=1): extra options for the lvmdevices command
2025 * @error: (out) (optional): place to store error (if any)
2026 *
2027 * Returns: whether the @device was successfully removed from @devices_file or not
2028 *
2029 * Tech category: %BD_LVM_TECH_DEVICES no mode (it is ignored)
2030 */
2031 gboolean bd_lvm_devices_delete (const gchar *device, const gchar *devices_file, const BDExtraArg **extra, GError **error);
2032
2033 /**
2034 * bd_lvm_config_get:
2035 * @section: (nullable): LVM config section, e.g. 'global' or %NULL to print the entire config
2036 * @setting: (nullable): name of the specific setting, e.g. 'umask' or %NULL to print the entire @section
2037 * @type: type of the config, e.g. 'full' or 'current'
2038 * @values_only: whether to include only values without keys in the output
2039 * @global_config: whether to include our internal global config in the call or not
2040 * @extra: (nullable) (array zero-terminated=1): extra options for the lvmconfig command
2041 * (just passed to LVM as is)
2042 * @error: (out) (optional): place to store error (if any)
2043 *
2044 * Returns: (transfer full): Requested LVM config @section and @setting configuration or %NULL in case of error.
2045 *
2046 * Tech category: %BD_LVM_TECH_CONFIG no mode (it is ignored)
2047 */
2048 gchar* bd_lvm_config_get (const gchar *section, const gchar *setting, const gchar *type, gboolean values_only, gboolean global_config, const BDExtraArg **extra, GError **error);
2049
2050 /**
2051 * bd_lvm_vgcfgbackup:
2052 * @vg_name: name of the VG to backup configuration
2053 * @backup_file: (nullable): file to save the backup to or %NULL for using the default backup file
2054 * in /etc/lvm/backup
2055 * @extra: (nullable) (array zero-terminated=1): extra options for the vgcfgbackup command
2056 * (just passed to LVM as is)
2057 * @error: (out) (optional): place to store error (if any)
2058 *
2059 * Note: This function does not back up the data content of LVs. See `vgcfbackup(8)` man page
2060 * for more information.
2061 *
2062 * Returns: Whether the backup was successfully created or not.
2063 *
2064 * Tech category: %BD_LVM_TECH_VG_CFG_BACKUP_RESTORE no mode (it is ignored)
2065 */
2066 gboolean bd_lvm_vgcfgbackup (const gchar *vg_name, const gchar *backup_file, const BDExtraArg **extra, GError **error);
2067
2068 /**
2069 * bd_lvm_vgcfgrestore:
2070 * @vg_name: name of the VG to restore configuration
2071 * @backup_file: (nullable): file to restore VG configuration from to or %NULL for using the
2072 * latest backup in /etc/lvm/backup
2073 * @extra: (nullable) (array zero-terminated=1): extra options for the vgcfgrestore command
2074 * (just passed to LVM as is)
2075 * @error: (out) (optional): place to store error (if any)
2076 *
2077 * Note: This function restores VG configuration created by %bd_lvm_vgcfgbackup from given
2078 * @backup_file or from the latest backup in /etc/lvm/backup.
2079 *
2080 * Returns: Whether the configuration was successfully restored or not.
2081 *
2082 * Tech category: %BD_LVM_TECH_VG_CFG_BACKUP_RESTORE no mode (it is ignored)
2083 */
2084 gboolean bd_lvm_vgcfgrestore (const gchar *vg_name, const gchar *backup_file, const BDExtraArg **extra, GError **error);
2085
2086 #endif /* BD_LVM_API */