md/raid1: factor out helpers to choose the best rdev from read_balance()
authorYu Kuai <yukuai3@huawei.com>
Thu, 29 Feb 2024 09:57:14 +0000 (17:57 +0800)
committerSong Liu <song@kernel.org>
Fri, 1 Mar 2024 06:49:46 +0000 (22:49 -0800)
commit0091c5a269eca7ab0e057c3083804daed9997f08
tree9f9f9f24cb0ece6c0e0063650d3ef69e9e6e4586
parentba58f57fdf98af642c57654599823640ffe8334c
md/raid1: factor out helpers to choose the best rdev from read_balance()

The way that best rdev is chosen:

1) If the read is sequential from one rdev:
 - if rdev is rotational, use this rdev;
 - if rdev is non-rotational, use this rdev until total read length
   exceed disk opt io size;

2) If the read is not sequential:
 - if there is idle disk, use it, otherwise:
 - if the array has non-rotational disk, choose the rdev with minimal
   inflight IO;
 - if all the underlaying disks are rotational disk, choose the rdev
   with closest IO;

There are no functional changes, just to make code cleaner and prepare
for following refactor.

Co-developed-by: Paul Luse <paul.e.luse@linux.intel.com>
Signed-off-by: Paul Luse <paul.e.luse@linux.intel.com>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240229095714.926789-12-yukuai1@huaweicloud.com
drivers/md/raid1.c