[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/9] btrfs: add support for reading a filesystem with a RAID
From: |
Daniel Kiper |
Subject: |
Re: [PATCH 1/9] btrfs: add support for reading a filesystem with a RAID 5 or RAID 6 profile. |
Date: |
Wed, 30 May 2018 12:07:18 +0200 |
User-agent: |
Mutt/1.3.28i |
On Wed, May 16, 2018 at 08:48:11PM +0200, Goffredo Baroncelli wrote:
> Signed-off-by: Goffredo Baroncelli <address@hidden>
> ---
> grub-core/fs/btrfs.c | 68 ++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 68 insertions(+)
>
> diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
> index be195448d..394611cbb 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,72 @@ 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, stripe_nr, high, 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;
> + }
> +
> + /*
> + * Below an example of a RAID6 layout and the meaning of the
s/an example of a RAID6/is an example of a RAID 6/
> + * variables. The same apply to RAID5. The only differences is
> that
s/The same apply to RAID5/The same applies to RAID 5/
> + * there is only one parity instead of two.
s/parity/parity disk/
> + *
> + * A RAID6 6 layout consists in several stripes spread
s/RAID6 6/RAID 6/
s/consists in/consists of/
> + * on the disks, following a layout like the one below
s/on the disks/over the disks/
> + *
> + * Disk1 Disk2 Disk3 Ddisk4
> + *
> + * A1 B1 P1 Q1
> + * Q2 A2 B2 P2
> + * P3 Q3 A3 B3
> + * [...]
> + *
> + * Note that the placement of the parities depends on row index;
Please, please, please, do not abuse ";". Full stop is preffered at the
end of sentence. Please fix this in all patches.
> + * In the code below:
> + * stripe_nr -> is the stripe number not considering the parities
> + * (A1=0, B1=1, A2 = 2, B2 = 3, ...)
May I ask you to do this like that.
The variables below have following meaning:
- stripe_nr is the stripe number not considering the parities
(A1 = 0, B1 = 1, A2 = 2, B2 = 3, ...),
- high is the row number (0 for A1...Q1, 1 for Q2...P2, ...),
...
- low is the offset of the data inside a stripe.
> + * high -> is the row number (0 for A1...Q1, 1 for Q2..P2, ...)
> + * stripen -> is the column number (or disk number)
> + * off -> logical address to read (from the beginning of the
> + * chunk space)
What do you mean by "chunk"? Is it e.g. A1 + B1 region? Please make it
clear what do you mean by "chunk".
> + * chunk_stripe_length -> size of a stripe (typically 64k)
> + * nstripes -> number of disks
> + * low -> offset of the data inside a stripe
It looks that stripe_offset and csize explanation is missing here.
> + *
> + */
> + stripe_nr = grub_divmod64 (off, chunk_stripe_length, &low);
> +
> + /*
> + * In the line below stripen is evaluated without considering
s/In the line below //
> + * the parities (0 for A1, A2, A3... 1 for B1, B2...);
s/;/./
> + */
> + high = grub_divmod64 (stripe_nr, nstripes - nparities, &stripen);
> +
> + /*
> + * In the line below stripen, now consider also the parities (0
s/In the line below stripen, now/Now/
> + * for A1, 1 for A2, 2 for A3....); the math is done "modulo"
s/; the/. The/
s/"modulo"/modulo/
> + * number of disks
Full stop at the end of sentence please.
Daniel
- [PATCH V4] Add support for BTRFS raid5/6 to GRUB, Goffredo Baroncelli, 2018/05/16
- [PATCH 1/9] btrfs: add support for reading a filesystem with a RAID 5 or RAID 6 profile., Goffredo Baroncelli, 2018/05/16
- Re: [PATCH 1/9] btrfs: add support for reading a filesystem with a RAID 5 or RAID 6 profile.,
Daniel Kiper <=
- [PATCH 2/9] btrfs: add helper to check the btrfs header., Goffredo Baroncelli, 2018/05/16
- [PATCH 5/9] btrfs: move logging code in grub_btrfs_read_logical(), Goffredo Baroncelli, 2018/05/16
- [PATCH 6/9] btrfs: refactor the code that read from disk, Goffredo Baroncelli, 2018/05/16
- [PATCH 3/9] btrfs: move the error logging from find_device() to its callee., Goffredo Baroncelli, 2018/05/16
- [PATCH 4/9] btrfs: avoiding a rescan for a device which was already not founded., Goffredo Baroncelli, 2018/05/16