public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Wang Yugui <wangyugui@e16-tech.com>
To: louis@waffle.tech
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: balance RAID1/RAID10 mirror selection
Date: Fri, 23 Oct 2020 15:38:15 +0800	[thread overview]
Message-ID: <20201023153814.643F.409509F4@e16-tech.com> (raw)
In-Reply-To: <8541d6d7a63e470b9f4c22ba95cd64fc@waffle.tech>

Hi, Louis Jencka

Can we move 'atomic_t rr_counter' into 'struct btrfs_fs_info' to
support multiple mounted btrfs filesystem?

Although 'readmirror feature (read_policy sysfs)'  is talked about, 
round-robin is a replacement for BTRFS_READ_POLICY_PID in most case, 
we no longer need BTRFS_READ_POLICY_PID ?

Best Regards
Wang Yugui (wangyugui@e16-tech.com)
2020/10/23

> Balance RAID1/RAID10 mirror selection via plain round-robin scheduling. This should roughly double throughput for large reads.
> 
> Signed-off-by: Louis Jencka <louis@waffle.tech>
> ---
>  fs/btrfs/volumes.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 58b9c419a..45c581d46 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -333,6 +333,9 @@ struct list_head * __attribute_const__ btrfs_get_fs_uuids(void)
>  	return &fs_uuids;
>  }
>  
> +/* Used for round-robin balancing RAID1/RAID10 reads. */
> +atomic_t rr_counter = ATOMIC_INIT(0);
> +
>  /*
>   * alloc_fs_devices - allocate struct btrfs_fs_devices
>   * @fsid:		if not NULL, copy the UUID to fs_devices::fsid
> @@ -5482,7 +5485,8 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info,
>  	else
>  		num_stripes = map->num_stripes;
>  
> -	preferred_mirror = first + current->pid % num_stripes;
> +	preferred_mirror = first +
> +	    (unsigned)atomic_inc_return(&rr_counter) % num_stripes;
>  
>  	if (dev_replace_is_ongoing &&
>  	    fs_info->dev_replace.cont_reading_from_srcdev_mode ==



  parent reply	other threads:[~2020-10-23  7:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16  5:59 [PATCH] btrfs: balance RAID1/RAID10 mirror selection louis
2020-10-16  7:15 ` Nikolay Borisov
2020-10-16  7:29   ` Qu Wenruo
2020-10-16 17:28     ` louis
2020-10-18  8:16       ` Anand Jain
2020-10-16 16:18   ` louis
2020-10-16 17:21 ` waxhead
2020-10-23  7:38 ` Wang Yugui [this message]
2020-10-23  7:42   ` Nikolay Borisov
2020-11-02 19:29     ` louis
2020-11-02 19:36       ` louis
2020-10-27 14:26   ` Wang Yugui

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=20201023153814.643F.409509F4@e16-tech.com \
    --to=wangyugui@e16-tech.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=louis@waffle.tech \
    /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