1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-17 06:04:23 +03:00

Suppress 'No PV label' message when removing several PVs without mdas.

This commit is contained in:
Alasdair Kergon 2010-11-23 01:55:53 +00:00
parent 9cd9dab06a
commit 728074ac83
6 changed files with 27 additions and 24 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.78 - Version 2.02.78 -
==================================== ====================================
Suppress 'No PV label' message when removing several PVs without mdas.
Fix default /etc/lvm permissions to be 0755. (2.02.66) Fix default /etc/lvm permissions to be 0755. (2.02.66)
Version 2.02.77 - 22nd November 2010 Version 2.02.77 - 22nd November 2010

View File

@ -848,7 +848,7 @@ void lvm_do_backup(const char *vgname)
pthread_mutex_lock(&lvm_lock); pthread_mutex_lock(&lvm_lock);
vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, &consistent); vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, 1, &consistent);
if (vg && consistent) if (vg && consistent)
check_current_backup(vg); check_current_backup(vg);

View File

@ -341,7 +341,7 @@ int vg_write(struct volume_group *vg);
int vg_commit(struct volume_group *vg); int vg_commit(struct volume_group *vg);
int vg_revert(struct volume_group *vg); int vg_revert(struct volume_group *vg);
struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name, struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name,
const char *vgid, int *consistent); const char *vgid, int warnings, int *consistent);
struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name, struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
struct dm_list *mdas, uint64_t *label_sector, struct dm_list *mdas, uint64_t *label_sector,
int warnings, int scan_label_only); int warnings, int scan_label_only);
@ -357,7 +357,7 @@ void lv_set_hidden(struct logical_volume *lv);
struct dm_list *get_vgnames(struct cmd_context *cmd, int include_internal); struct dm_list *get_vgnames(struct cmd_context *cmd, int include_internal);
struct dm_list *get_vgids(struct cmd_context *cmd, int include_internal); struct dm_list *get_vgids(struct cmd_context *cmd, int include_internal);
int scan_vgs_for_pvs(struct cmd_context *cmd); int scan_vgs_for_pvs(struct cmd_context *cmd, int warnings);
int pv_write(struct cmd_context *cmd, struct physical_volume *pv, int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
struct dm_list *mdas, int64_t label_sector); struct dm_list *mdas, int64_t label_sector);

View File

@ -344,7 +344,7 @@ int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name,
struct pv_list *pvl; struct pv_list *pvl;
int r = 0, consistent = 0; int r = 0, consistent = 0;
if (!(vg = vg_read_internal(fmt->cmd, vg_name, vgid, &consistent))) { if (!(vg = vg_read_internal(fmt->cmd, vg_name, vgid, 1, &consistent))) {
log_error("get_pv_from_vg_by_id: vg_read_internal failed to read VG %s", log_error("get_pv_from_vg_by_id: vg_read_internal failed to read VG %s",
vg_name); vg_name);
return 0; return 0;
@ -918,7 +918,7 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name)
/* FIXME: Is this vg_read_internal necessary? Move it inside /* FIXME: Is this vg_read_internal necessary? Move it inside
vg_lock_newname? */ vg_lock_newname? */
/* is this vg name already in use ? */ /* is this vg name already in use ? */
if ((vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) { if ((vg = vg_read_internal(cmd, vg_name, NULL, 1, &consistent))) {
log_error("A volume group called '%s' already exists.", vg_name); log_error("A volume group called '%s' already exists.", vg_name);
unlock_and_release_vg(cmd, vg, vg_name); unlock_and_release_vg(cmd, vg, vg_name);
return _vg_make_handle(cmd, NULL, FAILED_EXIST); return _vg_make_handle(cmd, NULL, FAILED_EXIST);
@ -1343,7 +1343,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
* system. * system.
*/ */
if (pv && is_orphan(pv) && mdas_empty_or_ignored(&mdas)) { if (pv && is_orphan(pv) && mdas_empty_or_ignored(&mdas)) {
if (!scan_vgs_for_pvs(cmd)) if (!scan_vgs_for_pvs(cmd, 0))
return_0; return_0;
pv = pv_read(cmd, name, NULL, NULL, 0, 0); pv = pv_read(cmd, name, NULL, NULL, 0, 0);
} }
@ -1812,7 +1812,7 @@ static struct physical_volume *_find_pv_by_name(struct cmd_context *cmd,
if (is_orphan_vg(pv->vg_name) && mdas_empty_or_ignored(&mdas)) { if (is_orphan_vg(pv->vg_name) && mdas_empty_or_ignored(&mdas)) {
/* If a PV has no MDAs - need to search all VGs for it */ /* If a PV has no MDAs - need to search all VGs for it */
if (!scan_vgs_for_pvs(cmd)) if (!scan_vgs_for_pvs(cmd, 1))
return_NULL; return_NULL;
if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0))) { if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0))) {
log_error("Physical volume %s not found", pv_name); log_error("Physical volume %s not found", pv_name);
@ -2513,6 +2513,7 @@ int vg_revert(struct volume_group *vg)
/* Make orphan PVs look like a VG */ /* Make orphan PVs look like a VG */
static struct volume_group *_vg_read_orphans(struct cmd_context *cmd, static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
int warnings,
const char *orphan_vgname) const char *orphan_vgname)
{ {
struct lvmcache_vginfo *vginfo; struct lvmcache_vginfo *vginfo;
@ -2554,7 +2555,7 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
} }
dm_list_iterate_items(info, &vginfo->infos) { dm_list_iterate_items(info, &vginfo->infos) {
if (!(pv = _pv_read(cmd, mem, dev_name(info->dev), NULL, NULL, 1, 0))) { if (!(pv = _pv_read(cmd, mem, dev_name(info->dev), NULL, NULL, warnings, 0))) {
continue; continue;
} }
if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl)))) { if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl)))) {
@ -2641,6 +2642,7 @@ static void check_reappeared_pv(struct volume_group *correct_vg,
static struct volume_group *_vg_read(struct cmd_context *cmd, static struct volume_group *_vg_read(struct cmd_context *cmd,
const char *vgname, const char *vgname,
const char *vgid, const char *vgid,
int warnings,
int *consistent, unsigned precommitted) int *consistent, unsigned precommitted)
{ {
struct format_instance *fid; struct format_instance *fid;
@ -2667,7 +2669,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
return NULL; return NULL;
} }
*consistent = 1; *consistent = 1;
return _vg_read_orphans(cmd, vgname); return _vg_read_orphans(cmd, warnings, vgname);
} }
/* /*
@ -3035,12 +3037,12 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
} }
struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgname, struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgname,
const char *vgid, int *consistent) const char *vgid, int warnings, int *consistent)
{ {
struct volume_group *vg; struct volume_group *vg;
struct lv_list *lvl; struct lv_list *lvl;
if (!(vg = _vg_read(cmd, vgname, vgid, consistent, 0))) if (!(vg = _vg_read(cmd, vgname, vgid, warnings, consistent, 0)))
return NULL; return NULL;
if (!check_pv_segments(vg)) { if (!check_pv_segments(vg)) {
@ -3104,7 +3106,7 @@ static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd,
/* Is corresponding vgname already cached? */ /* Is corresponding vgname already cached? */
if ((vginfo = vginfo_from_vgid(vgid)) && if ((vginfo = vginfo_from_vgid(vgid)) &&
vginfo->vgname && !is_orphan_vg(vginfo->vgname)) { vginfo->vgname && !is_orphan_vg(vginfo->vgname)) {
if ((vg = _vg_read(cmd, NULL, vgid, if ((vg = _vg_read(cmd, NULL, vgid, 1,
&consistent, precommitted)) && &consistent, precommitted)) &&
!strncmp((char *)vg->id.uuid, vgid, ID_LEN)) { !strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
@ -3137,7 +3139,7 @@ static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd,
if (!vgname) if (!vgname)
continue; // FIXME Unnecessary? continue; // FIXME Unnecessary?
consistent = 0; consistent = 0;
if ((vg = _vg_read(cmd, vgname, vgid, &consistent, if ((vg = _vg_read(cmd, vgname, vgid, 1, &consistent,
precommitted)) && precommitted)) &&
!strncmp((char *)vg->id.uuid, vgid, ID_LEN)) { !strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
@ -3208,7 +3210,7 @@ const char *find_vgname_from_pvid(struct cmd_context *cmd,
* every PV on the system. * every PV on the system.
*/ */
if (mdas_empty_or_ignored(&info->mdas)) { if (mdas_empty_or_ignored(&info->mdas)) {
if (!scan_vgs_for_pvs(cmd)) { if (!scan_vgs_for_pvs(cmd, 1)) {
log_error("Rescan for PVs without " log_error("Rescan for PVs without "
"metadata areas failed."); "metadata areas failed.");
return NULL; return NULL;
@ -3323,7 +3325,7 @@ struct dm_list *get_vgids(struct cmd_context *cmd, int include_internal)
return lvmcache_get_vgids(cmd, include_internal); return lvmcache_get_vgids(cmd, include_internal);
} }
static int _get_pvs(struct cmd_context *cmd, struct dm_list **pvslist) static int _get_pvs(struct cmd_context *cmd, int warnings, struct dm_list **pvslist)
{ {
struct str_list *strl; struct str_list *strl;
struct dm_list * uninitialized_var(results); struct dm_list * uninitialized_var(results);
@ -3364,7 +3366,7 @@ static int _get_pvs(struct cmd_context *cmd, struct dm_list **pvslist)
stack; stack;
continue; continue;
} }
if (!(vg = vg_read_internal(cmd, vgname, vgid, &consistent))) { if (!(vg = vg_read_internal(cmd, vgname, vgid, warnings, &consistent))) {
stack; stack;
continue; continue;
} }
@ -3398,15 +3400,15 @@ struct dm_list *get_pvs(struct cmd_context *cmd)
{ {
struct dm_list *results; struct dm_list *results;
if (!_get_pvs(cmd, &results)) if (!_get_pvs(cmd, 1, &results))
return NULL; return NULL;
return results; return results;
} }
int scan_vgs_for_pvs(struct cmd_context *cmd) int scan_vgs_for_pvs(struct cmd_context *cmd, int warnings)
{ {
return _get_pvs(cmd, NULL); return _get_pvs(cmd, warnings, NULL);
} }
int pv_write(struct cmd_context *cmd __attribute__((unused)), int pv_write(struct cmd_context *cmd __attribute__((unused)),
@ -3581,7 +3583,7 @@ static struct volume_group *_recover_vg(struct cmd_context *cmd,
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) if (!lock_vol(cmd, vg_name, LCK_VG_WRITE))
return_NULL; return_NULL;
if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent))) if (!(vg = vg_read_internal(cmd, vg_name, vgid, 1, &consistent)))
return_NULL; return_NULL;
if (!consistent) { if (!consistent) {
@ -3636,7 +3638,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
consistent_in = consistent; consistent_in = consistent;
/* If consistent == 1, we get NULL here if correction fails. */ /* If consistent == 1, we get NULL here if correction fails. */
if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent))) { if (!(vg = vg_read_internal(cmd, vg_name, vgid, 1, &consistent))) {
if (consistent_in && !consistent) { if (consistent_in && !consistent) {
log_error("Volume group \"%s\" inconsistent.", vg_name); log_error("Volume group \"%s\" inconsistent.", vg_name);
failure |= FAILED_INCONSISTENT; failure |= FAILED_INCONSISTENT;

View File

@ -48,7 +48,7 @@ static int pvremove_check(struct cmd_context *cmd, const char *name)
* PV on the system. * PV on the system.
*/ */
if (is_orphan(pv) && !dm_list_size(&mdas)) { if (is_orphan(pv) && !dm_list_size(&mdas)) {
if (!scan_vgs_for_pvs(cmd)) { if (!scan_vgs_for_pvs(cmd, 0)) {
log_error("Rescan for PVs without metadata areas " log_error("Rescan for PVs without metadata areas "
"failed."); "failed.");
return 0; return 0;

View File

@ -629,7 +629,7 @@ static int _process_all_devs(struct cmd_context *cmd, void *handle,
int ret_max = ECMD_PROCESSED; int ret_max = ECMD_PROCESSED;
int ret = 0; int ret = 0;
if (!scan_vgs_for_pvs(cmd)) { if (!scan_vgs_for_pvs(cmd, 1)) {
stack; stack;
return ECMD_FAILED; return ECMD_FAILED;
} }
@ -744,7 +744,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
if (!scanned && is_orphan(pv) && if (!scanned && is_orphan(pv) &&
!dm_list_size(&mdas)) { !dm_list_size(&mdas)) {
if (!scan_label_only && if (!scan_label_only &&
!scan_vgs_for_pvs(cmd)) { !scan_vgs_for_pvs(cmd, 1)) {
stack; stack;
ret_max = ECMD_FAILED; ret_max = ECMD_FAILED;
continue; continue;