All of lore.kernel.org
 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] btrfs: separate single stripe optimization into a dedicate branch
Date: Tue, 24 Jan 2023 17:45:40 +0800	[thread overview]
Message-ID: <30259d35-28e8-31db-c2f4-6d4eebe4ac80@gmx.com> (raw)
In-Reply-To: <8cb1628a-bf0f-57c5-551c-21ed3fe5a035@wdc.com>



On 2023/1/24 16:43, Johannes Thumshirn wrote:
> On 24.01.23 09:00, Qu Wenruo wrote:
>> +static int patch_single_stripe_for_replace(struct btrfs_fs_info *fs_info,
>> +					   struct btrfs_io_stripe *smap,
>> +					   int mirror_num, int ncopies)
>> +{
>> +	if (mirror_num > ncopies) {
>> +		if (mirror_num == ncopies + 1 &&
>> +		    btrfs_dev_replace_is_ongoing(&fs_info->dev_replace) &&
>> +		    fs_info->dev_replace.srcdev == smap->dev &&
>> +		    fs_info->dev_replace.tgtdev)
>> +			smap->dev = fs_info->dev_replace.tgtdev;
>> +		else
>> +			return -EINVAL;
>> +	}
> 
> If you'd reverse the above if statement and return early, you can save one
> level of indentation.

The problem is, the above one is way too complex.
Yes, we can go if (!(xxxx)), but I 'm not sure if that's any reader 
friendly...

> 
>> +	return 0;
>> +}
>> +
>> +static int map_single_stripe(struct btrfs_fs_info *fs_info,
>> +			     struct btrfs_io_stripe *smap,
>> +			     struct map_lookup *map,
>> +			     struct btrfs_io_geometry *geom,
>> +			     enum btrfs_map_op op,
>> +			     int mirror_num)
>> +{
>> +	enum btrfs_raid_types raid_index = btrfs_bg_flags_to_raid_index(map->type);
>> +	bool is_raid56 = map->type & BTRFS_BLOCK_GROUP_RAID56_MASK;
>> +	int data_stripes = nr_data_stripes(map);
>> +	int ncopies;
>> +	int target;
>> +	int rot;
>> +
>> +	/* For non-RAID56, just select the target stripe.*/
> 
> Why not have a RAID56 function and a non-RAID56 version?

That's a good advice!

Thanks,
Qu
> 
>> +	if (!is_raid56) {
>> +		/*
>> +		 * After BTRFS_STRIPE_LEN bytes, we need to forward @stripe_inc
>> +		 * stripes, and increase physical by (stripe_nr / @stripe_div) *
>> +		 * BTRFS_STRIPE_LEN bytes.
>> +		 *
>> +		 * The default values would handle SINGLE/DUP/RAID1*.
>> +		 * Only need to update to handle RAID0 and RAID10.
>> +		 */
> 

  reply	other threads:[~2023-01-24  9:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24  8:00 [PATCH] btrfs: separate single stripe optimization into a dedicate branch Qu Wenruo
2023-01-24  8:16 ` Christoph Hellwig
2023-01-24  8:18   ` Qu Wenruo
2023-01-24  8:43 ` Johannes Thumshirn
2023-01-24  9:45   ` Qu Wenruo [this message]
2023-01-24 15:41 ` kernel test robot
2023-01-24 15:41 ` kernel test robot

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=30259d35-28e8-31db-c2f4-6d4eebe4ac80@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 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.