[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/7] Add support for reading a filesystem with a raid5 or raid6 p
From: |
Goffredo Baroncelli |
Subject: |
[PATCH 1/7] Add support for reading a filesystem with a raid5 or raid6 profile. |
Date: |
Tue, 24 Apr 2018 21:13:10 +0200 |
Signed-off-by: Goffredo Baroncelli <address@hidden>
---
grub-core/fs/btrfs.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index be195448d..b0032ea46 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -119,6 +119,8 @@ struct grub_btrfs_chunk_item
#define GRUB_BTRFS_CHUNK_TYPE_RAID1 0x10
#define GRUB_BTRFS_CHUNK_TYPE_DUPLICATED 0x20
#define GRUB_BTRFS_CHUNK_TYPE_RAID10 0x40
+#define GRUB_BTRFS_CHUNK_TYPE_RAID5 0x80
+#define GRUB_BTRFS_CHUNK_TYPE_RAID6 0x100
grub_uint8_t dummy2[0xc];
grub_uint16_t nstripes;
grub_uint16_t nsubstripes;
@@ -764,6 +766,36 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data,
grub_disk_addr_t addr,
stripe_offset = low + chunk_stripe_length
* high;
csize = chunk_stripe_length - low;
+ break;
+ }
+ case GRUB_BTRFS_CHUNK_TYPE_RAID5:
+ case GRUB_BTRFS_CHUNK_TYPE_RAID6:
+ {
+ grub_uint64_t nparities;
+ grub_uint64_t stripe_nr, high;
+ grub_uint64_t low;
+
+ redundancy = 1; /* no redundancy for now */
+
+ if (grub_le_to_cpu64 (chunk->type) & GRUB_BTRFS_CHUNK_TYPE_RAID5)
+ {
+ grub_dprintf ("btrfs", "RAID5\n");
+ nparities = 1;
+ }
+ else
+ {
+ grub_dprintf ("btrfs", "RAID6\n");
+ nparities = 2;
+ }
+
+ stripe_nr = grub_divmod64 (off, chunk_stripe_length, &low);
+
+ high = grub_divmod64 (stripe_nr, nstripes - nparities, &stripen);
+ grub_divmod64 (high + stripen, nstripes, &stripen);
+
+ stripe_offset = low + chunk_stripe_length * high;
+ csize = chunk_stripe_length - low;
+
break;
}
default:
--
2.17.0
- [PATCH V2] Add support for BTRFS raid5/6 to GRUB, Goffredo Baroncelli, 2018/04/24
- [PATCH 1/7] Add support for reading a filesystem with a raid5 or raid6 profile.,
Goffredo Baroncelli <=
- [PATCH 2/7] Add helper to check the btrfs header., Goffredo Baroncelli, 2018/04/24
- [PATCH 3/7] Move from the find_device the error logging logic to the callee., Goffredo Baroncelli, 2018/04/24
- [PATCH 4/7] Avoiding scanning for an already not found device., Goffredo Baroncelli, 2018/04/24
- [PATCH 5/7] Refactor the code of read from disk, Goffredo Baroncelli, 2018/04/24
- [PATCH 6/7] Add support for recovery for a raid5 btrfs profiles., Goffredo Baroncelli, 2018/04/24
- [PATCH 7/7] Add raid6 recovery., Goffredo Baroncelli, 2018/04/24