]> sourceware.org Git - lvm2.git/commitdiff
pv: _pvcreate_write: do label removal and zeroing only if creating a new PV
authorPeter Rajnoha <prajnoha@redhat.com>
Thu, 12 Mar 2015 14:18:52 +0000 (15:18 +0100)
committerPeter Rajnoha <prajnoha@redhat.com>
Mon, 15 Feb 2016 11:44:46 +0000 (12:44 +0100)
lib/metadata/metadata.c

index 90643fa5cd37cf5d0a3020fc639b012db8ee0a44..7af545a11dd0d7a67207c484ee282a017e7ea5ed 100644 (file)
@@ -1637,32 +1637,33 @@ void pvcreate_params_set_defaults(struct pvcreate_params *pp)
 
 static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_write *pvw)
 {
-       int zero = pvw->pp ? pvw->pp->zero : 1;
        struct physical_volume *pv = pvw->pv;
        struct device *dev = pv->dev;
        const char *pv_name = dev_name(dev);
 
-       /* Wipe existing label first */
-       if (!label_remove(pv_dev(pv))) {
-               log_error("Failed to wipe existing label on %s", pv_name);
-               return 0;
-       }
-
-       if (zero) {
-               log_verbose("Zeroing start of device %s", pv_name);
-               if (!dev_open_quiet(dev)) {
-                       log_error("%s not opened: device not zeroed", pv_name);
+       if (pvw->new_pv) {
+               /* Wipe existing label first */
+               if (!label_remove(pv_dev(pv))) {
+                       log_error("Failed to wipe existing label on %s", pv_name);
                        return 0;
                }
 
-               if (!dev_set(dev, UINT64_C(0), (size_t) 2048, 0)) {
-                       log_error("%s not wiped: aborting", pv_name);
+               if (pvw->pp->zero) {
+                       log_verbose("Zeroing start of device %s", pv_name);
+                       if (!dev_open_quiet(dev)) {
+                               log_error("%s not opened: device not zeroed", pv_name);
+                               return 0;
+                       }
+
+                       if (!dev_set(dev, UINT64_C(0), (size_t) 2048, 0)) {
+                               log_error("%s not wiped: aborting", pv_name);
+                               if (!dev_close(dev))
+                                       stack;
+                               return 0;
+                       }
                        if (!dev_close(dev))
                                stack;
-                       return 0;
                }
-               if (!dev_close(dev))
-                       stack;
        }
 
        log_verbose("Writing physical volume data to disk \"%s\"",
This page took 0.044995 seconds and 5 git commands to generate.