grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Goffredo Baroncelli <kreijack@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH 1/9] btrfs: Add support for reading a filesystem with a RAID 5 or RAID 6 profile.
Date: Thu, 14 Jun 2018 20:55:00 +0200	[thread overview]
Message-ID: <680f897a-c0d1-f61e-65a3-78e1483e15a8@gmail.com> (raw)
In-Reply-To: <20180614111753.GA6436@router-fw-old.local.net-space.pl>

On 06/14/2018 01:17 PM, Daniel Kiper wrote:
> On Sun, Jun 03, 2018 at 08:53:40PM +0200, Goffredo Baroncelli wrote:
>> Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
>> ---
>>  grub-core/fs/btrfs.c | 70 ++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 70 insertions(+)
>>
>> diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
>> index be195448d..4d418859b 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,74 @@ 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 is an example of a RAID 6 layout and the meaning of the
>> +	       * variables. The same applies to RAID 5. The only differences is
>> +	       * that there is only one parity disk instead of two.
>> +	       *
>> +	       * A RAID 6 layout consists of several stripes spread
>> +	       * on the disks, following a layout like the one below
>> +	       *
>> +	       *   Disk1  Disk2  Disk3  Ddisk4
> 
> Numbering seems confusing to me. I think that it should be
>                    Disk0  Disk1  Disk2  Disk3
> 
>> +	       *
>> +	       *    A1     B1     P1     Q1
>> +	       *    Q2     A2     B2     P2
>> +	       *    P3     Q3     A3     B3
>> +	       *  [...]
>> +	       *
>> +	       *  Note that the placement of the parities depends on row index.
>> +	       *  In the code below:
>> +	       *  - stripe_nr is the stripe number not considering the parities
>> +	       *    (A1=0, B1=1, A2 = 2, B2 = 3, ...),
> 
> Please be consistent. A1 = 0, B1 = 1, A2 = 2, B2 = 3, ...
> 
>> +	       *  - high is the row number (0 for A1...Q1, 1 for Q2..P2, ...),
> 
> Ditto. Please always use "..." not "..".
> 
>> +	       *  - stripen is the column number (or disk number),
> 
> AIUI starting from 0. Right? If yes then I think that
> drawing above requires disks/columns renumbering.
right
> 
>> +	       *  - off is the logical address to read (from the beginning of
>> +	       *    the chunk space),
> 
> s/chunk space/chunk/?
> 
>> +	       *  - chunk_stripe_length is the size of a stripe (typically 64k),
>> +	       *  - nstripes is the number of disks,
>> +	       *  - low is the offset of the data inside a stripe,
>> +	       *  - stripe_offset is the offset from the beginning of the chunk
>> +	       *    disks physical address,
> 
> I am not sure that I understand. Could clarify this?
- stripe_offset is the offset (in bytes) from the beginning of the chunk portion 
  stored on disk.

You can think "stripe_offset" as the "row" in the drawing, but measured in bytes.

> 
>> +	       *  - csize is the "potential" data to read. It will be reduced to
>> +	       *    size if the latter is smaller.
>> +	       */
>> +	      stripe_nr = grub_divmod64 (off, chunk_stripe_length, &low);
> 
> OK.
> 
>> +	      /*
>> +	       * stripen is evaluated without considering
>> +	       * the parities (0 for A1, A2, A3... 1 for B1, B2...).
>> +	       */
>> +	      high = grub_divmod64 (stripe_nr, nstripes - nparities, &stripen);
> 
> OK.
> 
>> +	      /*
>> +	       * stripen now considers also the parities (0 for A1, 1 for A2,
>> +	       * 2 for A3....). The math is performed modulo number of disks.
>> +	       */
>> +	      grub_divmod64 (high + stripen, nstripes, &stripen);
> 
> OK.
> 
>> +	      stripe_offset = low + chunk_stripe_length * high;
> 
> Hmmm... I am confused. What does it mean?
> 
> Daniel
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 


-- 
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5


  reply	other threads:[~2018-06-14 18:55 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-03 18:53 [PATCH V5] Add support for BTRFS raid5/6 to GRUB Goffredo Baroncelli
2018-06-03 18:53 ` [PATCH 1/9] btrfs: Add support for reading a filesystem with a RAID 5 or RAID 6 profile Goffredo Baroncelli
2018-06-14 11:17   ` Daniel Kiper
2018-06-14 18:55     ` Goffredo Baroncelli [this message]
2018-06-19 17:30       ` Goffredo Baroncelli
2018-06-03 18:53 ` [PATCH 2/9] btrfs: Add helper to check the btrfs header Goffredo Baroncelli
2018-06-14 11:25   ` Daniel Kiper
2018-06-03 18:53 ` [PATCH 3/9] btrfs: Move the error logging from find_device() to its caller Goffredo Baroncelli
2018-06-14 11:28   ` Daniel Kiper
2018-06-03 18:53 ` [PATCH 5/9] btrfs: Move logging code in grub_btrfs_read_logical() Goffredo Baroncelli
2018-06-14 11:52   ` Daniel Kiper
2018-06-03 18:53 ` [PATCH 6/9] btrfs: Refactor the code that read from disk Goffredo Baroncelli
2018-06-14 12:38   ` Daniel Kiper
2018-06-03 18:53 ` [PATCH 7/9] btrfs: Add support for recovery for a RAID 5 btrfs profiles Goffredo Baroncelli
2018-06-14 13:03   ` Daniel Kiper
2018-06-14 19:05     ` Goffredo Baroncelli
2018-06-18 18:12       ` Goffredo Baroncelli
2018-09-03 12:32         ` Daniel Kiper
2018-06-03 18:53 ` [PATCH 8/9] btrfs: Make more generic the code for RAID 6 rebuilding Goffredo Baroncelli
2018-06-03 18:53 ` [PATCH 9/9] btrfs: Add RAID 6 recovery for a btrfs filesystem Goffredo Baroncelli
2018-06-14 13:11   ` Daniel Kiper
2018-06-14 13:21 ` [PATCH V5] Add support for BTRFS raid5/6 to GRUB Daniel Kiper
2018-06-14 18:06   ` Goffredo Baroncelli
  -- strict thread matches above, loose matches on Subject: below --
2018-10-22 17:29 [PATCH V11] " Goffredo Baroncelli
2018-10-22 17:29 ` [PATCH 1/9] btrfs: Add support for reading a filesystem with a RAID 5 or RAID 6 profile Goffredo Baroncelli
2018-10-18 17:55 [PATCH V10] Add support for BTRFS raid5/6 to GRUB Goffredo Baroncelli
2018-10-18 17:55 ` [PATCH 1/9] btrfs: Add support for reading a filesystem with a RAID 5 or RAID 6 profile Goffredo Baroncelli
2018-10-11 18:50 [PATCH V9] Add support for BTRFS raid5/6 to GRUB Goffredo Baroncelli
2018-10-11 18:50 ` [PATCH 1/9] btrfs: Add support for reading a filesystem with a RAID 5 or RAID 6 profile Goffredo Baroncelli
2018-10-17 13:46   ` Daniel Kiper
2018-09-27 18:34 [PATCH V8] Add support for BTRFS raid5/6 to GRUB Goffredo Baroncelli
2018-09-27 18:34 ` [PATCH 1/9] btrfs: Add support for reading a filesystem with a RAID 5 or RAID 6 profile Goffredo Baroncelli
2018-10-09 17:51   ` Daniel Kiper
2018-10-11 13:17     ` Daniel Kiper
2018-09-19 18:40 [PATCH V7] Add support for BTRFS raid5/6 to GRUB Goffredo Baroncelli
2018-09-19 18:40 ` [PATCH 1/9] btrfs: Add support for reading a filesystem with a RAID 5 or RAID 6 profile Goffredo Baroncelli
2018-09-25 15:31   ` Daniel Kiper
2018-09-26 20:40     ` Goffredo Baroncelli
2018-09-27 15:47       ` Daniel Kiper
2018-09-19 18:36 Goffredo Baroncelli
2018-09-19 18:42 ` Goffredo Baroncelli
2018-06-19 17:39 [PATCH V6] Add support for BTRFS raid5/6 to GRUB Goffredo Baroncelli
2018-06-19 17:39 ` [PATCH 1/9] btrfs: Add support for reading a filesystem with a RAID 5 or RAID 6 profile Goffredo Baroncelli
2018-07-08 15:51   ` Goffredo Baroncelli
2018-07-09 10:20     ` Daniel Kiper
2018-07-09 16:29       ` Goffredo Baroncelli
2018-07-12 13:46   ` Daniel Kiper
2018-07-18  6:24     ` Goffredo Baroncelli
2018-09-03 12:52       ` Daniel Kiper
2018-05-16 18:48 [PATCH V4] Add support for BTRFS raid5/6 to GRUB Goffredo Baroncelli
2018-05-16 18:48 ` [PATCH 1/9] btrfs: add support for reading a filesystem with a RAID 5 or RAID 6 profile Goffredo Baroncelli
2018-05-30 10:07   ` Daniel Kiper
2018-06-01 18:50     ` Goffredo Baroncelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=680f897a-c0d1-f61e-65a3-78e1483e15a8@gmail.com \
    --to=kreijack@gmail.com \
    --cc=grub-devel@gnu.org \
    --cc=kreijack@inwind.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).