提交 aece3d1f 编写于 作者: S Sandeep K Sinha 提交者: NeilBrown

md: Binary search in linear raid

Replace the linear search with binary search in which_dev.
Signed-off-by: NSandeep K Sinha <sandeepksinha@gmail.com>
Signed-off-by: NNeilBrown <neilb@suse.de>
上级 4db7cdc8
...@@ -27,14 +27,26 @@ ...@@ -27,14 +27,26 @@
*/ */
static inline dev_info_t *which_dev(mddev_t *mddev, sector_t sector) static inline dev_info_t *which_dev(mddev_t *mddev, sector_t sector)
{ {
dev_info_t *hash; int lo, mid, hi;
linear_conf_t *conf = mddev->private; linear_conf_t *conf = mddev->private;
hash = conf->disks; lo = 0;
hi = mddev->raid_disks - 1;
while (sector >= hash->end_sector) /*
hash++; * Binary Search
return hash; */
while (hi > lo) {
mid = (hi + lo) / 2;
if (sector < conf->disks[mid].end_sector)
hi = mid;
else
lo = mid + 1;
}
return conf->disks + lo;
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册