]> sourceware.org Git - lvm2.git/commitdiff
Detect and wipe swap signatures in pvcreate.
authorPetr Rockai <prokai@redhat.com>
Tue, 17 Mar 2009 13:59:56 +0000 (13:59 +0000)
committerPetr Rockai <prokai@redhat.com>
Tue, 17 Mar 2009 13:59:56 +0000 (13:59 +0000)
WHATS_NEW
lib/Makefile.in
lib/device/device.h
test/t-pvcreate-operation.sh
tools/pvcreate.c

index 1df0fe9bfbc7b3f59ee68f1ce19f068b8b0758bf..20a87a2e2c8b565bba7e09e33ca84a9a44d42822 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 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 lvcreate to remove cow volume if the snapshot creation fails.
   Fix error messages when PV uuid or pe_start reading fails.
index ee1f8ff9311502ed74e4debf08691bfadf9db8ca..e65d0c269db5eaab6ca67792c29f94349381ed99 100644 (file)
@@ -42,6 +42,7 @@ SOURCES =\
        device/dev-cache.c \
        device/dev-io.c \
        device/dev-md.c \
+       device/dev-swap.c \
        device/device.c \
        display/display.c \
        error/errseg.c \
index ac300231d20c4d08caa343ec914fe13a1517894f..abec65025fc9b620c87769b46e85ee6db6ee3afa 100644 (file)
@@ -93,6 +93,7 @@ const char *dev_name_confirmed(struct device *dev, int quiet);
 
 /* Does device contain md superblock?  If so, where? */
 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);
 
 int is_partitioned_dev(struct device *dev);
index 2affcfc994fd8c5e1b8494894e0c61b27a91abc2..a0b67e20b76487f40e86e8e6f7701e74d70ceea7 100755 (executable)
@@ -108,3 +108,10 @@ not pvcreate --uuid $uuid1 --restorefile $backupfile $dev1
 pvcreate --uuid $uuid1 $dev1
 vgcfgbackup -f $backupfile
 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"
index 8ec95f4519d2c4c22dec013f882b1677f6b49bdf..aa3dcff407eb3acfd02f512ad525ca510fa75d46 100644 (file)
@@ -45,7 +45,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
 {
        struct physical_volume *pv;
        struct device *dev;
-       uint64_t md_superblock;
+       uint64_t md_superblock, swap_signature;
 
        /* 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())
                return 0;
 
This page took 0.050074 seconds and 5 git commands to generate.