mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-24 06:04:19 +03:00
pvcreate wipes md superblocks. (With --uuid or --restorefile it prompts.)
This commit is contained in:
parent
0cdf7b0613
commit
99249cff04
@ -1,5 +1,6 @@
|
||||
Version 2.00.26 -
|
||||
=====================================
|
||||
pvcreate wipes md superblocks. (With --uuid or --restorefile it prompts.)
|
||||
Separate out md superblock detection code.
|
||||
Prevent snapshot origin resizing.
|
||||
Improve a vgremove error message.
|
||||
|
@ -537,6 +537,7 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
||||
/* md component filter. Optional, non-critical. */
|
||||
if (find_config_bool(cmd->cft->root, "devices/md_component_detection",
|
||||
DEFAULT_MD_COMPONENT_DETECTION)) {
|
||||
init_md_filtering(1);
|
||||
if ((filters[nr_filt] = md_filter_create()))
|
||||
nr_filt++;
|
||||
}
|
||||
|
@ -28,7 +28,12 @@
|
||||
|
||||
static int _ignore_md(struct dev_filter *f, struct device *dev)
|
||||
{
|
||||
int ret = dev_is_md(dev, NULL);
|
||||
int ret;
|
||||
|
||||
if (!md_filtering())
|
||||
return 1;
|
||||
|
||||
ret = dev_is_md(dev, NULL);
|
||||
|
||||
if (ret == 1) {
|
||||
log_debug("%s: Skipping md component device", dev_name(dev));
|
||||
|
@ -28,6 +28,7 @@ static struct str_list _log_dev_alias;
|
||||
static int _verbose_level = VERBOSE_BASE_LEVEL;
|
||||
static int _test = 0;
|
||||
static int _partial = 0;
|
||||
static int _md_filtering = 0;
|
||||
static int _pvmove = 0;
|
||||
static int _debug_level = 0;
|
||||
static int _syslog = 0;
|
||||
@ -138,6 +139,11 @@ void init_partial(int level)
|
||||
_partial = level;
|
||||
}
|
||||
|
||||
void init_md_filtering(int level)
|
||||
{
|
||||
_md_filtering = level;
|
||||
}
|
||||
|
||||
void init_pvmove(int level)
|
||||
{
|
||||
_pvmove = level;
|
||||
@ -187,6 +193,11 @@ int partial_mode()
|
||||
return _partial;
|
||||
}
|
||||
|
||||
int md_filtering()
|
||||
{
|
||||
return _md_filtering;
|
||||
}
|
||||
|
||||
int pvmove_mode()
|
||||
{
|
||||
return _pvmove;
|
||||
|
@ -63,6 +63,7 @@ void fin_syslog(void);
|
||||
void init_verbose(int level);
|
||||
void init_test(int level);
|
||||
void init_partial(int level);
|
||||
void init_md_filtering(int level);
|
||||
void init_pvmove(int level);
|
||||
void init_debug(int level);
|
||||
void init_cmd_name(int status);
|
||||
@ -75,6 +76,7 @@ void set_cmd_name(const char *cmd_name);
|
||||
|
||||
int test_mode(void);
|
||||
int partial_mode(void);
|
||||
int md_filtering(void);
|
||||
int pvmove_mode(void);
|
||||
int debug_level(void);
|
||||
int ignorelockingfailure(void);
|
||||
|
@ -25,6 +25,8 @@ const char _really_init[] =
|
||||
static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
{
|
||||
struct physical_volume *pv;
|
||||
struct device *dev;
|
||||
uint64_t md_superblock;
|
||||
|
||||
/* is the partition type set correctly ? */
|
||||
if ((arg_count(cmd, force_ARG) < 1) && !is_lvm_partition(name)) {
|
||||
@ -33,31 +35,65 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* is there a pv here already */
|
||||
/* Is there a pv here already? */
|
||||
/* FIXME Use partial mode here? */
|
||||
if (!(pv = pv_read(cmd, name, NULL, NULL, 0)))
|
||||
return 1;
|
||||
|
||||
/* orphan ? */
|
||||
if (!pv->vg_name[0])
|
||||
return 1;
|
||||
pv = pv_read(cmd, name, NULL, NULL, 0);
|
||||
|
||||
/* Allow partial & exported VGs to be destroyed. */
|
||||
/* we must have -ff to overwrite a non orphan */
|
||||
if (arg_count(cmd, force_ARG) < 2) {
|
||||
/* We must have -ff to overwrite a non orphan */
|
||||
if (pv && pv->vg_name[0] && arg_count(cmd, force_ARG) != 2) {
|
||||
log_error("Can't initialize physical volume \"%s\" of "
|
||||
"volume group \"%s\" without -ff", name, pv->vg_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* prompt */
|
||||
if (!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') {
|
||||
log_print("%s: physical volume not initialized", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, force_ARG)) {
|
||||
dev = dev_cache_get(name, cmd->filter);
|
||||
|
||||
/* Is there an md superblock here? */
|
||||
if (!dev && md_filtering()) {
|
||||
unlock_vg(cmd, "");
|
||||
log_verbose("Wiping cache of LVM-capable devices");
|
||||
persistent_filter_wipe(cmd->filter);
|
||||
log_verbose("Wiping internal cache");
|
||||
lvmcache_destroy();
|
||||
init_md_filtering(0);
|
||||
if (!lock_vol(cmd, "", LCK_VG_WRITE)) {
|
||||
log_error("Can't get lock for orphan PVs");
|
||||
init_md_filtering(1);
|
||||
return 0;
|
||||
}
|
||||
dev = dev_cache_get(name, cmd->filter);
|
||||
init_md_filtering(1);
|
||||
}
|
||||
|
||||
if (!dev) {
|
||||
log_error("Device %s not found.", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Wipe superblock? */
|
||||
if (dev_is_md(dev, &md_superblock) &&
|
||||
((!arg_count(cmd, uuidstr_ARG) &&
|
||||
!arg_count(cmd, restorefile_ARG)) ||
|
||||
arg_count(cmd, yes_ARG) ||
|
||||
(yes_no_prompt("Software RAID md superblock "
|
||||
"detected on %s. Wipe it? [y/n] ", name) == 'y'))) {
|
||||
log_print("Wiping software RAID md superblock on %s", name);
|
||||
if (!dev_zero(dev, md_superblock, 512)) {
|
||||
log_error("Failed to wipe RAID md superblock on %s",
|
||||
name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (pv && pv->vg_name[0] && arg_count(cmd, force_ARG)) {
|
||||
log_print("WARNING: Forcing physical volume creation on "
|
||||
"%s%s%s%s", name,
|
||||
pv->vg_name[0] ? " of volume group \"" : "",
|
||||
|
Loading…
x
Reference in New Issue
Block a user