1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Merge branch 'master' of git+ssh://sourceware.org/git/lvm2

This commit is contained in:
Joe Thornber 2018-06-01 19:19:11 +01:00
commit 4d19321fd3
19 changed files with 49 additions and 45 deletions

View File

@ -1010,7 +1010,8 @@ static void _filter_duplicate_devs(struct cmd_context *cmd)
dm_list_iterate_items_safe(devl, devl2, &_unused_duplicate_devs) {
info = lvmcache_info_from_pvid(devl->dev->pvid, NULL, 0);
if (!(info = lvmcache_info_from_pvid(devl->dev->pvid, NULL, 0)))
continue;
if (MAJOR(info->dev->dev) == dt->md_major) {
log_debug_devs("Ignoring md component duplicate %s", dev_name(devl->dev));
@ -1038,7 +1039,8 @@ static void _warn_duplicate_devs(struct cmd_context *cmd)
dm_list_iterate_items_safe(devl, devl2, &_unused_duplicate_devs) {
/* info for the preferred device that we're actually using */
info = lvmcache_info_from_pvid(devl->dev->pvid, NULL, 0);
if (!(info = lvmcache_info_from_pvid(devl->dev->pvid, NULL, 0)))
continue;
if (!id_write_format((const struct id *)info->dev->pvid, uuid, sizeof(uuid)))
stack;

6
lib/cache/lvmetad.c vendored
View File

@ -1069,14 +1069,14 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
* host.
*/
if (is_lockd_type(vg->lock_type) && cmd->include_shared_vgs) {
if (vg_is_shared(vg) && cmd->include_shared_vgs) {
log_debug_lvmetad("Rescan VG %s because including shared", vgname);
rescan = 1;
} else if (is_lockd_type(vg->lock_type) && cmd->lockd_vg_rescan) {
} else if (vg_is_shared(vg) && cmd->lockd_vg_rescan) {
log_debug_lvmetad("Rescan VG %s because no lvmlockd lock is held", vgname);
rescan = 1;
} else if (dm_config_find_node(reply.cft->root, "vg_invalid")) {
if (!is_lockd_type(vg->lock_type)) {
if (!vg_is_shared(vg)) {
/* Can happen if a previous command failed/crashed without updating lvmetad. */
log_warn("WARNING: Reading VG %s from disk because lvmetad metadata is invalid.", vgname);
} else {

View File

@ -832,7 +832,7 @@ int label_scan(struct cmd_context *cmd)
while ((dev = dev_iter_get(iter))) {
if (!(devl = dm_zalloc(sizeof(*devl))))
return 0;
continue;
devl->dev = dev;
dm_list_add(&all_devs, &devl->list);

View File

@ -1020,7 +1020,7 @@ int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int start_i
memset(uuid, 0, sizeof(uuid));
if (!is_lockd_type(vg->lock_type))
if (!vg_is_shared(vg))
return 1;
if (!_use_lvmlockd) {
@ -1111,7 +1111,7 @@ int lockd_stop_vg(struct cmd_context *cmd, struct volume_group *vg)
int result;
int ret;
if (!is_lockd_type(vg->lock_type))
if (!vg_is_shared(vg)))
return 1;
if (!_use_lvmlockd)
return 0;
@ -1996,7 +1996,7 @@ int lockd_vg_update(struct volume_group *vg)
int result;
int ret;
if (!is_lockd_type(vg->lock_type))
if (!vg_is_shared(vg))
return 1;
if (!_use_lvmlockd)
return 0;
@ -2253,7 +2253,7 @@ static int _lockd_lv_mirror(struct cmd_context *cmd, struct logical_volume *lv,
int lockd_lv(struct cmd_context *cmd, struct logical_volume *lv,
const char *def_mode, uint32_t flags)
{
if (!is_lockd_type(lv->vg->lock_type))
if (!vg_is_shared(lv->vg))
return 1;
if (!_use_lvmlockd) {
@ -2586,7 +2586,7 @@ int lockd_rename_vg_before(struct cmd_context *cmd, struct volume_group *vg)
int result;
int ret;
if (!is_lockd_type(vg->lock_type))
if (!vg_is_shared(vg))
return 1;
if (!_use_lvmlockd)
return 0;
@ -2650,7 +2650,7 @@ int lockd_rename_vg_final(struct cmd_context *cmd, struct volume_group *vg, int
int result;
int ret;
if (!is_lockd_type(vg->lock_type))
if (!vg_is_shared(vg))
return 1;
if (!_use_lvmlockd)
return 0;

View File

@ -7801,7 +7801,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lv->status |= LV_TEMPORARY;
if (seg_is_cache(lp)) {
if (is_lockd_type(lv->vg->lock_type)) {
if (vg_is_shared(vg)) {
if (is_change_activating(lp->activate)) {
if (!lv_active_change(cmd, lv, CHANGE_AEY, 0)) {
log_error("Aborting. Failed to activate LV %s.",

View File

@ -2576,7 +2576,7 @@ int vg_validate(struct volume_group *vg)
goto out;
}
if (is_lockd_type(vg->lock_type)) {
if (vg_is_shared(vg)) {
if (!vg->lock_args) {
log_error(INTERNAL_ERROR "VG %s with lock_type %s without lock_args",
vg->name, vg->lock_type);
@ -2612,7 +2612,7 @@ int vg_validate(struct volume_group *vg)
}
dm_list_iterate_items(lvl, &vg->lvs) {
if (is_lockd_type(vg->lock_type)) {
if (vg_is_shared(vg)) {
if (lockd_lv_uses_lock(lvl->lv)) {
if (vg->skip_validate_lock_args)
continue;
@ -2929,13 +2929,15 @@ int vg_write(struct volume_group *vg)
struct lv_list *lvl;
int revert = 0, wrote = 0;
dm_list_iterate_items(lvl, &vg->lvs) {
if (lvl->lv->lock_args && !strcmp(lvl->lv->lock_args, "pending")) {
if (!lockd_init_lv_args(vg->cmd, vg, lvl->lv, vg->lock_type, &lvl->lv->lock_args)) {
log_error("Cannot allocate lock for new LV.");
return 0;
if (vg_is_shared(vg)) {
dm_list_iterate_items(lvl, &vg->lvs) {
if (lvl->lv->lock_args && !strcmp(lvl->lv->lock_args, "pending")) {
if (!lockd_init_lv_args(vg->cmd, vg, lvl->lv, vg->lock_type, &lvl->lv->lock_args)) {
log_error("Cannot allocate lock for new LV.");
return 0;
}
lvl->lv->new_lock_args = 1;
}
lvl->lv->new_lock_args = 1;
}
}
@ -3556,7 +3558,7 @@ static int _repair_inconsistent_vg(struct volume_group *vg, uint32_t lockd_state
return 0;
}
if (is_lockd_type(vg->lock_type) && !(lockd_state & LDST_EX)) {
if (vg_is_shared(vg) && !(lockd_state & LDST_EX)) {
log_verbose("Skip metadata repair for shared VG without exclusive lock.");
return 0;
}
@ -3602,7 +3604,7 @@ static int _wipe_outdated_pvs(struct cmd_context *cmd, struct volume_group *vg,
return 0;
}
if (is_lockd_type(vg->lock_type) && !(lockd_state & LDST_EX)) {
if (vg_is_shared(vg) && !(lockd_state & LDST_EX)) {
log_verbose("Skip wiping outdated PVs for shared VG without exclusive lock.");
return 0;
}
@ -3684,7 +3686,7 @@ static int _check_or_repair_pv_ext(struct cmd_context *cmd,
"VG %s but not marked as used.",
pv_dev_name(pvl->pv), vg->name);
*inconsistent_pvs = 1;
} else if (is_lockd_type(vg->lock_type) && !(lockd_state & LDST_EX)) {
} else if (vg_is_shared(vg) && !(lockd_state & LDST_EX)) {
log_warn("Skip repair of PV %s that is in shared "
"VG %s but not marked as used.",
pv_dev_name(pvl->pv), vg->name);
@ -5260,7 +5262,7 @@ static int _access_vg_lock_type(struct cmd_context *cmd, struct volume_group *vg
/*
* Local VG requires no lock from lvmlockd.
*/
if (!is_lockd_type(vg->lock_type))
if (!vg_is_shared(vg))
return 1;
/*

View File

@ -426,7 +426,7 @@ static int _activate_lv_like_model(struct logical_volume *model,
{
/* FIXME: run all cases through lv_active_change when clvm variants are gone. */
if (is_lockd_type(lv->vg->lock_type))
if (vg_is_shared(vg))
return lv_active_change(lv->vg->cmd, lv, CHANGE_AEY, 0);
if (lv_is_active_exclusive(model)) {

View File

@ -3426,7 +3426,7 @@ int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name,
/* FIXME: run all cases through lv_active_change when clvm variants are gone. */
if (is_lockd_type(lvl->lv->vg->lock_type)) {
if (vg_is_shared(lvl->lv->vg)) {
if (!lv_active_change(lv->vg->cmd, lvl->lv, CHANGE_AEY, 0))
return_0;
} else if (!activate_lv_excl_local(cmd, lvl->lv))

View File

@ -709,7 +709,7 @@ char *vg_attr_dup(struct dm_pool *mem, const struct volume_group *vg)
if (vg_is_clustered(vg))
repstr[5] = 'c';
else if (is_lockd_type(vg->lock_type))
else if (vg_is_shared(vg))
repstr[5] = 's';
else
repstr[5] = '-';

View File

@ -1802,7 +1802,7 @@ static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volu
return 0;
}
if (is_lockd_type(vg->lock_type)) {
if (vg_is_shared(vg)) {
/* FIXME: we need to create a lock for the new LV. */
log_error("Unable to split snapshots in VG with lock_type %s.", vg->lock_type);
return 0;
@ -2622,7 +2622,7 @@ static int _lvconvert_to_thin_with_external(struct cmd_context *cmd,
*/
lvc.lv_name = origin_name;
if (is_lockd_type(vg->lock_type)) {
if (vg_is_shared(vg)) {
/*
* FIXME: external origins don't work in lockd VGs.
* Prior to the lvconvert, there's a lock associated with
@ -2936,7 +2936,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
zero_metadata = (to_cachepool) ? arg_int_value(cmd, zero_ARG, 1) : 1;
/* An existing LV needs to have its lock freed once it becomes a data LV. */
if (is_lockd_type(vg->lock_type) && lv->lock_args) {
if (vg_is_shared(vg) && lv->lock_args) {
lockd_data_args = dm_pool_strdup(cmd->mem, lv->lock_args);
lockd_data_name = dm_pool_strdup(cmd->mem, lv->name);
memcpy(&lockd_data_id, &lv->lvid.id[1], sizeof(struct id));
@ -2975,7 +2975,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
}
/* An existing LV needs to have its lock freed once it becomes a meta LV. */
if (is_lockd_type(vg->lock_type) && metadata_lv->lock_args) {
if (vg_is_shared(vg) && metadata_lv->lock_args) {
lockd_meta_args = dm_pool_strdup(cmd->mem, metadata_lv->lock_args);
lockd_meta_name = dm_pool_strdup(cmd->mem, metadata_lv->name);
memcpy(&lockd_meta_id, &metadata_lv->lvid.id[1], sizeof(struct id));
@ -3241,7 +3241,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
* Locks are removed from existing LVs that are being converted to
* data and meta LVs (they are unlocked and deleted below.)
*/
if (is_lockd_type(vg->lock_type)) {
if (vg_is_shared(vg)) {
if (to_cachepool) {
data_lv->lock_args = NULL;
metadata_lv->lock_args = NULL;
@ -3851,7 +3851,7 @@ static int _lvconvert_combine_split_snapshot_single(struct cmd_context *cmd,
{
const char *origin_name = cmd->position_argv[0];
if (is_lockd_type(lv->vg->lock_type)) {
if (vg_is_shared(lv->vg)) {
log_error("Unable to combine split snapshots in VG with lock_type %s", lv->vg->lock_type);
return ECMD_FAILED;
}
@ -4225,7 +4225,7 @@ static int _lvconvert_swap_pool_metadata_single(struct cmd_context *cmd,
struct logical_volume *metadata_lv;
const char *metadata_name;
if (is_lockd_type(lv->vg->lock_type)) {
if (vg_is_shared(lv->vg)) {
/* FIXME: need to swap locks betwen LVs? */
log_error("Unable to swap pool metadata in VG with lock_type %s", lv->vg->lock_type);
goto out;

View File

@ -1231,7 +1231,7 @@ static int _determine_cache_argument(struct volume_group *vg,
display_lvname(lv));
return 1;
} else if (is_lockd_type(vg->lock_type)) {
} else if (vg_is_shared(vg)) {
if (!lv_active_change(cmd, lv, CHANGE_AEY, 0)) {
log_error("Cannot activate cache origin %s.",
display_lvname(lv));
@ -1645,7 +1645,7 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name,
lp->snapshot ? " as snapshot of " : "",
lp->snapshot ? lp->origin_name : "", lp->segtype->name);
if (is_lockd_type(vg->lock_type)) {
if (vg_is_shared(vg)) {
if (cmd->command->command_enum == lvcreate_thin_vol_with_thinpool_or_sparse_snapshot_CMD) {
log_error("Use lvconvert to create thin pools and cache pools in a shared VG.");
goto out;

View File

@ -642,7 +642,7 @@ static int _pvmove_setup_single(struct cmd_context *cmd,
* other hosts. For LVs that are active on multiple hosts (sh), we
* would need to used cluster mirrors.
*/
if (is_lockd_type(vg->lock_type)) {
if (vg_is_shared(vg))) {
if (!lv) {
log_error("pvmove in a shared VG requires a named LV.");
return ECMD_FAILED;

View File

@ -197,7 +197,7 @@ static int _pvscan_autoactivate_single(struct cmd_context *cmd, const char *vg_n
if (vg_is_exported(vg))
return ECMD_PROCESSED;
if (is_lockd_type(vg->lock_type))
if (vg_is_shared(vg)))
return ECMD_PROCESSED;
log_debug("pvscan autoactivating VG %s.", vg_name);

View File

@ -631,7 +631,7 @@ static int _vgchange_lock_start(struct cmd_context *cmd, struct volume_group *vg
int auto_opt = 0;
int r;
if (!is_lockd_type(vg->lock_type))
if (!vg_is_shared(vg))
return 1;
if (arg_is_set(cmd, force_ARG))

View File

@ -207,7 +207,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
* used after this command completes (otherwise, the VG can only be
* read without locks until the lockspace is done starting.)
*/
if (is_lockd_type(vg->lock_type)) {
if (vg_is_shared(vg)) {
const char *start_opt = arg_str_value(cmd, lockopt_ARG, NULL);
if (!lockd_start_vg(cmd, vg, 1)) {

View File

@ -28,7 +28,7 @@ static int vgexport_single(struct cmd_context *cmd __attribute__((unused)),
goto bad;
}
if (is_lockd_type(vg->lock_type)) {
if (vg_is_shared(vg)) {
struct lv_list *lvl;
dm_list_iterate_items(lvl, &vg->lvs) {
if (!lockd_lv_uses_lock(lvl->lv))

View File

@ -38,7 +38,7 @@ static int _vgimport_single(struct cmd_context *cmd,
vg->status &= ~EXPORTED_VG;
if (!is_lockd_type(vg->lock_type))
if (!vg_is_shared(vg))
vg->system_id = cmd->system_id ? dm_pool_strdup(vg->vgmem, cmd->system_id) : NULL;
dm_list_iterate_items(pvl, &vg->pvs) {

View File

@ -26,7 +26,7 @@ static struct volume_group *_vgmerge_vg_read(struct cmd_context *cmd,
return NULL;
}
if (is_lockd_type(vg->lock_type)) {
if (vg_is_shared(vg)) {
log_error("vgmerge not allowed for lock_type %s", vg->lock_type);
unlock_and_release_vg(cmd, vg, vg_name);
return NULL;

View File

@ -517,7 +517,7 @@ static struct volume_group *_vgsplit_from(struct cmd_context *cmd,
return NULL;
}
if (is_lockd_type(vg_from->lock_type)) {
if (vg_is_shared(vg_from)) {
log_error("vgsplit not allowed for lock_type %s", vg_from->lock_type);
unlock_and_release_vg(cmd, vg_from, vg_name_from);
return NULL;