#define _LVM_METADATA_EXPORTED_H
#include "uuid.h"
-#include "lvm.h"
#define MAX_STRIPES 128U
#define SECTOR_SHIFT 9L
struct dm_list tags;
/*
- * vg_t handle fields.
- * FIXME: Split these out.
+ * FIXME: Move the next fields into a different struct?
*/
/*
unsigned yes;
};
-pv_t * pvcreate_single(struct cmd_context *cmd, const char *pv_name,
- struct pvcreate_params *pp);
+struct physical_volume *pvcreate_single(struct cmd_context *cmd,
+ const char *pv_name,
+ struct pvcreate_params *pp);
/*
* Utility functions
int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
struct dm_list *mdas, int64_t label_sector);
-int is_pv(pv_t *pv);
+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 pv_t *pv);
+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);
/*
* Return a handle to VG metadata.
*/
-vg_t *vg_read(struct cmd_context *cmd, const char *vg_name,
+struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name,
const char *vgid, uint32_t flags);
-vg_t *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
+struct volume_group *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
const char *vgid, uint32_t flags);
/*
* Test validity of a VG handle.
*/
-uint32_t vg_read_error(vg_t *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 */
-pv_t *pv_create(const struct cmd_context *cmd,
+struct physical_volume *pv_create(const struct cmd_context *cmd,
struct device *dev,
struct id *id,
uint64_t size,
/* FIXME: move internal to library */
uint32_t pv_list_extents_free(const struct dm_list *pvh);
-vg_t *vg_create(struct cmd_context *cmd, const char *vg_name);
+struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name);
int vg_remove(struct volume_group *vg);
-int vg_remove_single(vg_t *vg);
+int vg_remove_single(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);
int vg_reduce(struct volume_group *vg, char *pv_name);
-int vg_set_extent_size(vg_t *vg, uint32_t new_extent_size);
-int vg_set_max_lv(vg_t *vg, uint32_t max_lv);
-int vg_set_max_pv(vg_t *vg, uint32_t max_pv);
-int vg_set_alloc_policy(vg_t *vg, alloc_policy_t alloc);
+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_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
struct volume_group *vg_to);
/* Find a PV within a given VG */
struct pv_list *find_pv_in_vg(const struct volume_group *vg,
const char *pv_name);
-pv_t *find_pv_in_vg_by_uuid(const struct volume_group *vg,
+struct physical_volume *find_pv_in_vg_by_uuid(const struct volume_group *vg,
const struct id *id);
/* Find an LV within a given VG */
/*
* Begin skeleton for external LVM library
*/
-struct device *pv_dev(const pv_t *pv);
-const char *pv_vg_name(const pv_t *pv);
-const char *pv_dev_name(const pv_t *pv);
-uint64_t pv_size(const pv_t *pv);
-uint32_t pv_status(const pv_t *pv);
-uint32_t pv_pe_size(const pv_t *pv);
-uint64_t pv_pe_start(const pv_t *pv);
-uint32_t pv_pe_count(const pv_t *pv);
-uint32_t pv_pe_alloc_count(const pv_t *pv);
-uint32_t pv_mda_count(const pv_t *pv);
-
-uint64_t lv_size(const lv_t *lv);
-
-int vg_missing_pv_count(const vg_t *vg);
-uint32_t vg_seqno(const vg_t *vg);
-uint32_t vg_status(const vg_t *vg);
-uint64_t vg_size(const vg_t *vg);
-uint64_t vg_free(const vg_t *vg);
-uint64_t vg_extent_size(const vg_t *vg);
-uint64_t vg_extent_count(const vg_t *vg);
-uint64_t vg_free_count(const vg_t *vg);
-uint64_t vg_pv_count(const vg_t *vg);
-int vg_check_write_mode(vg_t *vg);
+struct device *pv_dev(const struct physical_volume *pv);
+const char *pv_vg_name(const struct physical_volume *pv);
+const char *pv_dev_name(const struct physical_volume *pv);
+uint64_t pv_size(const struct physical_volume *pv);
+uint32_t pv_status(const struct physical_volume *pv);
+uint32_t pv_pe_size(const struct physical_volume *pv);
+uint64_t pv_pe_start(const struct physical_volume *pv);
+uint32_t pv_pe_count(const struct physical_volume *pv);
+uint32_t pv_pe_alloc_count(const struct physical_volume *pv);
+uint32_t pv_mda_count(const struct physical_volume *pv);
+
+uint64_t lv_size(const struct logical_volume *lv);
+
+int vg_missing_pv_count(const struct volume_group *vg);
+uint32_t vg_seqno(const struct volume_group *vg);
+uint32_t vg_status(const struct volume_group *vg);
+uint64_t vg_size(const struct volume_group *vg);
+uint64_t vg_free(const struct volume_group *vg);
+uint64_t vg_extent_size(const struct volume_group *vg);
+uint64_t vg_extent_count(const struct volume_group *vg);
+uint64_t vg_free_count(const struct volume_group *vg);
+uint64_t vg_pv_count(const struct volume_group *vg);
+int vg_check_write_mode(struct volume_group *vg);
#define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED)
struct vgcreate_params {
static struct physical_volume *_find_pv_in_vg_by_uuid(const struct volume_group *vg,
const struct id *id);
-static vg_t *_vg_make_handle(struct cmd_context *cmd,
- struct volume_group *vg,
- uint32_t failure);
static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
uint32_t status);
return 1;
}
-int vg_remove_single(vg_t *vg)
+int vg_remove_single(struct volume_group *vg)
{
struct physical_volume *pv;
struct pv_list *pvl;
return 0;
}
+/*
+ * Create a (struct volume_group) volume group handle from a struct volume_group pointer and a
+ * possible failure code or zero for success.
+ */
+static struct volume_group *_vg_make_handle(struct cmd_context *cmd,
+ struct volume_group *vg,
+ uint32_t failure)
+{
+ struct dm_pool *vgmem;
+
+ if (!vg) {
+ if (!(vgmem = dm_pool_create("lvm2 vg_handle", VG_MEMPOOL_CHUNK)) ||
+ !(vg = dm_pool_zalloc(vgmem, sizeof(*vg)))) {
+ log_error("Error allocating vg handle.");
+ if (vgmem)
+ dm_pool_destroy(vgmem);
+ return_NULL;
+ }
+ vg->vgmem = vgmem;
+ }
+
+ vg->read_status = failure;
+
+ return (struct volume_group *)vg;
+}
+
/*
* Create a VG with default parameters.
* Returns:
- * - vg_t* with SUCCESS code: VG structure created
- * - NULL or vg_t* with FAILED_* code: error creating VG structure
+ * - struct volume_group* with SUCCESS code: VG structure created
+ * - NULL or struct volume_group* with FAILED_* code: error creating VG structure
* Use vg_read_error() to determine success or failure.
* FIXME: cleanup usage of _vg_make_handle()
*/
-vg_t *vg_create(struct cmd_context *cmd, const char *vg_name)
+struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name)
{
- vg_t *vg;
+ struct volume_group *vg;
int consistent = 0;
struct dm_pool *mem;
uint32_t rc;
return 1;
}
-int vg_set_extent_size(vg_t *vg, uint32_t new_size)
+int vg_set_extent_size(struct volume_group *vg, uint32_t new_size)
{
uint32_t old_size = vg->extent_size;
struct pv_list *pvl;
return 1;
}
-int vg_set_max_lv(vg_t *vg, uint32_t max_lv)
+int vg_set_max_lv(struct volume_group *vg, uint32_t max_lv)
{
if (!(vg_status(vg) & RESIZEABLE_VG)) {
log_error("Volume group \"%s\" must be resizeable "
return 1;
}
-int vg_set_max_pv(vg_t *vg, uint32_t max_pv)
+int vg_set_max_pv(struct volume_group *vg, uint32_t max_pv)
{
if (!(vg_status(vg) & RESIZEABLE_VG)) {
log_error("Volume group \"%s\" must be resizeable "
return 1;
}
-int vg_set_alloc_policy(vg_t *vg, alloc_policy_t alloc)
+int vg_set_alloc_policy(struct volume_group *vg, alloc_policy_t alloc)
{
if (alloc == ALLOC_INHERIT) {
log_error("Volume Group allocation policy cannot inherit "
*
* Returns:
* NULL: error
- * pv_t * (non-NULL): handle to physical volume created
+ * struct physical_volume * (non-NULL): handle to physical volume created
*/
-pv_t * pvcreate_single(struct cmd_context *cmd, const char *pv_name,
+struct physical_volume * pvcreate_single(struct cmd_context *cmd, const char *pv_name,
struct pvcreate_params *pp)
{
void *pv;
* Note
* FIXME - liblvm todo - make into function that takes VG handle
*/
-pv_t *find_pv_in_vg_by_uuid(const struct volume_group *vg,
+struct physical_volume *find_pv_in_vg_by_uuid(const struct volume_group *vg,
const struct id *id)
{
return _find_pv_in_vg_by_uuid(vg, id);
return 1;
}
-int vg_missing_pv_count(const vg_t *vg)
+int vg_missing_pv_count(const struct volume_group *vg)
{
int ret = 0;
struct pv_list *pvl;
* is_orphan - Determine whether a pv is an orphan based on its vg_name
* @pv: handle to the physical volume
*/
-int is_orphan(const pv_t *pv)
+int is_orphan(const struct physical_volume *pv)
{
return is_orphan_vg(pv_field(pv, vg_name));
}
* is_pv - Determine whether a pv is a real pv or dummy one
* @pv: handle to device
*/
-int is_pv(pv_t *pv)
+int is_pv(struct physical_volume *pv)
{
return (pv_field(pv, vg_name) ? 1 : 0);
}
}
/* FIXME: remove / combine this with locking? */
-int vg_check_write_mode(vg_t *vg)
+int vg_check_write_mode(struct volume_group *vg)
{
if (vg->open_mode != 'w') {
log_errno(EPERM, "Attempt to modify a read-only VG");
return !_vg_bad_status_bits(vg, status);
}
-/*
- * Create a (vg_t) volume group handle from a struct volume_group pointer and a
- * possible failure code or zero for success.
- */
-static vg_t *_vg_make_handle(struct cmd_context *cmd,
- struct volume_group *vg,
- uint32_t failure)
-{
- struct dm_pool *vgmem;
-
- if (!vg) {
- if (!(vgmem = dm_pool_create("lvm2 vg_handle", VG_MEMPOOL_CHUNK)) ||
- !(vg = dm_pool_zalloc(vgmem, sizeof(*vg)))) {
- log_error("Error allocating vg handle.");
- if (vgmem)
- dm_pool_destroy(vgmem);
- return_NULL;
- }
- vg->vgmem = vgmem;
- }
-
- vg->read_status = failure;
-
- return (vg_t *)vg;
-}
-
-static vg_t *_recover_vg(struct cmd_context *cmd, const char *lock_name,
+static struct volume_group *_recover_vg(struct cmd_context *cmd, const char *lock_name,
const char *vg_name, const char *vgid,
uint32_t lock_flags)
{
return_NULL;
}
- return (vg_t *)vg;
+ return (struct volume_group *)vg;
}
/*
* problems reading the volume group.
* Zero value means that the VG is open and appropriate locks are held.
*/
-static vg_t *_vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
+static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
const char *vgid, uint32_t lock_flags,
uint32_t status_flags, uint32_t misc_flags)
{
* toollib just set lock_flags to LCK_VG_WRITE and called vg_read_internal with
* *consistent = 1.
*/
-vg_t *vg_read(struct cmd_context *cmd, const char *vg_name,
+struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name,
const char *vgid, uint32_t flags)
{
uint32_t status = 0;
* later update (this means the user code can change the metadata and later
* request the new metadata to be written and committed).
*/
-vg_t *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
+struct volume_group *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
const char *vgid, uint32_t flags)
{
return vg_read(cmd, vg_name, vgid, flags | READ_FOR_UPDATE);
/*
* Test the validity of a VG handle returned by vg_read() or vg_read_for_update().
*/
-uint32_t vg_read_error(vg_t *vg_handle)
+uint32_t vg_read_error(struct volume_group *vg_handle)
{
if (!vg_handle)
return FAILED_ALLOCATION;
/*
* Gets/Sets for external LVM library
*/
-struct id pv_id(const pv_t *pv)
+struct id pv_id(const struct physical_volume *pv)
{
return pv_field(pv, id);
}
-const struct format_type *pv_format_type(const pv_t *pv)
+const struct format_type *pv_format_type(const struct physical_volume *pv)
{
return pv_field(pv, fmt);
}
-struct id pv_vgid(const pv_t *pv)
+struct id pv_vgid(const struct physical_volume *pv)
{
return pv_field(pv, vgid);
}
-struct device *pv_dev(const pv_t *pv)
+struct device *pv_dev(const struct physical_volume *pv)
{
return pv_field(pv, dev);
}
-const char *pv_vg_name(const pv_t *pv)
+const char *pv_vg_name(const struct physical_volume *pv)
{
return pv_field(pv, vg_name);
}
-const char *pv_dev_name(const pv_t *pv)
+const char *pv_dev_name(const struct physical_volume *pv)
{
return dev_name(pv_dev(pv));
}
-uint64_t pv_size(const pv_t *pv)
+uint64_t pv_size(const struct physical_volume *pv)
{
return pv_field(pv, size);
}
-uint32_t pv_status(const pv_t *pv)
+uint32_t pv_status(const struct physical_volume *pv)
{
return pv_field(pv, status);
}
-uint32_t pv_pe_size(const pv_t *pv)
+uint32_t pv_pe_size(const struct physical_volume *pv)
{
return pv_field(pv, pe_size);
}
-uint64_t pv_pe_start(const pv_t *pv)
+uint64_t pv_pe_start(const struct physical_volume *pv)
{
return pv_field(pv, pe_start);
}
-uint32_t pv_pe_count(const pv_t *pv)
+uint32_t pv_pe_count(const struct physical_volume *pv)
{
return pv_field(pv, pe_count);
}
-uint32_t pv_pe_alloc_count(const pv_t *pv)
+uint32_t pv_pe_alloc_count(const struct physical_volume *pv)
{
return pv_field(pv, pe_alloc_count);
}
-uint32_t pv_mda_count(const pv_t *pv)
+uint32_t pv_mda_count(const struct physical_volume *pv)
{
struct lvmcache_info *info;
return info ? dm_list_size(&info->mdas) : UINT64_C(0);
}
-uint32_t vg_seqno(const vg_t *vg)
+uint32_t vg_seqno(const struct volume_group *vg)
{
return vg->seqno;
}
-uint32_t vg_status(const vg_t *vg)
+uint32_t vg_status(const struct volume_group *vg)
{
return vg->status;
}
-uint64_t vg_size(const vg_t *vg)
+uint64_t vg_size(const struct volume_group *vg)
{
return (uint64_t) vg->extent_count * vg->extent_size;
}
-uint64_t vg_free(const vg_t *vg)
+uint64_t vg_free(const struct volume_group *vg)
{
return (uint64_t) vg->free_count * vg->extent_size;
}
-uint64_t vg_extent_size(const vg_t *vg)
+uint64_t vg_extent_size(const struct volume_group *vg)
{
return (uint64_t) vg->extent_size;
}
-uint64_t vg_extent_count(const vg_t *vg)
+uint64_t vg_extent_count(const struct volume_group *vg)
{
return (uint64_t) vg->extent_count;
}
-uint64_t vg_free_count(const vg_t *vg)
+uint64_t vg_free_count(const struct volume_group *vg)
{
return (uint64_t) vg->free_count;
}
-uint64_t vg_pv_count(const vg_t *vg)
+uint64_t vg_pv_count(const struct volume_group *vg)
{
return (uint64_t) vg->pv_count;
}
-uint64_t lv_size(const lv_t *lv)
+uint64_t lv_size(const struct logical_volume *lv)
{
return lv->size;
}
*
* FIXME: merge with find_pv_by_name ?
*/
-pv_t *pv_by_path(struct cmd_context *cmd, const char *pv_name)
+struct physical_volume *pv_by_path(struct cmd_context *cmd, const char *pv_name)
{
struct dm_list mdas;