summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2021-02-18 11:42:32 -0600
committerDavid Teigland <teigland@redhat.com>2021-02-18 11:42:32 -0600
commit12667e9897ad54f5723463b4c864c8259ba0be2a (patch)
tree88889674ab648dea1ca1c9dce7a8403876326e3c
parent3cba07125457b82045f41bfafc67733c0dad89a2 (diff)
downloadlvm2-12667e9897ad54f5723463b4c864c8259ba0be2a.tar.gz
fix check for md raid imsm signature on 4k devices
On devices with 4k logical block size, the imsm signature is located 8k from the end of the device, not 1k as is the case for devices with 512 LBS.
-rw-r--r--lib/device/dev-md.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/device/dev-md.c b/lib/device/dev-md.c
index 36494b12b..3049b81b7 100644
--- a/lib/device/dev-md.c
+++ b/lib/device/dev-md.c
@@ -56,6 +56,16 @@ 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;
+ unsigned int physical_block_size = 0;
+ unsigned int logical_block_size = 0;
+
+ if (!dev_get_direct_block_sizes(dev, &physical_block_size, &logical_block_size))
+ return_0;
+
+ if (logical_block_size == 4096)
+ off = (devsize_sectors * 512) - 8192;
+ else
+ off = (devsize_sectors * 512) - 1024;
if (!dev_read_bytes(dev, off, IMSM_SIG_LEN, imsm_signature))
return_0;