@@ -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 ==
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(-)