public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: balance RAID1/RAID10 mirror selection
@ 2020-10-16  5:59 louis
  2020-10-16  7:15 ` Nikolay Borisov
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: louis @ 2020-10-16  5:59 UTC (permalink / raw)
  To: linux-btrfs

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 ==

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-11-02 19:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox