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

Detect and wipe swap signatures in pvcreate.

This commit is contained in:
Petr Rockai 2009-03-17 13:59:56 +00:00
parent d917c98cd8
commit 3402ccd488
5 changed files with 22 additions and 1 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.46 - Version 2.02.46 -
================================ ================================
Detect and conditionally wipe swapspace signatures in pvcreate.
Fix maximal volume count check for snapshots if max_lv set for volume group. Fix maximal volume count check for snapshots if max_lv set for volume group.
Fix lvcreate to remove cow volume if the snapshot creation fails. Fix lvcreate to remove cow volume if the snapshot creation fails.
Fix error messages when PV uuid or pe_start reading fails. Fix error messages when PV uuid or pe_start reading fails.

View File

@ -42,6 +42,7 @@ SOURCES =\
device/dev-cache.c \ device/dev-cache.c \
device/dev-io.c \ device/dev-io.c \
device/dev-md.c \ device/dev-md.c \
device/dev-swap.c \
device/device.c \ device/device.c \
display/display.c \ display/display.c \
error/errseg.c \ error/errseg.c \

View File

@ -93,6 +93,7 @@ const char *dev_name_confirmed(struct device *dev, int quiet);
/* Does device contain md superblock? If so, where? */ /* Does device contain md superblock? If so, where? */
int dev_is_md(struct device *dev, uint64_t *sb); int dev_is_md(struct device *dev, uint64_t *sb);
int dev_is_swap(struct device *dev, uint64_t *signature);
unsigned long dev_md_chunk_size(const char *sysfs_dir, struct device *dev); unsigned long dev_md_chunk_size(const char *sysfs_dir, struct device *dev);
int is_partitioned_dev(struct device *dev); int is_partitioned_dev(struct device *dev);

View File

@ -108,3 +108,10 @@ not pvcreate --uuid $uuid1 --restorefile $backupfile $dev1
pvcreate --uuid $uuid1 $dev1 pvcreate --uuid $uuid1 $dev1
vgcfgbackup -f $backupfile vgcfgbackup -f $backupfile
not pvcreate --uuid $uuid2 --restorefile $backupfile $dev2 not pvcreate --uuid $uuid2 --restorefile $backupfile $dev2
# pvcreate wipes swap signature when forced
dd if=/dev/zero of=$dev1 bs=1024 count=64
mkswap $dev1
file -s $dev1 | grep "swap file"
pvcreate -f $dev1
file -s $dev1 | not grep "swap file"

View File

@ -45,7 +45,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
{ {
struct physical_volume *pv; struct physical_volume *pv;
struct device *dev; struct device *dev;
uint64_t md_superblock; uint64_t md_superblock, swap_signature;
/* FIXME Check partition type is LVM unless --force is given */ /* FIXME Check partition type is LVM unless --force is given */
@ -129,6 +129,17 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
} }
} }
if (dev_is_swap(dev, &swap_signature) &&
((!pp->idp && !pp->restorefile) || pp->yes ||
(yes_no_prompt("Swap signature detected on %s. Wipe it? [y/n] ",
name) == 'y'))) {
log_print("Wiping swap signature on %s", name);
if (!dev_set(dev, swap_signature, 10, 0)) {
log_error("Failed to wipe swap signature on %s", name);
return 0;
}
}
if (sigint_caught()) if (sigint_caught())
return 0; return 0;