Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: waxhead <waxhead@dirtcellar.net>
To: louis@waffle.tech, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: balance RAID1/RAID10 mirror selection
Date: Fri, 16 Oct 2020 19:21:59 +0200	[thread overview]
Message-ID: <c06268b1-a504-38bd-8cca-e9172997aef6@dirtcellar.net> (raw)
In-Reply-To: <8541d6d7a63e470b9f4c22ba95cd64fc@waffle.tech>

louis@waffle.tech wrote:
> 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 ==
> 

I am just a regular user of BTRFS, but the btrfs_fs_info structure 
contains a substructure (dirty_metadata_bytes).

Assuming that writing data leads to a dirty metadata bytes being set to 
non-zero would not something along the lines of this potentially be better?

if(fs_info->dirty_metadata_bytes) atomic_inc_return(&rr_counter);
prefered_mirror = first + (rr_counter+current->pid) % num_stripes;

My knowledge of BTRFS code is near zero and I should know better than 
posting "code" here, but I can't resist getting my point across. There 
must be a simple way to improve slightly over a regular rr scheme.

  parent reply	other threads:[~2020-10-16 17:22 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 [this message]
2020-10-23  7:38 ` Wang Yugui
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=c06268b1-a504-38bd-8cca-e9172997aef6@dirtcellar.net \
    --to=waxhead@dirtcellar.net \
    --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