1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-02-08 09:57:55 +03:00

Convert pv->vg_name to get_pv_vg_name

This commit is contained in:
Dave Wysochanski 2007-06-13 23:53:38 +00:00
parent 80f8436f0a
commit 3755157c61
8 changed files with 57 additions and 57 deletions

View File

@ -51,17 +51,17 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
} }
/* If in a VG, must change using volume group. */ /* If in a VG, must change using volume group. */
if (*pv->vg_name) { if (*get_pv_vg_name(pv)) {
log_verbose("Finding volume group of physical volume \"%s\"", log_verbose("Finding volume group of physical volume \"%s\"",
pv_name); pv_name);
if (!lock_vol(cmd, pv->vg_name, LCK_VG_WRITE)) { if (!lock_vol(cmd, pv->vg_name, LCK_VG_WRITE)) {
log_error("Can't get lock for %s", pv->vg_name); log_error("Can't get lock for %s", get_pv_vg_name(pv));
return 0; return 0;
} }
if (!(vg = vg_read(cmd, pv->vg_name, NULL, &consistent))) { if (!(vg = vg_read(cmd, pv->vg_name, NULL, &consistent))) {
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
log_error("Unable to find volume group of \"%s\"", log_error("Unable to find volume group of \"%s\"",
pv_name); pv_name);
return 0; return 0;
@ -69,25 +69,25 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
if (!vg_check_status(vg, if (!vg_check_status(vg,
CLUSTERED | EXPORTED_VG | LVM_WRITE)) { CLUSTERED | EXPORTED_VG | LVM_WRITE)) {
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
return 0; return 0;
} }
if (!(pvl = find_pv_in_vg(vg, pv_name))) { if (!(pvl = find_pv_in_vg(vg, pv_name))) {
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
log_error log_error
("Unable to find \"%s\" in volume group \"%s\"", ("Unable to find \"%s\" in volume group \"%s\"",
pv_name, vg->name); pv_name, vg->name);
return 0; return 0;
} }
if (tagarg && !(vg->fid->fmt->features & FMT_TAGS)) { if (tagarg && !(vg->fid->fmt->features & FMT_TAGS)) {
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
log_error("Volume group containing %s does not " log_error("Volume group containing %s does not "
"support tags", pv_name); "support tags", pv_name);
return 0; return 0;
} }
if (arg_count(cmd, uuid_ARG) && lvs_in_vg_activated(vg)) { if (arg_count(cmd, uuid_ARG) && lvs_in_vg_activated(vg)) {
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
log_error("Volume group containing %s has active " log_error("Volume group containing %s has active "
"logical volumes", pv_name); "logical volumes", pv_name);
return 0; return 0;
@ -127,8 +127,8 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
if (allocatable && (get_pv_status(pv) & ALLOCATABLE_PV)) { if (allocatable && (get_pv_status(pv) & ALLOCATABLE_PV)) {
log_error("Physical volume \"%s\" is already " log_error("Physical volume \"%s\" is already "
"allocatable", pv_name); "allocatable", pv_name);
if (*pv->vg_name) if (*get_pv_vg_name(pv))
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
else else
unlock_vg(cmd, ORPHAN); unlock_vg(cmd, ORPHAN);
return 1; return 1;
@ -137,8 +137,8 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
if (!allocatable && !(get_pv_status(pv) & ALLOCATABLE_PV)) { if (!allocatable && !(get_pv_status(pv) & ALLOCATABLE_PV)) {
log_error("Physical volume \"%s\" is already " log_error("Physical volume \"%s\" is already "
"unallocatable", pv_name); "unallocatable", pv_name);
if (*pv->vg_name) if (*get_pv_vg_name(pv))
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
else else
unlock_vg(cmd, ORPHAN); unlock_vg(cmd, ORPHAN);
return 1; return 1;
@ -180,7 +180,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
return 0; return 0;
} }
log_verbose("Changing uuid of %s to %s.", pv_name, uuid); log_verbose("Changing uuid of %s to %s.", pv_name, uuid);
if (*pv->vg_name) { if (*get_pv_vg_name(pv)) {
orig_vg_name = pv->vg_name; orig_vg_name = pv->vg_name;
orig_pe_alloc_count = get_pv_pe_alloc_count(pv); orig_pe_alloc_count = get_pv_pe_alloc_count(pv);
pv->vg_name = ORPHAN; pv->vg_name = ORPHAN;
@ -196,15 +196,15 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
} }
log_verbose("Updating physical volume \"%s\"", pv_name); log_verbose("Updating physical volume \"%s\"", pv_name);
if (*pv->vg_name) { if (*get_pv_vg_name(pv)) {
if (!vg_write(vg) || !vg_commit(vg)) { if (!vg_write(vg) || !vg_commit(vg)) {
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
log_error("Failed to store physical volume \"%s\" in " log_error("Failed to store physical volume \"%s\" in "
"volume group \"%s\"", pv_name, vg->name); "volume group \"%s\"", pv_name, vg->name);
return 0; return 0;
} }
backup(vg); backup(vg);
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
} else { } else {
if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) { if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
unlock_vg(cmd, ORPHAN); unlock_vg(cmd, ORPHAN);

View File

@ -47,13 +47,13 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
/* We must have -ff to overwrite a non orphan */ /* We must have -ff to overwrite a non orphan */
if (pv && pv->vg_name[0] && arg_count(cmd, force_ARG) != 2) { if (pv && pv->vg_name[0] && arg_count(cmd, force_ARG) != 2) {
log_error("Can't initialize physical volume \"%s\" of " log_error("Can't initialize physical volume \"%s\" of "
"volume group \"%s\" without -ff", name, pv->vg_name); "volume group \"%s\" without -ff", name, get_pv_vg_name(pv));
return 0; return 0;
} }
/* prompt */ /* prompt */
if (pv && pv->vg_name[0] && !arg_count(cmd, yes_ARG) && if (pv && pv->vg_name[0] && !arg_count(cmd, yes_ARG) &&
yes_no_prompt(_really_init, name, pv->vg_name) == 'n') { yes_no_prompt(_really_init, name, get_pv_vg_name(pv)) == 'n') {
log_print("%s: physical volume not initialized", name); log_print("%s: physical volume not initialized", name);
return 0; return 0;
} }

View File

@ -26,14 +26,14 @@ static int _pvdisplay_single(struct cmd_context *cmd,
const char *pv_name = dev_name(get_pv_dev(pv)); const char *pv_name = dev_name(get_pv_dev(pv));
if (pv->vg_name) { if (get_pv_vg_name(pv)) {
if (!lock_vol(cmd, pv->vg_name, LCK_VG_READ)) { if (!lock_vol(cmd, pv->vg_name, LCK_VG_READ)) {
log_error("Can't lock %s: skipping", pv->vg_name); log_error("Can't lock %s: skipping", get_pv_vg_name(pv));
return ECMD_FAILED; return ECMD_FAILED;
} }
if (!(vg = vg_read(cmd, pv->vg_name, (char *)&pv->vgid, &consistent))) { if (!(vg = vg_read(cmd, pv->vg_name, (char *)&pv->vgid, &consistent))) {
log_error("Can't read %s: skipping", pv->vg_name); log_error("Can't read %s: skipping", get_pv_vg_name(pv));
goto out; goto out;
} }
@ -56,7 +56,7 @@ static int _pvdisplay_single(struct cmd_context *cmd,
pv = pvl->pv; pv = pvl->pv;
} }
if (!*pv->vg_name) if (!*get_pv_vg_name(pv))
size = get_pv_size(pv); size = get_pv_size(pv);
else else
size = (get_pv_pe_count(pv) - get_pv_pe_alloc_count(pv)) * size = (get_pv_pe_count(pv) - get_pv_pe_alloc_count(pv)) *
@ -70,9 +70,9 @@ static int _pvdisplay_single(struct cmd_context *cmd,
if (get_pv_status(pv) & EXPORTED_VG) if (get_pv_status(pv) & EXPORTED_VG)
log_print("Physical volume \"%s\" of volume group \"%s\" " log_print("Physical volume \"%s\" of volume group \"%s\" "
"is exported", pv_name, pv->vg_name); "is exported", pv_name, get_pv_vg_name(pv));
if (!pv->vg_name) if (!get_pv_vg_name(pv))
log_print("\"%s\" is a new physical volume of \"%s\"", log_print("\"%s\" is a new physical volume of \"%s\"",
pv_name, display_size(cmd, size)); pv_name, display_size(cmd, size));
@ -87,8 +87,8 @@ static int _pvdisplay_single(struct cmd_context *cmd,
pvdisplay_segments(pv); pvdisplay_segments(pv);
out: out:
if (pv->vg_name) if (get_pv_vg_name(pv))
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
return ret; return ret;
} }

View File

@ -289,9 +289,9 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
} }
/* Read VG */ /* Read VG */
log_verbose("Finding volume group \"%s\"", pv->vg_name); log_verbose("Finding volume group \"%s\"", get_pv_vg_name(pv));
if (!(vg = _get_vg(cmd, pv->vg_name))) { if (!(vg = _get_vg(cmd, get_pv_vg_name(pv)))) {
stack; stack;
return ECMD_FAILED; return ECMD_FAILED;
} }
@ -304,7 +304,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
if (!(lvs_changed = lvs_using_lv(cmd, vg, lv_mirr))) { if (!(lvs_changed = lvs_using_lv(cmd, vg, lv_mirr))) {
log_error log_error
("ABORTING: Failed to generate list of moving LVs"); ("ABORTING: Failed to generate list of moving LVs");
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
return ECMD_FAILED; return ECMD_FAILED;
} }
@ -312,7 +312,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
if (!activate_lv_excl(cmd, lv_mirr)) { if (!activate_lv_excl(cmd, lv_mirr)) {
log_error log_error
("ABORTING: Temporary mirror activation failed."); ("ABORTING: Temporary mirror activation failed.");
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
return ECMD_FAILED; return ECMD_FAILED;
} }
@ -322,7 +322,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
if (!(source_pvl = create_pv_list(cmd->mem, vg, 1, if (!(source_pvl = create_pv_list(cmd->mem, vg, 1,
&pv_name_arg, 0))) { &pv_name_arg, 0))) {
stack; stack;
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
return ECMD_FAILED; return ECMD_FAILED;
} }
@ -334,12 +334,12 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
if (!(allocatable_pvs = _get_allocatable_pvs(cmd, argc, argv, if (!(allocatable_pvs = _get_allocatable_pvs(cmd, argc, argv,
vg, pv, alloc))) { vg, pv, alloc))) {
stack; stack;
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
return ECMD_FAILED; return ECMD_FAILED;
} }
if (!archive(vg)) { if (!archive(vg)) {
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
stack; stack;
return ECMD_FAILED; return ECMD_FAILED;
} }
@ -348,7 +348,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
allocatable_pvs, alloc, allocatable_pvs, alloc,
&lvs_changed))) { &lvs_changed))) {
stack; stack;
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
return ECMD_FAILED; return ECMD_FAILED;
} }
} }
@ -356,7 +356,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
/* Lock lvs_changed for exclusive use and activate (with old metadata) */ /* Lock lvs_changed for exclusive use and activate (with old metadata) */
if (!activate_lvs_excl(cmd, lvs_changed)) { if (!activate_lvs_excl(cmd, lvs_changed)) {
stack; stack;
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
return ECMD_FAILED; return ECMD_FAILED;
} }
@ -368,13 +368,13 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
if (!_update_metadata if (!_update_metadata
(cmd, vg, lv_mirr, lvs_changed, first_time)) { (cmd, vg, lv_mirr, lvs_changed, first_time)) {
stack; stack;
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
return ECMD_FAILED; return ECMD_FAILED;
} }
} }
/* LVs are all in status LOCKED */ /* LVs are all in status LOCKED */
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }
@ -469,7 +469,7 @@ static struct volume_group *_get_move_vg(struct cmd_context *cmd,
return NULL; return NULL;
} }
return _get_vg(cmd, pv->vg_name); return _get_vg(cmd, get_pv_vg_name(pv));
} }
static struct poll_functions _pvmove_fns = { static struct poll_functions _pvmove_fns = {

View File

@ -50,13 +50,13 @@ static int pvremove_check(struct cmd_context *cmd, const char *name)
/* we must have -ff to overwrite a non orphan */ /* we must have -ff to overwrite a non orphan */
if (arg_count(cmd, force_ARG) < 2) { if (arg_count(cmd, force_ARG) < 2) {
log_error("Can't pvremove physical volume \"%s\" of " log_error("Can't pvremove physical volume \"%s\" of "
"volume group \"%s\" without -ff", name, pv->vg_name); "volume group \"%s\" without -ff", name, get_pv_vg_name(pv));
return 0; return 0;
} }
/* prompt */ /* prompt */
if (!arg_count(cmd, yes_ARG) && if (!arg_count(cmd, yes_ARG) &&
yes_no_prompt(_really_wipe, name, pv->vg_name) == 'n') { yes_no_prompt(_really_wipe, name, get_pv_vg_name(pv)) == 'n') {
log_print("%s: physical volume label not removed", name); log_print("%s: physical volume label not removed", name);
return 0; return 0;
} }

View File

@ -41,7 +41,7 @@ static int _pvresize_single(struct cmd_context *cmd,
params->total++; params->total++;
if (!*pv->vg_name) { if (!*get_pv_vg_name(pv)) {
vg_name = ORPHAN; vg_name = ORPHAN;
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) { if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
@ -66,7 +66,7 @@ static int _pvresize_single(struct cmd_context *cmd,
vg_name = pv->vg_name; vg_name = pv->vg_name;
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) { if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
log_error("Can't get lock for %s", pv->vg_name); log_error("Can't get lock for %s", get_pv_vg_name(pv));
return ECMD_FAILED; return ECMD_FAILED;
} }
@ -158,9 +158,9 @@ static int _pvresize_single(struct cmd_context *cmd,
pv_name, get_pv_size(pv)); pv_name, get_pv_size(pv));
log_verbose("Updating physical volume \"%s\"", pv_name); log_verbose("Updating physical volume \"%s\"", pv_name);
if (*pv->vg_name) { if (*get_pv_vg_name(pv)) {
if (!vg_write(vg) || !vg_commit(vg)) { if (!vg_write(vg) || !vg_commit(vg)) {
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
log_error("Failed to store physical volume \"%s\" in " log_error("Failed to store physical volume \"%s\" in "
"volume group \"%s\"", pv_name, vg->name); "volume group \"%s\"", pv_name, vg->name);
return ECMD_FAILED; return ECMD_FAILED;

View File

@ -48,7 +48,7 @@ static void _pvscan_display_single(struct cmd_context *cmd,
memset(pv_tmp_name, 0, sizeof(pv_tmp_name)); memset(pv_tmp_name, 0, sizeof(pv_tmp_name));
vg_name_len = strlen(pv->vg_name) + 1; vg_name_len = strlen(get_pv_vg_name(pv)) + 1;
if (arg_count(cmd, uuid_ARG)) { if (arg_count(cmd, uuid_ARG)) {
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) { if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
@ -62,7 +62,7 @@ static void _pvscan_display_single(struct cmd_context *cmd,
sprintf(pv_tmp_name, "%s", dev_name(get_pv_dev(pv))); sprintf(pv_tmp_name, "%s", dev_name(get_pv_dev(pv)));
} }
if (!*pv->vg_name) { if (!*get_pv_vg_name(pv)) {
log_print("PV %-*s %-*s %s [%s]", log_print("PV %-*s %-*s %s [%s]",
pv_max_name_len, pv_tmp_name, pv_max_name_len, pv_tmp_name,
vg_max_name_len, " ", vg_max_name_len, " ",
@ -85,7 +85,7 @@ static void _pvscan_display_single(struct cmd_context *cmd,
return; return;
} }
sprintf(vg_tmp_name, "%s", pv->vg_name); sprintf(vg_tmp_name, "%s", get_pv_vg_name(pv));
log_print("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len, log_print("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len,
pv_tmp_name, vg_max_name_len, vg_tmp_name, pv_tmp_name, vg_max_name_len, vg_tmp_name,
pv->fmt ? pv->fmt->name : " ", pv->fmt ? pv->fmt->name : " ",
@ -137,7 +137,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
if ((arg_count(cmd, exported_ARG) if ((arg_count(cmd, exported_ARG)
&& !(get_pv_status(pv) & EXPORTED_VG)) && !(get_pv_status(pv) & EXPORTED_VG))
|| (arg_count(cmd, novolumegroup_ARG) && (*pv->vg_name))) { || (arg_count(cmd, novolumegroup_ARG) && (*get_pv_vg_name(pv)))) {
list_del(&pvl->list); list_del(&pvl->list);
continue; continue;
} }
@ -154,7 +154,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
********/ ********/
pvs_found++; pvs_found++;
if (!*pv->vg_name) { if (!*get_pv_vg_name(pv)) {
new_pvs_found++; new_pvs_found++;
size_new += get_pv_size(pv); size_new += get_pv_size(pv);
size_total += get_pv_size(pv); size_total += get_pv_size(pv);
@ -169,7 +169,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
len = strlen(dev_name(get_pv_dev(pv))); len = strlen(dev_name(get_pv_dev(pv)));
if (pv_max_name_len < len) if (pv_max_name_len < len)
pv_max_name_len = len; pv_max_name_len = len;
len = strlen(pv->vg_name); len = strlen(get_pv_vg_name(pv));
if (vg_max_name_len < len) if (vg_max_name_len < len)
vg_max_name_len = len; vg_max_name_len = len;
} }

View File

@ -62,12 +62,12 @@ static int _pvsegs_sub_single(struct cmd_context *cmd, struct volume_group *vg,
int ret = ECMD_PROCESSED; int ret = ECMD_PROCESSED;
if (!lock_vol(cmd, pv->vg_name, LCK_VG_READ)) { if (!lock_vol(cmd, pv->vg_name, LCK_VG_READ)) {
log_error("Can't lock %s: skipping", pv->vg_name); log_error("Can't lock %s: skipping", get_pv_vg_name(pv));
return ECMD_FAILED; return ECMD_FAILED;
} }
if (!(vg = vg_read(cmd, pv->vg_name, NULL, &consistent))) { if (!(vg = vg_read(cmd, pv->vg_name, NULL, &consistent))) {
log_error("Can't read %s: skipping", pv->vg_name); log_error("Can't read %s: skipping", get_pv_vg_name(pv));
goto out; goto out;
} }
@ -80,7 +80,7 @@ static int _pvsegs_sub_single(struct cmd_context *cmd, struct volume_group *vg,
ret = ECMD_FAILED; ret = ECMD_FAILED;
out: out:
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
return ret; return ret;
} }
@ -106,14 +106,14 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
int consistent = 0; int consistent = 0;
int ret = ECMD_PROCESSED; int ret = ECMD_PROCESSED;
if (pv->vg_name) { if (get_pv_vg_name(pv)) {
if (!lock_vol(cmd, pv->vg_name, LCK_VG_READ)) { if (!lock_vol(cmd, pv->vg_name, LCK_VG_READ)) {
log_error("Can't lock %s: skipping", pv->vg_name); log_error("Can't lock %s: skipping", get_pv_vg_name(pv));
return ECMD_FAILED; return ECMD_FAILED;
} }
if (!(vg = vg_read(cmd, pv->vg_name, (char *)&pv->vgid, &consistent))) { if (!(vg = vg_read(cmd, pv->vg_name, (char *)&pv->vgid, &consistent))) {
log_error("Can't read %s: skipping", pv->vg_name); log_error("Can't read %s: skipping", get_pv_vg_name(pv));
goto out; goto out;
} }
@ -127,8 +127,8 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
ret = ECMD_FAILED; ret = ECMD_FAILED;
out: out:
if (pv->vg_name) if (get_pv_vg_name(pv))
unlock_vg(cmd, pv->vg_name); unlock_vg(cmd, get_pv_vg_name(pv));
return ret; return ret;
} }