2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
9 * of the GNU Lesser General Public License v.2.1.
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, write to the Free Software Foundation,
13 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * This is the representation of LVM metadata that is being adapted
21 #ifndef _LVM_METADATA_EXPORTED_H
22 #define _LVM_METADATA_EXPORTED_H
28 #include "lvm-percent.h"
30 #define MAX_STRIPES 128U
31 #define SECTOR_SHIFT 9L
32 #define SECTOR_SIZE ( 1L << SECTOR_SHIFT )
33 #define STRIPE_SIZE_MIN ( (unsigned) lvm_getpagesize() >> SECTOR_SHIFT) /* PAGESIZE in sectors */
34 #define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
35 #define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
36 #define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
37 #define MAX_RESTRICTED_LVS 255 /* Used by FMT_RESTRICTED_LVIDS */
40 #define MIRROR_SYNC_LAYER "_mimagetmp"
43 /* Note that the bits no longer necessarily correspond to LVM1 disk format */
45 #define PARTIAL_VG 0x00000001U /* VG */
46 #define EXPORTED_VG 0x00000002U /* VG PV */
47 #define RESIZEABLE_VG 0x00000004U /* VG */
49 /* May any free extents on this PV be used or must they be left free? */
50 #define ALLOCATABLE_PV 0x00000008U /* PV */
52 //#define SPINDOWN_LV 0x00000010U /* LV */
53 //#define BADBLOCK_ON 0x00000020U /* LV */
54 #define VISIBLE_LV 0x00000040U /* LV */
55 #define FIXED_MINOR 0x00000080U /* LV */
56 /* FIXME Remove when metadata restructuring is completed */
57 #define SNAPSHOT 0x00001000U /* LV - internal use only */
58 #define PVMOVE 0x00002000U /* VG LV SEG */
59 #define LOCKED 0x00004000U /* LV */
60 #define MIRRORED 0x00008000U /* LV - internal use only */
61 //#define VIRTUAL 0x00010000U /* LV - internal use only */
62 #define MIRROR_LOG 0x00020000U /* LV */
63 #define MIRROR_IMAGE 0x00040000U /* LV */
64 #define MIRROR_NOTSYNCED 0x00080000U /* LV */
65 //#define ACTIVATE_EXCL 0x00100000U /* LV - internal use only */
66 //#define PRECOMMITTED 0x00200000U /* VG - internal use only */
67 #define CONVERTING 0x00400000U /* LV */
69 #define MISSING_PV 0x00800000U /* PV */
70 #define PARTIAL_LV 0x01000000U /* LV - derived flag, not
71 written out in metadata*/
73 //#define POSTORDER_FLAG 0x02000000U /* Not real flags, reserved for
74 //#define POSTORDER_OPEN_FLAG 0x04000000U temporary use inside vg_read_internal. */
75 //#define VIRTUAL_ORIGIN 0x08000000U /* LV - internal use only */
77 #define MERGING 0x10000000U /* LV SEG */
79 #define REPLICATOR 0x20000000U /* LV -internal use only for replicator */
80 #define REPLICATOR_LOG 0x40000000U /* LV -internal use only for replicator-dev */
82 #define LVM_READ 0x00000100U /* LV VG */
83 #define LVM_WRITE 0x00000200U /* LV VG */
84 #define CLUSTERED 0x00000400U /* VG */
85 //#define SHARED 0x00000800U /* VG */
87 /* Format features flags */
88 #define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */
89 #define FMT_MDAS 0x00000002U /* Proper metadata areas? */
90 #define FMT_TAGS 0x00000004U /* Tagging? */
91 #define FMT_UNLIMITED_VOLS 0x00000008U /* Unlimited PVs/LVs? */
92 #define FMT_RESTRICTED_LVIDS 0x00000010U /* LVID <= 255 */
93 #define FMT_ORPHAN_ALLOCATABLE 0x00000020U /* Orphan PV allocatable? */
94 //#define FMT_PRECOMMIT 0x00000040U /* Supports pre-commit? */
95 #define FMT_RESIZE_PV 0x00000080U /* Supports pvresize? */
96 #define FMT_UNLIMITED_STRIPESIZE 0x00000100U /* Unlimited stripe size? */
97 #define FMT_RESTRICTED_READAHEAD 0x00000200U /* Readahead restricted to 2-120? */
99 /* Mirror conversion type flags */
100 #define MIRROR_BY_SEG 0x00000001U /* segment-by-segment mirror */
101 #define MIRROR_BY_LV 0x00000002U /* mirror using whole mimage LVs */
102 #define MIRROR_SKIP_INIT_SYNC 0x00000010U /* skip initial sync */
104 /* vg_read and vg_read_for_update flags */
105 #define READ_ALLOW_INCONSISTENT 0x00010000U
106 #define READ_ALLOW_EXPORTED 0x00020000U
107 #define READ_WITHOUT_LOCK 0x00040000U
109 /* A meta-flag, useful with toollib for_each_* functions. */
110 #define READ_FOR_UPDATE 0x00100000U
112 /* vg's "read_status" field */
113 #define FAILED_INCONSISTENT 0x00000001U
114 #define FAILED_LOCKING 0x00000002U
115 #define FAILED_NOTFOUND 0x00000004U
116 #define FAILED_READ_ONLY 0x00000008U
117 #define FAILED_EXPORTED 0x00000010U
118 #define FAILED_RESIZEABLE 0x00000020U
119 #define FAILED_CLUSTERED 0x00000040U
120 #define FAILED_ALLOCATION 0x00000080U
121 #define FAILED_EXIST 0x00000100U
122 #define SUCCESS 0x00000000U
124 #define VGMETADATACOPIES_ALL UINT32_MAX
125 #define VGMETADATACOPIES_UNMANAGED 0
127 /* Ordered list - see lv_manip.c */
135 * Whether or not to force an operation.
138 PROMPT = 0, /* Issue yes/no prompt to confirm operation */
139 DONT_PROMPT = 1, /* Skip yes/no prompt */
140 DONT_PROMPT_OVERRIDE = 2 /* Skip prompt + override a second condition */
144 struct format_handler;
149 struct cmd_context *cmd;
150 struct format_handler *ops;
151 struct labeller *labeller;
154 const char *orphan_vg_name;
161 struct dm_list list; /* Member of pv->segments: ordered list
162 * covering entire data area on this PV */
164 struct physical_volume *pv;
168 struct lv_segment *lvseg; /* NULL if free space */
169 uint32_t lv_area; /* Index to area in LV segment */
172 #define pvseg_is_allocated(pvseg) ((pvseg)->lvseg)
174 struct format_instance {
175 const struct format_type *fmt;
177 * Each mda in a vg is on exactly one of the below lists.
178 * MDAs on the 'in_use' list will be read from / written to
179 * disk, while MDAs on the 'ignored' list will not be read
182 struct dm_list metadata_areas_in_use;
183 struct dm_list metadata_areas_ignored;
187 /* There will be one area for each stripe */
188 struct lv_segment_area {
192 struct pv_segment *pvseg;
195 struct logical_volume *lv;
203 /* List with vg_name, vgid and flags */
209 struct volume_group *vg;
212 /* ++ Replicator datatypes */
214 REPLICATOR_STATE_PASSIVE,
215 REPLICATOR_STATE_ACTIVE,
217 } replicator_state_t;
219 struct replicator_site {
220 struct dm_list list; /* Chained list of sites */
221 struct dm_list rdevices; /* Device list */
223 struct logical_volume *replicator; /* Reference to replicator */
225 const char *name; /* Site name */
226 const char *vg_name; /* VG name */
227 struct volume_group *vg; /* resolved vg (activate/deactive) */
229 replicator_state_t state; /* Active or pasive state of site */
230 dm_replicator_mode_t op_mode; /* Operation mode sync or async fail|warn|drop|stall */
231 uint64_t fall_behind_data; /* Bytes */
232 uint32_t fall_behind_ios; /* IO operations */
233 uint32_t fall_behind_timeout; /* Seconds */
236 struct replicator_device {
237 struct dm_list list; /* Chained list of devices from same site */
239 struct lv_segment *replicator_dev; /* Reference to replicator-dev segment */
240 struct replicator_site *rsite; /* Reference to site parameters */
242 uint64_t device_index;
243 const char *name; /* Device LV name */
244 struct logical_volume *lv; /* LV from replicator site's VG */
245 struct logical_volume *slog; /* Synclog lv from VG */
246 const char *slog_name; /* Debug - specify size of core synclog */
248 /* -- Replicator datatypes */
252 struct logical_volume *lv;
254 const struct segment_type *segtype;
260 /* FIXME Fields depend on segment type */
261 uint32_t stripe_size;
264 uint32_t chunk_size; /* For snapshots - in sectors */
265 struct logical_volume *origin;
266 struct logical_volume *cow;
267 struct dm_list origin_list;
268 uint32_t region_size; /* For mirrors, replicators - in sectors */
269 uint32_t extents_copied;
270 struct logical_volume *log_lv;
271 struct lv_segment *pvmove_source_seg;
272 void *segtype_private;
276 struct lv_segment_area *areas;
278 struct logical_volume *replicator;/* For replicator-devs - link to replicator LV */
279 struct logical_volume *rlog_lv; /* For replicators */
280 const char *rlog_type; /* For replicators */
281 uint64_t rdevice_index_highest; /* For replicators */
282 unsigned rsite_index_highest; /* For replicators */
285 #define seg_type(seg, s) (seg)->areas[(s)].type
286 #define seg_pv(seg, s) (seg)->areas[(s)].u.pv.pvseg->pv
287 #define seg_lv(seg, s) (seg)->areas[(s)].u.lv.lv
291 uint32_t start; /* PEs */
292 uint32_t count; /* PEs */
297 struct physical_volume *pv;
298 struct dm_list *mdas; /* Metadata areas */
299 struct dm_list *pe_ranges; /* Ranges of PEs e.g. for allocation */
304 struct logical_volume *lv;
307 struct pvcreate_params {
310 uint64_t data_alignment;
311 uint64_t data_alignment_offset;
312 int pvmetadatacopies;
313 uint64_t pvmetadatasize;
315 struct id id; /* FIXME: redundant */
316 struct id *idp; /* 0 if no --uuid option */
318 uint32_t extent_count;
319 uint32_t extent_size;
320 const char *restorefile; /* 0 if no --restorefile option */
323 unsigned metadataignore;
326 struct physical_volume *pvcreate_single(struct cmd_context *cmd,
328 struct pvcreate_params *pp);
329 void pvcreate_params_set_defaults(struct pvcreate_params *pp);
334 int vg_write(struct volume_group *vg);
335 int vg_commit(struct volume_group *vg);
336 int vg_revert(struct volume_group *vg);
337 struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name,
338 const char *vgid, int warnings, int *consistent);
339 struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
340 struct dm_list *mdas, uint64_t *label_sector,
341 int warnings, int scan_label_only);
342 struct dm_list *get_pvs(struct cmd_context *cmd);
345 * Add/remove LV to/from volume group
347 int link_lv_to_vg(struct volume_group *vg, struct logical_volume *lv);
348 int unlink_lv_from_vg(struct logical_volume *lv);
349 void lv_set_visible(struct logical_volume *lv);
350 void lv_set_hidden(struct logical_volume *lv);
352 struct dm_list *get_vgnames(struct cmd_context *cmd, int include_internal);
353 struct dm_list *get_vgids(struct cmd_context *cmd, int include_internal);
354 int scan_vgs_for_pvs(struct cmd_context *cmd, int warnings);
356 int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
357 struct dm_list *mdas, int64_t label_sector);
358 int move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
359 const char *pv_name);
360 int move_pvs_used_by_lv(struct volume_group *vg_from,
361 struct volume_group *vg_to,
362 const char *lv_name);
363 int is_global_vg(const char *vg_name);
364 int is_orphan_vg(const char *vg_name);
365 int vg_missing_pv_count(const struct volume_group *vg);
366 int vgs_are_compatible(struct cmd_context *cmd,
367 struct volume_group *vg_from,
368 struct volume_group *vg_to);
369 uint32_t vg_lock_newname(struct cmd_context *cmd, const char *vgname);
372 * Return a handle to VG metadata.
374 struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name,
375 const char *vgid, uint32_t flags);
376 struct volume_group *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
377 const char *vgid, uint32_t flags);
380 * Test validity of a VG handle.
382 uint32_t vg_read_error(struct volume_group *vg_handle);
384 /* pe_start and pe_end relate to any existing data so that new metadata
385 * areas can avoid overlap */
386 struct physical_volume *pv_create(const struct cmd_context *cmd,
390 unsigned long data_alignment,
391 unsigned long data_alignment_offset,
393 uint32_t existing_extent_count,
394 uint32_t existing_extent_size,
395 int pvmetadatacopies, uint64_t pvmetadatasize,
396 unsigned metadataignore,
397 struct dm_list *mdas);
398 int pv_resize(struct physical_volume *pv, struct volume_group *vg,
399 uint32_t new_pe_count);
400 int pv_analyze(struct cmd_context *cmd, const char *pv_name,
401 uint64_t label_sector);
403 /* FIXME: move internal to library */
404 uint32_t pv_list_extents_free(const struct dm_list *pvh);
406 struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name);
407 int vg_remove_mdas(struct volume_group *vg);
408 int vg_remove_check(struct volume_group *vg);
409 void vg_remove_pvs(struct volume_group *vg);
410 int vg_remove(struct volume_group *vg);
411 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
412 const char *new_name);
413 int vg_extend(struct volume_group *vg, int pv_count, char **pv_names,
414 struct pvcreate_params *pp);
415 int vg_reduce(struct volume_group *vg, char *pv_name);
416 int vg_change_tag(struct volume_group *vg, const char *tag, int add_tag);
417 int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
418 struct volume_group *vg_to);
419 /* FIXME: Investigate refactoring these functions to take a pv ISO pv_list */
420 void add_pvl_to_vgs(struct volume_group *vg, struct pv_list *pvl);
421 void del_pvl_from_vgs(struct volume_group *vg, struct pv_list *pvl);
423 /* FIXME: refactor / unexport when lvremove liblvm refactoring dones */
424 int remove_lvs_in_vg(struct cmd_context *cmd,
425 struct volume_group *vg,
428 * free_vg() must be called on every struct volume_group allocated
429 * by vg_create() or vg_read_internal() to free it when no longer required.
431 void free_vg(struct volume_group *vg);
434 struct logical_volume *lv_create_empty(const char *name,
437 alloc_policy_t alloc,
438 struct volume_group *vg);
440 /* Write out LV contents */
441 int set_lv(struct cmd_context *cmd, struct logical_volume *lv,
442 uint64_t sectors, int value);
444 int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag);
446 /* Reduce the size of an LV by extents */
447 int lv_reduce(struct logical_volume *lv, uint32_t extents);
449 /* Empty an LV prior to deleting it */
450 int lv_empty(struct logical_volume *lv);
452 /* Empty an LV and add error segment */
453 int replace_lv_with_error_segment(struct logical_volume *lv);
455 /* Entry point for all LV extent allocations */
456 int lv_extend(struct logical_volume *lv,
457 const struct segment_type *segtype,
458 uint32_t stripes, uint32_t stripe_size,
459 uint32_t mirrors, uint32_t extents,
460 struct physical_volume *mirrored_pv, uint32_t mirrored_pe,
461 uint64_t status, struct dm_list *allocatable_pvs,
462 alloc_policy_t alloc);
464 /* lv must be part of lv->vg->lvs */
465 int lv_remove(struct logical_volume *lv);
467 int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
470 int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *lv,
471 force_t force, unsigned level);
473 int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
474 const char *new_name);
476 uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
477 uint32_t extent_size);
479 /* FIXME: refactor and reduce the size of this struct! */
480 struct lvcreate_params {
482 int snapshot; /* snap */
486 int log_count; /* mirror */
487 int nosync; /* mirror */
488 int activation_monitoring; /* all */
490 char *origin; /* snap */
491 const char *vg_name; /* all */
492 const char *lv_name; /* all */
494 uint32_t stripes; /* striped */
495 uint32_t stripe_size; /* striped */
496 uint32_t chunk_size; /* snapshot */
497 uint32_t region_size; /* mirror */
499 uint32_t mirrors; /* mirror */
501 const struct segment_type *segtype; /* all */
504 uint32_t extents; /* all */
505 uint32_t voriginextents; /* snapshot */
506 uint64_t voriginsize; /* snapshot */
507 struct dm_list *pvh; /* all */
509 uint32_t permission; /* all */
510 uint32_t read_ahead; /* all */
511 alloc_policy_t alloc; /* all */
513 struct dm_list tags; /* all */
516 int lv_create_single(struct volume_group *vg,
517 struct lvcreate_params *lp);
520 * Functions for layer manipulation
522 int insert_layer_for_segments_on_pv(struct cmd_context *cmd,
523 struct logical_volume *lv_where,
524 struct logical_volume *layer_lv,
527 struct dm_list *lvs_changed);
528 int remove_layers_for_segments(struct cmd_context *cmd,
529 struct logical_volume *lv,
530 struct logical_volume *layer_lv,
531 uint64_t status_mask, struct dm_list *lvs_changed);
532 int remove_layers_for_segments_all(struct cmd_context *cmd,
533 struct logical_volume *layer_lv,
534 uint64_t status_mask,
535 struct dm_list *lvs_changed);
536 int split_parent_segments_for_layer(struct cmd_context *cmd,
537 struct logical_volume *layer_lv);
538 int remove_layer_from_lv(struct logical_volume *lv,
539 struct logical_volume *layer_lv);
540 struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
541 struct logical_volume *lv_where,
543 const char *layer_suffix);
545 /* Find a PV within a given VG */
546 struct pv_list *find_pv_in_vg(const struct volume_group *vg,
547 const char *pv_name);
548 struct pv_list *find_pv_in_vg_by_uuid(const struct volume_group *vg,
549 const struct id *id);
551 /* Find an LV within a given VG */
552 struct lv_list *find_lv_in_vg(const struct volume_group *vg,
553 const char *lv_name);
555 /* FIXME Merge these functions with ones above */
556 struct logical_volume *find_lv(const struct volume_group *vg,
557 const char *lv_name);
558 struct physical_volume *find_pv_by_name(struct cmd_context *cmd,
559 const char *pv_name);
561 const char *find_vgname_from_pvname(struct cmd_context *cmd,
563 const char *find_vgname_from_pvid(struct cmd_context *cmd,
565 /* Find LV segment containing given LE */
566 struct lv_segment *first_seg(const struct logical_volume *lv);
570 * Useful functions for managing snapshots.
572 int lv_is_origin(const struct logical_volume *lv);
573 int lv_is_virtual_origin(const struct logical_volume *lv);
574 int lv_is_cow(const struct logical_volume *lv);
575 int lv_is_merging_origin(const struct logical_volume *origin);
576 int lv_is_merging_cow(const struct logical_volume *snapshot);
578 /* Test if given LV is visible from user's perspective */
579 int lv_is_visible(const struct logical_volume *lv);
581 int pv_is_in_vg(struct volume_group *vg, struct physical_volume *pv);
583 struct lv_segment *find_merging_cow(const struct logical_volume *origin);
585 /* Given a cow LV, return return the snapshot lv_segment that uses it */
586 struct lv_segment *find_cow(const struct logical_volume *lv);
588 /* Given a cow LV, return its origin */
589 struct logical_volume *origin_from_cow(const struct logical_volume *lv);
591 void init_snapshot_seg(struct lv_segment *seg, struct logical_volume *origin,
592 struct logical_volume *cow, uint32_t chunk_size, int merge);
594 void init_snapshot_merge(struct lv_segment *cow_seg, struct logical_volume *origin);
596 void clear_snapshot_merge(struct logical_volume *origin);
598 int vg_add_snapshot(struct logical_volume *origin, struct logical_volume *cow,
599 union lvid *lvid, uint32_t extent_count,
600 uint32_t chunk_size);
602 int vg_remove_snapshot(struct logical_volume *cow);
604 int vg_check_status(const struct volume_group *vg, uint64_t status);
608 * Check if the VG reached maximal LVs count (if set)
610 int vg_max_lv_reached(struct volume_group *vg);
613 * Mirroring functions
615 struct lv_segment *find_mirror_seg(struct lv_segment *seg);
616 int lv_add_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
617 uint32_t mirrors, uint32_t stripes, uint32_t stripe_size,
618 uint32_t region_size, uint32_t log_count,
619 struct dm_list *pvs, alloc_policy_t alloc, uint32_t flags);
620 int lv_split_mirror_images(struct logical_volume *lv, const char *split_lv_name,
621 uint32_t split_count, struct dm_list *removable_pvs);
622 int lv_remove_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
623 uint32_t mirrors, uint32_t log_count,
624 int (*is_removable)(struct logical_volume *, void *),
625 void *removable_baton, uint64_t status_mask);
627 int is_temporary_mirror_layer(const struct logical_volume *lv);
628 struct logical_volume * find_temporary_mirror(const struct logical_volume *lv);
629 int lv_is_mirrored(const struct logical_volume *lv);
630 uint32_t lv_mirror_count(const struct logical_volume *lv);
631 uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
632 uint32_t region_size);
633 int remove_mirrors_from_segments(struct logical_volume *lv,
634 uint32_t new_mirrors, uint64_t status_mask);
635 int add_mirrors_to_segments(struct cmd_context *cmd, struct logical_volume *lv,
636 uint32_t mirrors, uint32_t region_size,
637 struct dm_list *allocatable_pvs, alloc_policy_t alloc);
639 int remove_mirror_images(struct logical_volume *lv, uint32_t num_mirrors,
640 int (*is_removable)(struct logical_volume *, void *),
641 void *removable_baton, unsigned remove_log);
642 int add_mirror_images(struct cmd_context *cmd, struct logical_volume *lv,
643 uint32_t mirrors, uint32_t stripes, uint32_t stripe_size, uint32_t region_size,
644 struct dm_list *allocatable_pvs, alloc_policy_t alloc,
646 struct logical_volume *detach_mirror_log(struct lv_segment *seg);
647 int attach_mirror_log(struct lv_segment *seg, struct logical_volume *lv);
648 int remove_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,
649 struct dm_list *removable_pvs, int force);
650 int add_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,
651 uint32_t log_count, uint32_t region_size,
652 struct dm_list *allocatable_pvs, alloc_policy_t alloc);
654 int reconfigure_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
655 struct dm_list *removable_pvs, unsigned remove_log);
656 int collapse_mirrored_lv(struct logical_volume *lv);
657 int shift_mirror_images(struct lv_segment *mirrored_seg, unsigned mimage);
659 /* ++ metadata/replicator_manip.c */
660 int replicator_add_replicator_dev(struct logical_volume *replicator_lv,
661 struct lv_segment *rdev_seg);
662 struct logical_volume *replicator_remove_replicator_dev(struct lv_segment *rdev_seg);
663 int replicator_add_rlog(struct lv_segment *replicator_seg, struct logical_volume *rlog_lv);
664 struct logical_volume *replicator_remove_rlog(struct lv_segment *replicator_seg);
666 int replicator_dev_add_slog(struct replicator_device *rdev, struct logical_volume *slog_lv);
667 struct logical_volume *replicator_dev_remove_slog(struct replicator_device *rdev);
668 int replicator_dev_add_rimage(struct replicator_device *rdev, struct logical_volume *lv);
669 struct logical_volume *replicator_dev_remove_rimage(struct replicator_device *rdev);
671 int lv_is_active_replicator_dev(const struct logical_volume *lv);
672 int lv_is_replicator(const struct logical_volume *lv);
673 int lv_is_replicator_dev(const struct logical_volume *lv);
674 int lv_is_rimage(const struct logical_volume *lv);
675 int lv_is_rlog(const struct logical_volume *lv);
676 int lv_is_slog(const struct logical_volume *lv);
677 struct logical_volume *first_replicator_dev(const struct logical_volume *lv);
678 /* -- metadata/replicator_manip.c */
679 struct cmd_vg *cmd_vg_add(struct dm_pool *mem, struct dm_list *cmd_vgs,
680 const char *vg_name, const char *vgid,
682 struct cmd_vg *cmd_vg_lookup(struct dm_list *cmd_vgs,
683 const char *vg_name, const char *vgid);
684 int cmd_vg_read(struct cmd_context *cmd, struct dm_list *cmd_vgs);
685 void free_cmd_vgs(struct dm_list *cmd_vgs);
687 int find_replicator_vgs(struct logical_volume *lv);
689 int lv_read_replicator_vgs(struct logical_volume *lv);
690 void lv_release_replicator_vgs(struct logical_volume *lv);
692 struct logical_volume *find_pvmove_lv(struct volume_group *vg,
693 struct device *dev, uint32_t lv_type);
694 struct logical_volume *find_pvmove_lv_from_pvname(struct cmd_context *cmd,
695 struct volume_group *vg,
699 const char *get_pvmove_pvname_from_lv(struct logical_volume *lv);
700 const char *get_pvmove_pvname_from_lv_mirr(struct logical_volume *lv_mirr);
701 percent_t copy_percent(struct logical_volume *lv_mirr);
702 struct dm_list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg,
703 struct logical_volume *lv);
705 uint32_t find_free_lvnum(struct logical_volume *lv);
706 char *generate_lv_name(struct volume_group *vg, const char *format,
707 char *buffer, size_t len);
710 * Begin skeleton for external LVM library
712 int pv_change_metadataignore(struct physical_volume *pv, uint32_t mda_ignore);
715 int vg_check_write_mode(struct volume_group *vg);
716 #define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED)
717 #define vg_is_exported(vg) (vg_status((vg)) & EXPORTED_VG)
718 #define vg_is_resizeable(vg) (vg_status((vg)) & RESIZEABLE_VG)
720 int lv_has_unknown_segments(const struct logical_volume *lv);
721 int vg_has_unknown_segments(const struct volume_group *vg);
723 struct vgcreate_params {
725 uint32_t extent_size;
728 alloc_policy_t alloc;
729 int clustered; /* FIXME: put this into a 'status' variable instead? */
730 uint32_t vgmetadatacopies;
733 int vgcreate_params_validate(struct cmd_context *cmd,
734 struct vgcreate_params *vp);
736 int validate_vg_rename_params(struct cmd_context *cmd,
737 const char *vg_name_old,
738 const char *vg_name_new);