]> sourceware.org Git - lvm2.git/commitdiff
fix check for md raid imsm signature on 4k devices
authorDavid Teigland <teigland@redhat.com>
Thu, 18 Feb 2021 17:42:32 +0000 (11:42 -0600)
committerDavid Teigland <teigland@redhat.com>
Thu, 18 Feb 2021 17:42:32 +0000 (11:42 -0600)
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.

lib/device/dev-md.c

index 36494b12b383c93366a2724381f6bc4bae7642d3..3049b81b726f94cc876676d9e5d749654b006e89 100644 (file)
@@ -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;
This page took 0.039747 seconds and 5 git commands to generate.