From: wangyugui <wangyugui@e16-tech.com>
To: linux-btrfs@vger.kernel.org
Cc: kreijack@libero.it, wangyugui <wangyugui@e16-tech.com>
Subject: [PATCH 3/4] btrfs: tier-aware mirror path select
Date: Thu, 29 Oct 2020 13:35:55 +0800 [thread overview]
Message-ID: <20201029053556.10619-4-wangyugui@e16-tech.com> (raw)
In-Reply-To: <20201029053556.10619-1-wangyugui@e16-tech.com>
This feature help the read performance, so it is enabled even if tier=off.
Signed-off-by: wangyugui <wangyugui@e16-tech.com>
---
fs/btrfs/volumes.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 2a422ac..b65f916 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5568,6 +5568,11 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info,
int tolerance;
struct btrfs_device *srcdev;
+ /* tier-aware even if tier=off */
+ int top_tier_num_stripes = 0;
+ int top_tier_stripe_idxs[4]; /* RAID1C4 */
+ u8 top_tier_score = 0;
+
ASSERT((map->type &
(BTRFS_BLOCK_GROUP_RAID1_MASK | BTRFS_BLOCK_GROUP_RAID10)));
@@ -5576,7 +5581,21 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info,
else
num_stripes = map->num_stripes;
- preferred_mirror = first + current->pid % num_stripes;
+ for (i = 0; i < num_stripes; ++i)
+ {
+ if (map->stripes[i].dev->tier_score > top_tier_score)
+ {
+ top_tier_score = map->stripes[i].dev->tier_score;
+ top_tier_stripe_idxs[0] = i;
+ top_tier_num_stripes = 1;
+ }
+ else if (map->stripes[i].dev->tier_score == top_tier_score)
+ {
+ top_tier_stripe_idxs[top_tier_num_stripes] = i;
+ top_tier_num_stripes++;
+ }
+ }
+ preferred_mirror = first + top_tier_stripe_idxs[current->pid % top_tier_num_stripes];
if (dev_replace_is_ongoing &&
fs_info->dev_replace.cont_reading_from_srcdev_mode ==
--
2.29.1
next prev parent reply other threads:[~2020-10-29 7:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 5:35 [PATCH 0/4] btrfs: basic tier support wangyugui
2020-10-29 5:35 ` [PATCH 1/4] btrfs: add tier score to device wangyugui
2020-10-29 5:35 ` [PATCH 2/4] btrfs: tiering data and metadata wangyugui
2020-10-29 5:35 ` wangyugui [this message]
2020-10-29 5:35 ` [PATCH 4/4] btrfs: tier-aware free space cacl wangyugui
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=20201029053556.10619-4-wangyugui@e16-tech.com \
--to=wangyugui@e16-tech.com \
--cc=kreijack@libero.it \
--cc=linux-btrfs@vger.kernel.org \
/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