nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0482-btrfs-Add-support-for-new-RAID1C34-profiles.patch

d18179
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
d18179
From: David Sterba <dave@jikos.cz>
d18179
Date: Mon, 4 Nov 2019 17:23:22 +0100
d18179
Subject: [PATCH] btrfs: Add support for new RAID1C34 profiles
d18179
d18179
New 3- and 4-copy variants of RAID1 were merged into Linux kernel 5.5.
d18179
Add the two new profiles to the list of recognized ones. As this builds
d18179
on the same code as RAID1, only the redundancy level needs to be
d18179
adjusted, the rest is done by the existing code.
d18179
d18179
Signed-off-by: David Sterba <dsterba@suse.com>
d18179
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
d18179
(cherry picked from commit 495781f5ed1b48bf27f16c53940d6700c181c74c)
d18179
---
d18179
 grub-core/fs/btrfs.c | 11 +++++++++--
d18179
 1 file changed, 9 insertions(+), 2 deletions(-)
d18179
d18179
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
d18179
index 6f17f5d0eb..2d92d9c1b2 100644
d18179
--- a/grub-core/fs/btrfs.c
d18179
+++ b/grub-core/fs/btrfs.c
d18179
@@ -122,6 +122,8 @@ struct grub_btrfs_chunk_item
d18179
 #define GRUB_BTRFS_CHUNK_TYPE_RAID10        0x40
d18179
 #define GRUB_BTRFS_CHUNK_TYPE_RAID5         0x80
d18179
 #define GRUB_BTRFS_CHUNK_TYPE_RAID6         0x100
d18179
+#define GRUB_BTRFS_CHUNK_TYPE_RAID1C3       0x200
d18179
+#define GRUB_BTRFS_CHUNK_TYPE_RAID1C4       0x400
d18179
   grub_uint8_t dummy2[0xc];
d18179
   grub_uint16_t nstripes;
d18179
   grub_uint16_t nsubstripes;
d18179
@@ -743,14 +745,19 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
d18179
 	      csize = (stripen + 1) * stripe_length - off;
d18179
 	      break;
d18179
 	    }
d18179
+	  case GRUB_BTRFS_CHUNK_TYPE_RAID1C4:
d18179
+	    redundancy++;
d18179
+	    /* fall through */
d18179
+	  case GRUB_BTRFS_CHUNK_TYPE_RAID1C3:
d18179
+	    redundancy++;
d18179
+	    /* fall through */
d18179
 	  case GRUB_BTRFS_CHUNK_TYPE_DUPLICATED:
d18179
 	  case GRUB_BTRFS_CHUNK_TYPE_RAID1:
d18179
 	    {
d18179
-	      grub_dprintf ("btrfs", "RAID1\n");
d18179
+	      grub_dprintf ("btrfs", "RAID1 (copies: %d)\n", ++redundancy);
d18179
 	      stripen = 0;
d18179
 	      stripe_offset = off;
d18179
 	      csize = grub_le_to_cpu64 (chunk->size) - off;
d18179
-	      redundancy = 2;
d18179
 	      break;
d18179
 	    }
d18179
 	  case GRUB_BTRFS_CHUNK_TYPE_RAID0: