#define FMT_RESIZE_PV 0x00000080U /* Supports pvresize? */
#define FMT_UNLIMITED_STRIPESIZE 0x00000100U /* Unlimited stripe size? */
+/* LVM2 external library flags */
+#define CORRECT_INCONSISTENT 0x00000001U /* Correct inconsistent metadata */
+#define FAIL_INCONSISTENT 0x00000002U /* Fail if metadata inconsistent */
+
/* Ordered list - see lv_manip.c */
typedef enum {
ALLOC_INVALID,
struct list *mdas, int64_t label_sector);
int is_orphan(pv_t *pv);
vg_t *vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
- uint32_t lock_flags, uint32_t status_flags);
+ uint32_t lock_flags, uint32_t status_flags,
+ uint32_t misc_flags);
/* pe_start and pe_end relate to any existing data so that new metadata
* areas can avoid overlap */
* @vg_name - name of the volume group to lock and read
* @lock_flags - locking flags to use
* @status_flags - status flags to check
+ * @misc_flags - function modifier flags
*
* Returns:
* NULL - failure
* non-NULL - success; volume group handle
*/
vg_t *vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
- uint32_t lock_flags, uint32_t status_flags)
+ uint32_t lock_flags, uint32_t status_flags,
+ uint32_t misc_flags)
{
struct volume_group *vg;
int consistent = 1;
-
+
+ if (!(misc_flags & CORRECT_INCONSISTENT))
+ consistent = 0;
+
if (!lock_vol(cmd, vg_name, lock_flags)) {
log_error("Can't get lock for %s", vg_name);
return NULL;
}
- if (!(vg = vg_read(cmd, vg_name, NULL, &consistent)) || !consistent) {
+ if (!(vg = vg_read(cmd, vg_name, NULL, &consistent)) ||
+ ((misc_flags & FAIL_INCONSISTENT) && !consistent)) {
log_error("Volume group \"%s\" not found", vg_name);
unlock_vg(cmd, vg_name);
return NULL;
dev_close_all();
if (!(vg = vg_lock_and_read(cmd, vgname, LCK_VG_WRITE,
- CLUSTERED | EXPORTED_VG | LVM_WRITE)))
+ CLUSTERED | EXPORTED_VG | LVM_WRITE,
+ CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
return NULL;
return vg;
log_verbose("Checking for volume group \"%s\"", vg_name);
if (!(vg = vg_lock_and_read(cmd, vg_name, LCK_VG_WRITE | LCK_NONBLOCK,
CLUSTERED | EXPORTED_VG |
- LVM_WRITE | RESIZEABLE_VG))) {
+ LVM_WRITE | RESIZEABLE_VG,
+ CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) {
unlock_vg(cmd, ORPHAN);
return ECMD_FAILED;
}
log_verbose("Checking for volume group \"%s\"", vg_name_to);
if (!(vg_to = vg_lock_and_read(cmd, vg_name_to, LCK_VG_WRITE,
- CLUSTERED | EXPORTED_VG | LVM_WRITE)))
+ CLUSTERED | EXPORTED_VG | LVM_WRITE,
+ CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
return ECMD_FAILED;
log_verbose("Checking for volume group \"%s\"", vg_name_from);
if (!(vg_from = vg_lock_and_read(cmd, vg_name_from,
LCK_VG_WRITE | LCK_NONBLOCK,
- CLUSTERED | EXPORTED_VG | LVM_WRITE))) {
+ CLUSTERED | EXPORTED_VG | LVM_WRITE,
+ CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) {
unlock_vg(cmd, vg_name_to);
return ECMD_FAILED;
}
log_verbose("Checking for volume group \"%s\"", vg_name_from);
if (!(vg_to = vg_lock_and_read(cmd, vg_name_from, LCK_VG_WRITE,
CLUSTERED | EXPORTED_VG |
- RESIZEABLE_VG | LVM_WRITE)))
+ RESIZEABLE_VG | LVM_WRITE,
+ CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
return ECMD_FAILED;
log_verbose("Checking for volume group \"%s\"", vg_name_to);