mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-12 00:38:55 +00:00
md: Binary search in linear raid
Replace the linear search with binary search in which_dev. Signed-off-by: Sandeep K Sinha <sandeepksinha@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
4db7cdc859
commit
aece3d1f40
@ -27,14 +27,26 @@
|
||||
*/
|
||||
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;
|
||||
|
||||
hash = conf->disks;
|
||||
lo = 0;
|
||||
hi = mddev->raid_disks - 1;
|
||||
|
||||
while (sector >= hash->end_sector)
|
||||
hash++;
|
||||
return hash;
|
||||
/*
|
||||
* Binary Search
|
||||
*/
|
||||
|
||||
while (hi > lo) {
|
||||
|
||||
mid = (hi + lo) / 2;
|
||||
if (sector < conf->disks[mid].end_sector)
|
||||
hi = mid;
|
||||
else
|
||||
lo = mid + 1;
|
||||
}
|
||||
|
||||
return conf->disks + lo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user