mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Add CORRECT_INCONSISTENT and FAIL_INCONSISTENT flags to vg_lock_and_read
This commit is contained in:
parent
891c3d298b
commit
4f629c3bba
@ -83,6 +83,10 @@ struct pv_segment;
|
||||
#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,
|
||||
@ -293,7 +297,8 @@ int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
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 */
|
||||
|
@ -1798,23 +1798,29 @@ int vg_check_status(struct volume_group *vg, uint32_t status)
|
||||
* @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;
|
||||
|
@ -55,7 +55,8 @@ static struct volume_group *_get_vg(struct cmd_context *cmd, const char *vgname)
|
||||
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;
|
||||
|
@ -49,7 +49,8 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
|
||||
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;
|
||||
}
|
||||
|
@ -30,13 +30,15 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -242,7 +242,8 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user