Backport patches for supporting intel vroc raid device. Commit 23774f997ea077f2cbe8a32bd8bccdd7f4560cca (devices: detect md ddf and imsm superblocks) Commit 00c9a788cc617e5e40746dee2e17287d61ee5c81 (devices: simplify md superblock checking code) Commit 7880896f0dbe730e7b47aa8040544434813eacc4 (gcc: calc size in compile time) Commit 12667e9897ad54f5723463b4c864c8259ba0be2a (fix check for md raid imsm signature on 4k devices) Commit 6a099707c433f0b3f2644c52f7773751832693a4 (clang: remove unused assignment) Otherwise, create vg on a intel vroc raid will produce below error: /* command begin */ $ pvcreate /dev/md0 $ vgcreate testvg /dev/md0 Cannot use device /dev/md0 with duplicates. /* command end */ Signed-off-by: Xiaole He <hexiaole@kylinos.cn>
37 lines
1.1 KiB
Diff
37 lines
1.1 KiB
Diff
From ce343148c06c394971fec2ca53f15c60b87a8cf8 Mon Sep 17 00:00:00 2001
|
|
From: David Teigland <teigland@redhat.com>
|
|
Date: Thu, 18 Feb 2021 11:42:32 -0600
|
|
Subject: [PATCH 21/22] 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.
|
|
---
|
|
lib/device/dev-md.c | 10 ++++++++++
|
|
1 file changed, 10 insertions(+)
|
|
|
|
diff --git a/lib/device/dev-md.c b/lib/device/dev-md.c
|
|
index 8fe7fc3..9f211a8 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;
|
|
--
|
|
2.27.0
|
|
|