/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the representation of LVM metadata that is being adapted
* for library export.
*/
/* May any free extents on this PV be used or must they be left free? */
#define ALLOCATABLE_PV 0x00000008U /* PV */
//#define SPINDOWN_LV 0x00000010U /* LV */
//#define BADBLOCK_ON 0x00000020U /* LV */
#define VISIBLE_LV 0x00000040U /* LV */
#define FIXED_MINOR 0x00000080U /* LV */
/* FIXME Remove when metadata restructuring is completed */
#define SNAPSHOT 0x00001000U /* LV - internal use only */
#define PVMOVE 0x00002000U /* VG LV SEG */
#define LOCKED 0x00004000U /* LV */
#define MIRRORED 0x00008000U /* LV - internal use only */
//#define VIRTUAL 0x00010000U /* LV - internal use only */
#define MIRROR_LOG 0x00020000U /* LV */
#define MIRROR_IMAGE 0x00040000U /* LV */
#define MIRROR_NOTSYNCED 0x00080000U /* LV */
//#define ACTIVATE_EXCL 0x00100000U /* LV - internal use only */
//#define PRECOMMITTED 0x00200000U /* VG - internal use only */
#define CONVERTING 0x00400000U /* LV */
#define MISSING_PV 0x00800000U /* PV */
#define PARTIAL_LV 0x01000000U /* LV - derived flag, not
written out in metadata*/
//#define POSTORDER_FLAG 0x02000000U /* Not real flags, reserved for
//#define POSTORDER_OPEN_FLAG 0x04000000U temporary use inside vg_read_internal. */
//#define VIRTUAL_ORIGIN 0x08000000U /* LV - internal use only */
/*
* logical volumes
* The following relationship should always hold:
* dm_list_size(lvs) = user visible lv_count + snapshot_count + other invisible LVs
*
* Snapshots consist of 2 instances of "struct logical_volume":
* - cow (lv_name is visible to the user)
* - snapshot (lv_name is 'snapshotN')
*
* Mirrors consist of multiple instances of "struct logical_volume":
* - one for the mirror log
* - one for each mirror leg
* - one for the user-visible mirror LV
*/
struct dm_list lvs;
struct dm_list tags;
/*
* FIXME: Move the next fields into a different struct?
*/
/*
* List of removed physical volumes by pvreduce.
* They have to get cleared on vg_commit.
*/
struct dm_list removed_pvs;
uint32_t open_mode; /* FIXME: read or write - check lock type? */
/*
* Store result of the last vg_read().
* 0 for success else appropriate FAILURE_* bits set.
*/
uint32_t read_status;
};
/* There will be one area for each stripe */
struct lv_segment_area {
area_type_t type;
union {
struct {
struct pv_segment *pvseg;
} pv;
struct {
struct logical_volume *lv;
uint32_t le;
} lv;
} u;
};
/*
* Utility functions
*/
int vg_write(struct volume_group *vg);
int vg_commit(struct volume_group *vg);
int vg_revert(struct volume_group *vg);
struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name,
const char *vgid, int *consistent);
struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
struct dm_list *mdas, uint64_t *label_sector,
int warnings, int scan_label_only);
struct dm_list *get_pvs(struct cmd_context *cmd);
/*
* Add/remove LV to/from volume group
*/
int link_lv_to_vg(struct volume_group *vg, struct logical_volume *lv);
int unlink_lv_from_vg(struct logical_volume *lv);
void lv_set_visible(struct logical_volume *lv);
void lv_set_hidden(struct logical_volume *lv);
/* Set full_scan to 1 to re-read every (filtered) device label */
struct dm_list *get_vgnames(struct cmd_context *cmd, int full_scan);
struct dm_list *get_vgids(struct cmd_context *cmd, int full_scan);
int scan_vgs_for_pvs(struct cmd_context *cmd);
int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
struct dm_list *mdas, int64_t label_sector);
int is_pv(struct physical_volume *pv);
int move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
const char *pv_name);
int move_pvs_used_by_lv(struct volume_group *vg_from,
struct volume_group *vg_to,
const char *lv_name);
int is_orphan_vg(const char *vg_name);
int is_orphan(const struct physical_volume *pv);
int vgs_are_compatible(struct cmd_context *cmd,
struct volume_group *vg_from,
struct volume_group *vg_to);
uint32_t vg_lock_newname(struct cmd_context *cmd, const char *vgname);
/*
* Test validity of a VG handle.
*/
uint32_t vg_read_error(struct volume_group *vg_handle);
/* pe_start and pe_end relate to any existing data so that new metadata
* areas can avoid overlap */
struct physical_volume *pv_create(const struct cmd_context *cmd,
struct device *dev,
struct id *id,
uint64_t size,
unsigned long data_alignment,
unsigned long data_alignment_offset,
uint64_t pe_start,
uint32_t existing_extent_count,
uint32_t existing_extent_size,
int pvmetadatacopies,
uint64_t pvmetadatasize, struct dm_list *mdas);
int pv_resize(struct physical_volume *pv, struct volume_group *vg,
uint32_t new_pe_count);
int pv_analyze(struct cmd_context *cmd, const char *pv_name,
uint64_t label_sector);
struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name);
int vg_remove_mdas(struct volume_group *vg);
int vg_remove_check(struct volume_group *vg);
int vg_remove(struct volume_group *vg);
int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
const char *new_name);
int vg_extend(struct volume_group *vg, int pv_count, char **pv_names,
struct pvcreate_params *pp);
int vg_reduce(struct volume_group *vg, char *pv_name);
int vg_set_extent_size(struct volume_group *vg, uint32_t new_extent_size);
int vg_set_max_lv(struct volume_group *vg, uint32_t max_lv);
int vg_set_max_pv(struct volume_group *vg, uint32_t max_pv);
int vg_set_alloc_policy(struct volume_group *vg, alloc_policy_t alloc);
int vg_set_clustered(struct volume_group *vg, int clustered);
int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
struct volume_group *vg_to);
/* FIXME: refactor / unexport when lvremove liblvm refactoring dones */
int remove_lvs_in_vg(struct cmd_context *cmd,
struct volume_group *vg,
force_t force);
/*
* vg_release() must be called on every struct volume_group allocated
* by vg_create() or vg_read_internal() to free it when no longer required.
*/
void vg_release(struct volume_group *vg);
/* FIXME: refactor and reduce the size of this struct! */
struct lvcreate_params {
/* flags */
int snapshot; /* snap */
int zero; /* all */
int major; /* all */
int minor; /* all */
int corelog; /* mirror */
int nosync; /* mirror */
char *origin; /* snap */
const char *vg_name; /* all */
const char *lv_name; /* all */