summaryrefslogtreecommitdiffstats
path: root/drivers/md/linear.c
diff options
context:
space:
mode:
authorSandeep K Sinha <sandeepksinha@gmail.com>2009-06-16 16:57:08 +1000
committerNeilBrown <neilb@suse.de>2009-06-16 16:57:08 +1000
commitaece3d1f40879759f641dfbfdbb9e2593adeb43c (patch)
tree0264ac8e02f4d08472c11b04305f8c39695d9007 /drivers/md/linear.c
parent4db7cdc859f56ecf0a186e0cfb238b5bb3af2efb (diff)
downloadop-kernel-dev-aece3d1f40879759f641dfbfdbb9e2593adeb43c.zip
op-kernel-dev-aece3d1f40879759f641dfbfdbb9e2593adeb43c.tar.gz
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>
Diffstat (limited to 'drivers/md/linear.c')
-rw-r--r--drivers/md/linear.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 529a3d3..9b02a73 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -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;
}
/**
OpenPOWER on IntegriCloud