master - devices: simplify md superblock checking code
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=00c9a788cc617e5e407...
Commit: 00c9a788cc617e5e40746dee2e17287d61ee5c81
Parent: 23774f997ea077f2cbe8a32bd8bccdd7f4560cca
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Sep 19 12:17:36 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jul 9 10:48:34 2020 -0500
devices: simplify md superblock checking code
---
lib/device/dev-md.c | 135 ++++++++++++++++++++++------------------------------
1 file changed, 58 insertions(+), 77 deletions(-)
diff --git a/lib/device/dev-md.c b/lib/device/dev-md.c
index 13a3c168a..23ce41af1 100644
--- a/lib/device/dev-md.c
+++ b/lib/device/dev-md.c
@@ -75,7 +75,7 @@ struct ddf_header {
char padding[472];
};
-static int _dev_has_ddf_magic(struct device *dev, uint64_t devsize_sectors)
+static int _dev_has_ddf_magic(struct device *dev, uint64_t devsize_sectors, uint64_t *sb_offset)
{
struct ddf_header hdr;
uint32_t crc, our_crc;
@@ -99,8 +99,7 @@ static int _dev_has_ddf_magic(struct device *dev, uint64_t devsize_sectors)
if ((cpu_to_be32(our_crc) == crc) ||
(cpu_to_le32(our_crc) == crc)) {
- log_debug_devs("Found md ddf magic at %llu crc %x %s",
- (unsigned long long)off, crc, dev_name(dev));
+ *sb_offset = off;
return 1;
} else {
log_debug_devs("Found md ddf magic at %llu wrong crc %x disk %x %s",
@@ -123,8 +122,7 @@ static int _dev_has_ddf_magic(struct device *dev, uint64_t devsize_sectors)
if ((cpu_to_be32(our_crc) == crc) ||
(cpu_to_le32(our_crc) == crc)) {
- log_debug_devs("Found md ddf magic at %llu crc %x %s",
- (unsigned long long)off, crc, dev_name(dev));
+ *sb_offset = off;
return 1;
} else {
log_debug_devs("Found md ddf magic at %llu wrong crc %x disk %x %s",
@@ -136,46 +134,6 @@ static int _dev_has_ddf_magic(struct device *dev, uint64_t devsize_sectors)
return 0;
}
-/*
- * Calculate the position of the superblock.
- * It is always aligned to a 4K boundary and
- * depending on minor_version, it can be:
- * 0: At least 8K, but less than 12K, from end of device
- * 1: At start of device
- * 2: 4K from start of device.
- */
-typedef enum {
- MD_MINOR_VERSION_MIN,
- MD_MINOR_V0 = MD_MINOR_VERSION_MIN,
- MD_MINOR_V1,
- MD_MINOR_V2,
- MD_MINOR_VERSION_MAX = MD_MINOR_V2
-} md_minor_version_t;
-
-static uint64_t _v1_sb_offset(uint64_t size, md_minor_version_t minor_version)
-{
- uint64_t sb_offset;
-
- switch(minor_version) {
- case MD_MINOR_V0:
- sb_offset = (size - 8 * 2) & ~(4 * 2 - 1ULL);
- break;
- case MD_MINOR_V1:
- sb_offset = 0;
- break;
- case MD_MINOR_V2:
- sb_offset = 4 * 2;
- break;
- default:
- log_warn(INTERNAL_ERROR "WARNING: Unknown minor version %d.",
- minor_version);
- return 0;
- }
- sb_offset <<= SECTOR_SHIFT;
-
- return sb_offset;
-}
-
/*
* _udev_dev_is_md_component() only works if
* external_device_info_source="udev"
@@ -218,7 +176,6 @@ static int _udev_dev_is_md_component(struct device *dev)
*/
static int _native_dev_is_md_component(struct device *dev, uint64_t *offset_found, int full)
{
- md_minor_version_t minor;
uint64_t size, sb_offset;
int ret;
@@ -234,9 +191,9 @@ static int _native_dev_is_md_component(struct device *dev, uint64_t *offset_foun
return 0;
/*
- * Old md versions locate the magic number at the end of the device.
- * Those checks can't be satisfied with the initial bcache data, and
- * would require an extra read i/o at the end of every device. Issuing
+ * Some md versions locate the magic number at the end of the device.
+ * Those checks can't be satisfied with the initial scan data, and
+ * require an extra read i/o at the end of every device. Issuing
* an extra read to every device in every command, just to check for
* the old md format is a bad tradeoff.
*
@@ -247,54 +204,78 @@ static int _native_dev_is_md_component(struct device *dev, uint64_t *offset_foun
* and set it for commands that could possibly write to an md dev
* (pvcreate/vgcreate/vgextend).
*/
- if (!full) {
- sb_offset = 0;
- if (_dev_has_md_magic(dev, sb_offset)) {
- log_debug_devs("Found md magic number at offset 0 of %s.", dev_name(dev));
- ret = 1;
- goto out;
- }
- sb_offset = 8 << SECTOR_SHIFT;
- if (_dev_has_md_magic(dev, sb_offset)) {
- log_debug_devs("Found md magic number at offset %d of %s.", (int)sb_offset, dev_name(dev));
- ret = 1;
- goto out;
- }
+ /*
+ * md superblock version 1.1 at offset 0 from start
+ */
+
+ if (_dev_has_md_magic(dev, 0)) {
+ log_debug_devs("Found md magic number at offset 0 of %s.", dev_name(dev));
+ ret = 1;
+ goto out;
+ }
+
+ /*
+ * md superblock version 1.2 at offset 4KB from start
+ */
+ if (_dev_has_md_magic(dev, 4096)) {
+ log_debug_devs("Found md magic number at offset 4096 of %s.", dev_name(dev));
+ ret = 1;
+ goto out;
+ }
+
+ if (!full) {
ret = 0;
goto out;
}
- /* Version 0.90.0 */
- /* superblock at 64KB from end of device */
+ /*
+ * Handle superblocks at the end of the device.
+ */
+
+ /*
+ * md superblock version 0 at 64KB from end of device
+ * (after end is aligned to 64KB)
+ */
+
sb_offset = MD_NEW_SIZE_SECTORS(size) << SECTOR_SHIFT;
+
if (_dev_has_md_magic(dev, sb_offset)) {
+ log_debug_devs("Found md magic number at offset %llu of %s.", (unsigned long long)sb_offset, dev_name(dev));
ret = 1;
goto out;
}
- minor = MD_MINOR_VERSION_MIN;
+ /*
+ * md superblock version 1.0 at 8KB from end of device
+ */
- /* Version 1, try v1.0 -> v1.2 */
+ sb_offset = ((size - 8 * 2) & ~(4 * 2 - 1ULL)) << SECTOR_SHIFT;
- do {
- /* superblock at start or 4K from start */
- sb_offset = _v1_sb_offset(size, minor);
- if (_dev_has_md_magic(dev, sb_offset)) {
- ret = 1;
- goto out;
- }
- } while (++minor <= MD_MINOR_VERSION_MAX);
+ if (_dev_has_md_magic(dev, sb_offset)) {
+ log_debug_devs("Found md magic number at offset %llu of %s.", (unsigned long long)sb_offset, dev_name(dev));
+ ret = 1;
+ goto out;
+ }
+
+ /*
+ * md imsm superblock 1K from end of device
+ */
- /* superblock 1K from end of device */
if (_dev_has_imsm_magic(dev, size)) {
+ log_debug_devs("Found md imsm magic number at offset %llu of %s.", (unsigned long long)sb_offset, dev_name(dev));
+ sb_offset = 1024;
ret = 1;
goto out;
}
- /* superblock 512 bytes from end, or 128KB from end */
- if (_dev_has_ddf_magic(dev, size)) {
+ /*
+ * md ddf superblock 512 bytes from end, or 128KB from end
+ */
+
+ if (_dev_has_ddf_magic(dev, size, &sb_offset)) {
+ log_debug_devs("Found md ddf magic number at offset %llu of %s.", (unsigned long long)sb_offset, dev_name(dev));
ret = 1;
goto out;
}
3 years, 9 months
master - devices: detect md ddf and imsm superblocks
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=23774f997ea077f2cbe...
Commit: 23774f997ea077f2cbe8a32bd8bccdd7f4560cca
Parent: 286a793c12aac1fde17cb9768bacad660e1dfeb3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Sep 19 11:33:59 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jul 9 10:48:21 2020 -0500
devices: detect md ddf and imsm superblocks
---
lib/device/dev-md.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 104 insertions(+), 1 deletion(-)
diff --git a/lib/device/dev-md.c b/lib/device/dev-md.c
index 9d0a36363..13a3c168a 100644
--- a/lib/device/dev-md.c
+++ b/lib/device/dev-md.c
@@ -16,6 +16,7 @@
#include "lib/misc/lib.h"
#include "lib/device/dev-type.h"
#include "lib/mm/xlate.h"
+#include "lib/misc/crc.h"
#ifdef UDEV_SYNC_SUPPORT
#include <libudev.h> /* for MD detection using udev db records */
#include "lib/device/dev-ext-udev-constants.h"
@@ -48,6 +49,93 @@ static int _dev_has_md_magic(struct device *dev, uint64_t sb_offset)
return 0;
}
+#define IMSM_SIGNATURE "Intel Raid ISM Cfg Sig. "
+#define IMSM_SIG_LEN (strlen(IMSM_SIGNATURE))
+
+static int _dev_has_imsm_magic(struct device *dev, uint64_t devsize_sectors)
+{
+ char imsm_signature[IMSM_SIG_LEN];
+ uint64_t off = (devsize_sectors * 512) - 1024;
+
+ if (!dev_read_bytes(dev, off, IMSM_SIG_LEN, imsm_signature))
+ return_0;
+
+ if (!memcmp(imsm_signature, IMSM_SIGNATURE, IMSM_SIG_LEN))
+ return 1;
+
+ return 0;
+}
+
+#define DDF_MAGIC 0xDE11DE11
+struct ddf_header {
+ uint32_t magic;
+ uint32_t crc;
+ char guid[24];
+ char revision[8];
+ char padding[472];
+};
+
+static int _dev_has_ddf_magic(struct device *dev, uint64_t devsize_sectors)
+{
+ struct ddf_header hdr;
+ uint32_t crc, our_crc;
+ uint64_t off;
+ uint64_t devsize_bytes = devsize_sectors * 512;
+
+ if (devsize_bytes < 0x30000)
+ return 0;
+
+ /* 512 bytes before the end of device (from libblkid) */
+ off = ((devsize_bytes / 0x200) - 1) * 0x200;
+
+ if (!dev_read_bytes(dev, off, 512, &hdr))
+ return_0;
+
+ if ((hdr.magic == cpu_to_be32(DDF_MAGIC)) ||
+ (hdr.magic == cpu_to_le32(DDF_MAGIC))) {
+ crc = hdr.crc;
+ hdr.crc = 0xffffffff;
+ our_crc = calc_crc(0, (const uint8_t *)&hdr, 512);
+
+ if ((cpu_to_be32(our_crc) == crc) ||
+ (cpu_to_le32(our_crc) == crc)) {
+ log_debug_devs("Found md ddf magic at %llu crc %x %s",
+ (unsigned long long)off, crc, dev_name(dev));
+ return 1;
+ } else {
+ log_debug_devs("Found md ddf magic at %llu wrong crc %x disk %x %s",
+ (unsigned long long)off, our_crc, crc, dev_name(dev));
+ return 0;
+ }
+ }
+
+ /* 128KB before the end of device (from libblkid) */
+ off = ((devsize_bytes / 0x200) - 257) * 0x200;
+
+ if (!dev_read_bytes(dev, off, 512, &hdr))
+ return_0;
+
+ if ((hdr.magic == cpu_to_be32(DDF_MAGIC)) ||
+ (hdr.magic == cpu_to_le32(DDF_MAGIC))) {
+ crc = hdr.crc;
+ hdr.crc = 0xffffffff;
+ our_crc = calc_crc(0, (const uint8_t *)&hdr, 512);
+
+ if ((cpu_to_be32(our_crc) == crc) ||
+ (cpu_to_le32(our_crc) == crc)) {
+ log_debug_devs("Found md ddf magic at %llu crc %x %s",
+ (unsigned long long)off, crc, dev_name(dev));
+ return 1;
+ } else {
+ log_debug_devs("Found md ddf magic at %llu wrong crc %x disk %x %s",
+ (unsigned long long)off, our_crc, crc, dev_name(dev));
+ return 0;
+ }
+ }
+
+ return 0;
+}
+
/*
* Calculate the position of the superblock.
* It is always aligned to a 4K boundary and
@@ -178,8 +266,8 @@ static int _native_dev_is_md_component(struct device *dev, uint64_t *offset_foun
goto out;
}
- /* Check if it is an md component device. */
/* Version 0.90.0 */
+ /* superblock at 64KB from end of device */
sb_offset = MD_NEW_SIZE_SECTORS(size) << SECTOR_SHIFT;
if (_dev_has_md_magic(dev, sb_offset)) {
ret = 1;
@@ -187,8 +275,11 @@ static int _native_dev_is_md_component(struct device *dev, uint64_t *offset_foun
}
minor = MD_MINOR_VERSION_MIN;
+
/* Version 1, try v1.0 -> v1.2 */
+
do {
+ /* superblock at start or 4K from start */
sb_offset = _v1_sb_offset(size, minor);
if (_dev_has_md_magic(dev, sb_offset)) {
ret = 1;
@@ -196,6 +287,18 @@ static int _native_dev_is_md_component(struct device *dev, uint64_t *offset_foun
}
} while (++minor <= MD_MINOR_VERSION_MAX);
+ /* superblock 1K from end of device */
+ if (_dev_has_imsm_magic(dev, size)) {
+ ret = 1;
+ goto out;
+ }
+
+ /* superblock 512 bytes from end, or 128KB from end */
+ if (_dev_has_ddf_magic(dev, size)) {
+ ret = 1;
+ goto out;
+ }
+
ret = 0;
out:
if (ret && offset_found)
3 years, 9 months
stable-2.02 - lvconvert: fix conversion to 'mirrored' mirror log with larger regionsize
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7ebe1bc901c3ed9404f...
Commit: 7ebe1bc901c3ed9404f92c7415c7c491593aed47
Parent: e7e2288ff4ac34d825dd13dd45b0418723a7da84
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Jul 9 14:09:46 2020 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Jul 9 14:43:23 2020 +0200
lvconvert: fix conversion to 'mirrored' mirror log with larger regionsize
merge.c:_check_lv_segment() was checking regionsize vs. mirrored LV size on
any 'mirror/raid1/raid10' segment type including type 'mirrored' mirror logs.
Avoid the check only for 'mirrored' mirror logs to allow conversion from log
type 'disk' with regionsize > mirror log SubLV size.
As we disabled support for 'mirrored' mirror logs with
commit e82303fd6abc3ae43168f8032806c7c17d181a3e which still conditionally
allows to enable it via global/support_mirrored_mirror_logs=1,
patch is mandatory for all distributions.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1712983
---
WHATS_NEW | 1 +
lib/metadata/merge.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0e65ff172..846510b28 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.188 -
==================================
+ Fix conversion to 'mirrored' mirror log with larger regionsize.
Fix support for lvconvert --repair used by foreign apps (i.e. Docker).
Version 2.02.187 - 24th March 2020
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index a024877a3..054f1855f 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -424,7 +424,8 @@ static void _check_lv_segment(struct logical_volume *lv, struct lv_segment *seg,
if (seg_is_mirror(seg)) {
if (!seg->region_size)
seg_error("region size is zero");
- else if (seg->region_size > seg->lv->size)
+ /* Avoid regionsize check in case of 'mirrored' mirror log or larger than mlog regionsize will fail */
+ else if (!strstr(seg->lv->name, "_mlog") && (seg->region_size > seg->lv->size))
seg_error("region size is bigger then LV itself");
else if (!is_power_of_2(seg->region_size))
seg_error("region size is non power of 2");
3 years, 9 months
master - lvconvert: fix conversion to 'mirrored' mirror log with larger regionsize
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=286a793c12aac1fde17...
Commit: 286a793c12aac1fde17cb9768bacad660e1dfeb3
Parent: d0faad0db38fe733cae42d7df136d7ed4f7bcba6
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Jul 9 14:09:46 2020 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Jul 9 14:39:50 2020 +0200
lvconvert: fix conversion to 'mirrored' mirror log with larger regionsize
merge.c:_check_lv_segment() was checking regionsize vs. mirrored LV size on
any 'mirror/raid1/raid10' segment type including type 'mirrored' mirror logs.
Avoid the check only for 'mirrored' mirror logs to allow conversion from log
type 'disk' with regionsize > mirror log SubLV size.
As we disabled support for 'mirrored' mirror logs with
commit e82303fd6abc3ae43168f8032806c7c17d181a3e which still conditionally
allows to enable it via global/support_mirrored_mirror_logs=1,
patch is mandatory for all distributions.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1712983
---
WHATS_NEW | 1 +
lib/metadata/merge.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2e2e6d919..89656a341 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.10 -
=================================
+ Fix conversion to 'mirrored' mirror log with larger regionsize.
Zero pool metadata on allocation (disable with allocation/zero_metadata=0).
Failure in zeroing or wiping will fail command (bypass with -Zn, -Wn).
Fix running out of free buffers for async writing for larger writes.
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index ecd55efdd..1d47449db 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -441,7 +441,8 @@ static void _check_lv_segment(struct logical_volume *lv, struct lv_segment *seg,
if (seg_is_mirror(seg)) {
if (!seg->region_size)
seg_error("region size is zero");
- else if (seg->region_size > seg->lv->size)
+ /* Avoid regionsize check in case of 'mirrored' mirror log or larger than mlog regionsize will fail */
+ else if (!strstr(seg->lv->name, "_mlog") && (seg->region_size > seg->lv->size))
seg_error("region size is bigger then LV itself");
else if (!is_power_of_2(seg->region_size))
seg_error("region size is non power of 2");
3 years, 9 months
master - debug: missing stacktrace
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d0faad0db38fe733cae...
Commit: d0faad0db38fe733cae42d7df136d7ed4f7bcba6
Parent: 9b9bf8786fb423a4430cc676301edadf2310098d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 8 11:06:39 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 8 11:40:55 2020 +0200
debug: missing stacktrace
---
tools/lvconvert.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 0dcc77689..2896c67c3 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -5524,7 +5524,8 @@ static int _writecache_zero(struct cmd_context *cmd, struct logical_volume *lv)
return 0;
}
- ret = wipe_lv(lv, wp);
+ if (!(ret = wipe_lv(lv, wp)))
+ stack;
if (!deactivate_lv(cmd, lv)) {
log_error("Failed to deactivate LV %s for zeroing.", display_lvname(lv));
3 years, 9 months
master - raid: no wiping when zeroing raid metadata device
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9b9bf8786fb423a4430...
Commit: 9b9bf8786fb423a4430cc676301edadf2310098d
Parent: b7f3667ce20b731bbda9b1d61df49abbcd1bd20e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 8 10:59:51 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 8 11:40:55 2020 +0200
raid: no wiping when zeroing raid metadata device
Currently lvm2 is not wiping signatures when creating 'metadata' volumes
and raid _rmeta was the only exception - so make the behavior consistent
with other metadata devices and drop wiping ATM.
Drop also some extra debug since they are now more explanatory in
wipe_lv() function.
Also note - although lvm2 now does not wipe signatures - the error
from such wipping used to be actually 'ignored' before wipe_lv()
started to return error (with recent commit) and raid creation
continued with 'unzeroed' metadata device.
TODO: Several issues to resolve:
1. We may want to flip to wipping with all LVs (in that case we need to
support passing --yet & --force).
2. Also we may want to clear whole metadata device - however current
function is also used for wipping i.e. snapshot COW device which
is likely not a good candidate for full device zeroing.
We may also need to think about better logic when extent size is
enforcing very large LVs, when only a small portion of LV is ever
being used.
3. Using TRIM instead of zeroing metadata device might be worth to
implement.
mm
---
lib/metadata/lv_manip.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 5956d032c..f0ba3f0db 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7731,12 +7731,10 @@ int activate_and_wipe_lvlist(struct dm_list *lv_list, int commit)
}
dm_list_iterate_items(lvl, lv_list) {
- log_verbose("Wiping metadata area %s.", display_lvname(lvl->lv));
/* Wipe any know signatures */
- if (!wipe_lv(lvl->lv, (struct wipe_params) { .do_wipe_signatures = 1, .do_zero = 1, .zero_sectors = 1 })) {
- log_error("Failed to wipe %s.", display_lvname(lvl->lv));
+ if (!wipe_lv(lvl->lv, (struct wipe_params) { .do_zero = 1 /* TODO: is_metadata = 1 */ })) {
r = 0;
- goto out;
+ goto_out;
}
}
out:
3 years, 9 months
master - lvconvert: more support for yes conversion
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b7f3667ce20b731bbda...
Commit: b7f3667ce20b731bbda9b1d61df49abbcd1bd20e
Parent: fe78cd4082cb9af10580180d61898fcef93dc624
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 8 10:57:52 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 8 11:37:33 2020 +0200
lvconvert: more support for yes conversion
When converting volume to pool LV use also wiping of other signatures.
For writecache & pool conversion support --yet and --force
to bypass prompting for signature wiping.
For writecache drop unneded zero_sectors.
Note: currently we have lvconvert doing convertion and prompting
for confirmation of conversion - and then again wipe_lv() prompts
for removing i.e. filesystem signature - we should unify this
prompting into 1 message - althought the 'filesystem' discovery
needs active volume - while the 1st. conversion prompt can
work without active converted volume.
---
tools/lvconvert.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 61256c698..0dcc77689 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3279,7 +3279,11 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
}
metadata_lv->status &= ~LV_ACTIVATION_SKIP;
- if (!wipe_lv(metadata_lv, (struct wipe_params) { .do_zero = 1 })) {
+ if (!wipe_lv(metadata_lv, (struct wipe_params) {
+ .do_wipe_signatures = 1,
+ .is_metadata = 1,
+ .yes = arg_count(cmd, yes_ARG),
+ .force = arg_count(cmd, force_ARG) } )) {
log_error("Aborting. Failed to wipe metadata lv.");
goto bad;
}
@@ -5502,7 +5506,8 @@ static int _writecache_zero(struct cmd_context *cmd, struct logical_volume *lv)
struct wipe_params wp = {
.do_wipe_signatures = 1, /* optional, to print warning if clobbering something */
.do_zero = 1, /* required for dm-writecache to work */
- .zero_sectors = 1
+ .yes = arg_count(cmd, yes_ARG),
+ .force = arg_count(cmd, force_ARG)
};
int ret;
3 years, 9 months
master - wipe_lv: always zero at least 4K
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fe78cd4082cb9af1058...
Commit: fe78cd4082cb9af10580180d61898fcef93dc624
Parent: 40266faaab07f5578d137f9e400fbc9190edabcd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 8 10:38:36 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 8 11:12:54 2020 +0200
wipe_lv: always zero at least 4K
When zero_sectors passed value like 1 - we could zero only 1 sector.
Reinstantiate we always zero at least 4K block.
---
lib/metadata/lv_manip.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index d96137aff..5956d032c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7642,7 +7642,9 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
if (wp.is_metadata) /* Verbosely notify metadata will not be fully zeroed */
log_verbose("Metadata logical volume %s not fully zeroed and may contain stale data.",
display_lvname(lv));
- zero_sectors = wp.zero_sectors ? : UINT64_C(4096) >> SECTOR_SHIFT;
+ zero_sectors = UINT64_C(4096) >> SECTOR_SHIFT;
+ if (wp.zero_sectors > zero_sectors)
+ zero_sectors = wp.zero_sectors;
if (zero_sectors > lv->size)
zero_sectors = lv->size;
3 years, 9 months
master - writecache: skip fs block size check in test mode
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=40266faaab07f5578d1...
Commit: 40266faaab07f5578d137f9e400fbc9190edabcd
Parent: ad773511c59aea239592c014a2dab4161ed92214
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jul 7 13:20:18 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jul 7 13:20:18 2020 -0500
writecache: skip fs block size check in test mode
if doing so requires activating the LV
---
tools/lvconvert.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 0155fdbf9..61256c698 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -5649,6 +5649,11 @@ static int _set_writecache_block_size(struct cmd_context *cmd,
stack;
if (!(fs_dev = dev_cache_get(cmd, pathname, NULL))) {
+ if (test_mode()) {
+ log_print("Test mode skips checking fs block size.");
+ fs_block_size = 0;
+ goto skip_fs;
+ }
log_error("Device for LV not found to check block size %s", pathname);
goto_bad;
}
@@ -5667,6 +5672,7 @@ static int _set_writecache_block_size(struct cmd_context *cmd,
* With 512 LBS and 4K PBS, mkfs.xfs will use xfs sector size 4K.
*/
rv = get_fs_block_size(fs_dev, &fs_block_size);
+skip_fs:
if (!rv || !fs_block_size) {
if (lbs_4k && pbs_4k && !pbs_512) {
block_size = 4096;
3 years, 9 months