Hi, This patch replaces the linear search in which_dev to binary search. Author: Sandeep K Sinha <sandeepksinha@xxxxxxxxx> Date: Tue May 19 16:14:15 2009 +0530 Replaces the linear search to binary search in which_dev. diff --git a/drivers/md/linear.c b/drivers/md/linear.c index f7f6bb9..9ad6ec4 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_to_conf(mddev); + + lo = 0; + hi = mddev->raid_disks - 1; - hash = conf->disks; + /* + * Binary Search + */ + + while (hi > lo) { + + mid = (hi + lo) / 2; + if (sector < conf->disks[mid].end_sector) + hi = mid; + else + lo = mid + 1; + } - while (sector >= hash->end_sector) - hash++; - return hash; + return conf->disks + lo; } /** -- Regards, Sandeep. “To learn is to change. Education is a process that changes the learner.” -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html