Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>,
	Qu Wenruo <wqu@suse.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 4/4] btrfs: use btrfs_raid_array[].ncopies in btrfs_num_copies()
Date: Fri, 13 May 2022 17:22:05 +0800	[thread overview]
Message-ID: <ace856f6-b1c0-6746-797e-af85ce6a0f0b@gmx.com> (raw)
In-Reply-To: <PH0PR04MB7416E0CEDDA84965B0FDD2919BCA9@PH0PR04MB7416.namprd04.prod.outlook.com>



On 2022/5/13 17:15, Johannes Thumshirn wrote:
> On 13/05/2022 10:34, Qu Wenruo wrote:
>>   	map = em->map_lookup;
>> -	if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1_MASK))
>> -		ret = map->num_stripes;
>> -	else if (map->type & BTRFS_BLOCK_GROUP_RAID10)
>> -		ret = map->sub_stripes;
>> +	index = btrfs_bg_flags_to_raid_index(map->type);
>> +
>> +	if (!(map->type & BTRFS_BLOCK_GROUP_RAID56_MASK))
>> +		/* Non-raid56, use their ncopies from btrfs_raid_array[]. */
>> +		ret = btrfs_raid_array[index].ncopies;
>>   	else if (map->type & BTRFS_BLOCK_GROUP_RAID5)
>>   		ret = 2;
>>   	else if (map->type & BTRFS_BLOCK_GROUP_RAID6)
>
> Here I'm not 100% sure. RAID10 used sub_stripes and now it's using ncopies.
> The code still produces the same result, as for RAID10 ncopies == sub_stripes,
> but semantically it's different (I think).

Since the objective of the code is the get the number of mirrors for the
chunk, sub_stripes is definitely not correct here.

Just imagine if we have RAID1C30 (sounds ugly I know), which is RAID1C3
first, then RAID0.

We should still have sub_stripes == 2, but ncopies == 3.

And the number of mirrors is definitely 3, not 2.

So it's the old code not correctly semantically.

Thanks,
Qu

  reply	other threads:[~2022-05-13  9:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13  8:34 [PATCH 0/4] btrfs: cleanups and preparation for the incoming RAID56J features Qu Wenruo
2022-05-13  8:34 ` [PATCH 1/4] btrfs: remove @dev_extent_len argument from scrub_stripe() function Qu Wenruo
2022-05-13  8:47   ` Johannes Thumshirn
2022-05-13  8:34 ` [PATCH 2/4] btrfs: use btrfs_chunk_max_errors() to replace weird tolerance calculation Qu Wenruo
2022-05-13  8:45   ` Johannes Thumshirn
2022-05-13  8:34 ` [PATCH 3/4] btrfs: use btrfs_raid_array[] to calculate the number of parity stripes Qu Wenruo
2022-05-13  8:56   ` Johannes Thumshirn
2022-05-13  8:34 ` [PATCH 4/4] btrfs: use btrfs_raid_array[].ncopies in btrfs_num_copies() Qu Wenruo
2022-05-13  9:15   ` Johannes Thumshirn
2022-05-13  9:22     ` Qu Wenruo [this message]
2022-05-13  9:24       ` Johannes Thumshirn
2022-05-13  9:33         ` Qu Wenruo
2022-05-13 11:38 ` [PATCH 0/4] btrfs: cleanups and preparation for the incoming RAID56J features David Sterba
2022-05-13 12:21   ` Qu Wenruo
2022-05-13 15:14 ` Forza
2022-05-13 22:58   ` Qu Wenruo
2022-06-15 11:45 ` 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=ace856f6-b1c0-6746-797e-af85ce6a0f0b@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /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