mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
pvcreate: do not issue warning about any existing PV
If we're calling pvcreate on a device that already has a PV label, the blkid detects the existing PV and then we consider it for wiping before we continue creating the new PV label and we issue a warning with a prompt whether such old PV label should be removed. We don't do this with native signature detection code. Let's make it consistent with old behaviour. But still keep this "PV" (identified as "LVM1_member" or "LVM2_member" by blkid) detection when creating new LVs to avoid unexpected PV label appeareance inside LV.
This commit is contained in:
parent
ce8ebda3fc
commit
6a1957badc
@ -449,8 +449,8 @@ out:
|
||||
|
||||
#ifdef BLKID_WIPING_SUPPORT
|
||||
|
||||
static int _blkid_wipe(blkid_probe probe, struct device *dev,
|
||||
const char *name, int yes, force_t force)
|
||||
static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
|
||||
int exclude_lvm_member, int yes, force_t force)
|
||||
{
|
||||
const char *offset = NULL, *type = NULL, *magic = NULL,
|
||||
*usage = NULL, *label = NULL, *uuid = NULL;
|
||||
@ -458,6 +458,9 @@ static int _blkid_wipe(blkid_probe probe, struct device *dev,
|
||||
size_t len;
|
||||
|
||||
if (!blkid_probe_lookup_value(probe, "TYPE", &type, NULL)) {
|
||||
if (exclude_lvm_member &&
|
||||
(!strcmp(type, "LVM1_member") || !strcmp(type, "LVM2_member")))
|
||||
return 1;
|
||||
if (!blkid_probe_lookup_value(probe, "SBMAGIC_OFFSET", &offset, NULL) &&
|
||||
blkid_probe_lookup_value(probe, "SBMAGIC", &magic, &len))
|
||||
return_0;
|
||||
@ -495,6 +498,7 @@ static int _blkid_wipe(blkid_probe probe, struct device *dev,
|
||||
}
|
||||
|
||||
static int _wipe_known_signatures_with_blkid(struct device *dev, const char *name,
|
||||
int exclude_lvm_member,
|
||||
int yes, force_t force)
|
||||
{
|
||||
blkid_probe probe = NULL;
|
||||
@ -522,7 +526,7 @@ static int _wipe_known_signatures_with_blkid(struct device *dev, const char *nam
|
||||
|
||||
while (!blkid_do_probe(probe)) {
|
||||
found++;
|
||||
if (_blkid_wipe(probe, dev, name, yes, force))
|
||||
if (_blkid_wipe(probe, dev, name, exclude_lvm_member, yes, force))
|
||||
wiped++;
|
||||
}
|
||||
|
||||
@ -576,6 +580,7 @@ static int _wipe_signature(struct device *dev, const char *type, const char *nam
|
||||
}
|
||||
|
||||
static int _wipe_known_signatures_with_lvm(struct device *dev, const char *name,
|
||||
int exclude_lvm_member,
|
||||
int yes, force_t force)
|
||||
{
|
||||
if (!_wipe_signature(dev, "software RAID md superblock", name, 4, yes, force, dev_is_md) ||
|
||||
@ -587,13 +592,16 @@ static int _wipe_known_signatures_with_lvm(struct device *dev, const char *name,
|
||||
}
|
||||
|
||||
int wipe_known_signatures(struct cmd_context *cmd, struct device *dev,
|
||||
const char *name, int yes, force_t force)
|
||||
const char *name, int exclude_lvm_member,
|
||||
int yes, force_t force)
|
||||
{
|
||||
#ifdef BLKID_WIPING_SUPPORT
|
||||
if (find_config_tree_bool(cmd, allocation_use_blkid_wiping_CFG, NULL))
|
||||
return _wipe_known_signatures_with_blkid(dev, name, yes, force);
|
||||
return _wipe_known_signatures_with_blkid(dev, name,
|
||||
exclude_lvm_member, yes, force);
|
||||
#endif
|
||||
return _wipe_known_signatures_with_lvm(dev, name, yes, force);
|
||||
return _wipe_known_signatures_with_lvm(dev, name,
|
||||
exclude_lvm_member, yes, force);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
|
@ -60,7 +60,8 @@ int dev_is_swap(struct device *dev, uint64_t *signature);
|
||||
int dev_is_luks(struct device *dev, uint64_t *signature);
|
||||
|
||||
/* Signature wiping. */
|
||||
int wipe_known_signatures(struct cmd_context *cmd, struct device *dev, const char *name, int yes, force_t force);
|
||||
int wipe_known_signatures(struct cmd_context *cmd, struct device *dev, const char *name,
|
||||
int exclude_lvm_member, int yes, force_t force);
|
||||
|
||||
/* Type-specific device properties */
|
||||
unsigned long dev_md_stripe_width(struct dev_types *dt, struct device *dev);
|
||||
|
@ -5415,7 +5415,7 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
|
||||
if (wp.do_wipe_signatures) {
|
||||
log_verbose("Wiping known signatures on logical volume \"%s/%s\"",
|
||||
lv->vg->name, lv->name);
|
||||
if (!wipe_known_signatures(lv->vg->cmd, dev, name, wp.yes, wp.force))
|
||||
if (!wipe_known_signatures(lv->vg->cmd, dev, name, 0, wp.yes, wp.force))
|
||||
stack;
|
||||
}
|
||||
|
||||
|
@ -1328,7 +1328,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!wipe_known_signatures(cmd, dev, name, pp->yes, pp->force)) {
|
||||
if (!wipe_known_signatures(cmd, dev, name, 1, pp->yes, pp->force)) {
|
||||
log_error("Aborting pvcreate on %s.", name);
|
||||
goto bad;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user