All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: kreijack@inwind.it
Cc: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/4] btrfs: add support for 3-copy replication (raid1c3)
Date: Tue, 17 Jul 2018 18:00:49 +0200	[thread overview]
Message-ID: <20180717160049.GD3126@twin.jikos.cz> (raw)
In-Reply-To: <16e66925-bf9e-57d6-b6c0-a8b03c8d38c9@libero.it>

On Fri, Jul 13, 2018 at 11:02:03PM +0200, Goffredo Baroncelli wrote:
> As general comment, good to hear that something is moving around raid5/6 + write hole and multiple mirroring.
> However I am guessing if this is time to simplify the RAID code. There are a lot of "if" which could be avoided using 
> the values stored in the array "btrfs_raid_array[]".

I absolutely agree and had the same impression during implementing the
feature. For this patchset I did only a minimal prep work, the
suggestions you give below make sense to me.

Enhancing the table would make a lot of code go away and just use one
formula to calculate the results that are now opencoded. I'll be going
through the raid code so I'll get to the cleanups eventually.

> Below some comments:

> > @@ -5075,6 +5093,8 @@ static inline int btrfs_chunk_max_errors(struct map_lookup *map)
> >  			 BTRFS_BLOCK_GROUP_RAID5 |
> >  			 BTRFS_BLOCK_GROUP_DUP)) {
> >  		max_errors = 1;
> > +	} else if (map->type & BTRFS_BLOCK_GROUP_RAID1C3) {
> > +		max_errors = 2;
> >  	} else if (map->type & BTRFS_BLOCK_GROUP_RAID6) {
> >  		max_errors = 2;
> >  	} else {
> 
> Even in this case the ifs above could be replaced with something like:
> 
> 	index = btrfs_bg_flags_to_raid_index(map->type)
> 	max_errors = btrfs_raid_array[index].ncopies-1;

There's .tolerated_failures that should equal ncopies - 1 in general,
but does not for DUP so the semantics of the function and caller needs
to be verified.

  reply	other threads:[~2018-07-17 16:34 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 18:46 [PATCH 0/4] 3- and 4- copy RAID1 David Sterba
2018-07-13 18:46 ` [PATCH] btrfs-progs: add support for raid1c3 and raid1c4 David Sterba
2018-07-13 18:46 ` [PATCH 1/4] btrfs: refactor block group replication factor calculation to a helper David Sterba
2018-07-13 18:46 ` [PATCH 2/4] btrfs: add support for 3-copy replication (raid1c3) David Sterba
2018-07-13 21:02   ` Goffredo Baroncelli
2018-07-17 16:00     ` David Sterba [this message]
2018-07-13 18:46 ` [PATCH 3/4] btrfs: add support for 4-copy replication (raid1c4) David Sterba
2018-07-13 18:46 ` [PATCH 4/4] btrfs: add incompatibility bit for extended raid features David Sterba
2018-07-15 14:37 ` [PATCH 0/4] 3- and 4- copy RAID1 waxhead
2018-07-16 18:29   ` Goffredo Baroncelli
2018-07-16 18:49     ` Austin S. Hemmelgarn
2018-07-17 21:12     ` Duncan
2018-07-18  5:59       ` Goffredo Baroncelli
2018-07-18  7:20         ` Duncan
2018-07-18  8:39           ` Duncan
2018-07-18 12:45             ` Austin S. Hemmelgarn
2018-07-18 12:50             ` Hugo Mills
2018-07-19 21:22               ` waxhead
2018-07-18 12:50           ` Austin S. Hemmelgarn
2018-07-18 19:42           ` Goffredo Baroncelli
2018-07-19 11:43             ` Austin S. Hemmelgarn
2018-07-19 17:29               ` Goffredo Baroncelli
2018-07-19 19:10                 ` Austin S. Hemmelgarn
2018-07-20 17:13                   ` Goffredo Baroncelli
2018-07-20 18:33                     ` Austin S. Hemmelgarn
2018-07-20  5:17             ` Andrei Borzenkov
2018-07-20 17:16               ` Goffredo Baroncelli
2018-07-20 18:38                 ` Andrei Borzenkov
2018-07-20 18:41                   ` Hugo Mills
2018-07-20 18:46                     ` Austin S. Hemmelgarn
2018-07-16 21:51   ` waxhead
2018-07-15 14:46 ` Hugo Mills
2018-07-19  7:27 ` Qu Wenruo
2018-07-19 11:47   ` Austin S. Hemmelgarn
2018-07-20 16:42     ` David Sterba
2018-07-20 16:35   ` David Sterba

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=20180717160049.GD3126@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=dsterba@suse.com \
    --cc=kreijack@inwind.it \
    --cc=linux-btrfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.