From 019c4e2f3e02aac4b44003913b54ca4b332e4371 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 9 Jan 2009 08:31:06 +1100 Subject: md: raid0: Represent device offset in sectors. Rename zone->dev_offset to zone->dev_start to make sure all users have been converted. Signed-off-by: Andre Noll Signed-off-by: NeilBrown --- include/linux/raid/raid0.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/linux/raid/raid0.h') diff --git a/include/linux/raid/raid0.h b/include/linux/raid/raid0.h index 1b2dda035f8..61c3d29dc15 100644 --- a/include/linux/raid/raid0.h +++ b/include/linux/raid/raid0.h @@ -6,7 +6,7 @@ struct strip_zone { sector_t zone_offset; /* Zone offset in md_dev */ - sector_t dev_offset; /* Zone offset in real dev */ + sector_t dev_start; /* Zone offset in real dev (in sectors) */ sector_t size; /* Zone size */ int nb_dev; /* # of devices attached to the zone */ mdk_rdev_t **dev; /* Devices attached to the zone */ -- cgit v1.2.3-70-g09d2 From 6199d3db0fc34f8ada895879d04a353a6ae632bc Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 9 Jan 2009 08:31:07 +1100 Subject: md: raid0: Represent zone->zone_offset in sectors. For the same reason as in the previous patch, rename it from zone_offset to zone_start. Signed-off-by: Andre Noll Signed-off-by: NeilBrown --- drivers/md/raid0.c | 12 ++++++------ include/linux/raid/raid0.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'include/linux/raid/raid0.h') diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index b860536dc89..6e12a358f36 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -155,7 +155,7 @@ static int create_strip_zones (mddev_t *mddev) } zone->nb_dev = cnt; zone->size = smallest->size * cnt; - zone->zone_offset = 0; + zone->zone_start = 0; current_offset = smallest->size; curr_zone_offset = zone->size; @@ -194,7 +194,7 @@ static int create_strip_zones (mddev_t *mddev) printk("raid0: zone->nb_dev: %d, size: %llu\n", zone->nb_dev, (unsigned long long)zone->size); - zone->zone_offset = curr_zone_offset; + zone->zone_start = curr_zone_offset * 2; curr_zone_offset += zone->size; current_offset = smallest->size; @@ -437,14 +437,14 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio) zone = conf->hash_table[x]; } - while (sector / 2 >= (zone->zone_offset + zone->size)) + while (sector / 2 >= (zone->zone_start / 2 + zone->size)) zone++; sect_in_chunk = bio->bi_sector & (chunk_sects - 1); { - sector_t x = (sector - zone->zone_offset * 2) >> chunksect_bits; + sector_t x = (sector - zone->zone_start) >> chunksect_bits; sector_div(x, zone->nb_dev); chunk = x; @@ -489,8 +489,8 @@ static void raid0_status (struct seq_file *seq, mddev_t *mddev) seq_printf(seq, "%s/", bdevname( conf->strip_zone[j].dev[k]->bdev,b)); - seq_printf(seq, "] zo=%d ds=%d s=%d\n", - conf->strip_zone[j].zone_offset, + seq_printf(seq, "] zs=%d ds=%d s=%d\n", + conf->strip_zone[j].zone_start, conf->strip_zone[j].dev_start, conf->strip_zone[j].size); } diff --git a/include/linux/raid/raid0.h b/include/linux/raid/raid0.h index 61c3d29dc15..eaf4f6ac55f 100644 --- a/include/linux/raid/raid0.h +++ b/include/linux/raid/raid0.h @@ -5,7 +5,7 @@ struct strip_zone { - sector_t zone_offset; /* Zone offset in md_dev */ + sector_t zone_start; /* Zone offset in md_dev (in sectors) */ sector_t dev_start; /* Zone offset in real dev (in sectors) */ sector_t size; /* Zone size */ int nb_dev; /* # of devices attached to the zone */ -- cgit v1.2.3-70-g09d2 From 83838ed87898e0a8ff8dbf001e54e6c017f0a011 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 9 Jan 2009 08:31:07 +1100 Subject: md: raid0: Represent the size of strip zones in sectors. This completes the block -> sector conversion of struct strip_zone. Signed-off-by: Andre Noll Signed-off-by: NeilBrown --- drivers/md/raid0.c | 26 +++++++++++++------------- include/linux/raid/raid0.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'include/linux/raid/raid0.h') diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index c759436b5d8..6e85e88bbae 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -156,11 +156,11 @@ static int create_strip_zones (mddev_t *mddev) goto abort; } zone->nb_dev = cnt; - zone->size = smallest->size * cnt; + zone->sectors = smallest->size * cnt * 2; zone->zone_start = 0; current_start = smallest->size * 2; - curr_zone_start = zone->size * 2; + curr_zone_start = zone->sectors; /* now do the other zones */ for (i = 1; i < conf->nr_strip_zones; i++) @@ -193,12 +193,12 @@ static int create_strip_zones (mddev_t *mddev) } zone->nb_dev = c; - zone->size = (smallest->size - current_start / 2) * c; - printk(KERN_INFO "raid0: zone->nb_dev: %d, size: %llu\n", - zone->nb_dev, (unsigned long long)zone->size); + zone->sectors = (smallest->size * 2 - current_start) * c; + printk(KERN_INFO "raid0: zone->nb_dev: %d, sectors: %llu\n", + zone->nb_dev, (unsigned long long)zone->sectors); zone->zone_start = curr_zone_start; - curr_zone_start += zone->size * 2; + curr_zone_start += zone->sectors; current_start = smallest->size * 2; printk(KERN_INFO "raid0: current zone start: %llu\n", @@ -220,7 +220,7 @@ static int create_strip_zones (mddev_t *mddev) sector_t sz = 0; for (j=i; jnr_strip_zones-1 && sz < min_spacing ; j++) - sz += conf->strip_zone[j].size; + sz += conf->strip_zone[j].sectors / 2; if (sz >= min_spacing && sz < conf->hash_spacing) conf->hash_spacing = sz; } @@ -325,13 +325,13 @@ static int raid0_run (mddev_t *mddev) conf->hash_table = kmalloc (sizeof (struct strip_zone *)*nb_zone, GFP_KERNEL); if (!conf->hash_table) goto out_free_conf; - size = conf->strip_zone[cur].size; + size = conf->strip_zone[cur].sectors / 2; conf->hash_table[0] = conf->strip_zone + cur; for (i=1; i< nb_zone; i++) { while (size <= conf->hash_spacing) { cur++; - size += conf->strip_zone[cur].size; + size += conf->strip_zone[cur].sectors / 2; } size -= conf->hash_spacing; conf->hash_table[i] = conf->strip_zone + cur; @@ -439,10 +439,10 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio) sector_div(x, (u32)conf->hash_spacing); zone = conf->hash_table[x]; } - - while (sector / 2 >= (zone->zone_start / 2 + zone->size)) + + while (sector >= zone->zone_start + zone->sectors) zone++; - + sect_in_chunk = bio->bi_sector & (chunk_sects - 1); @@ -495,7 +495,7 @@ static void raid0_status (struct seq_file *seq, mddev_t *mddev) seq_printf(seq, "] zs=%d ds=%d s=%d\n", conf->strip_zone[j].zone_start, conf->strip_zone[j].dev_start, - conf->strip_zone[j].size); + conf->strip_zone[j].sectors); } #endif seq_printf(seq, " %dk chunks", mddev->chunk_size/1024); diff --git a/include/linux/raid/raid0.h b/include/linux/raid/raid0.h index eaf4f6ac55f..c12521d027e 100644 --- a/include/linux/raid/raid0.h +++ b/include/linux/raid/raid0.h @@ -7,7 +7,7 @@ struct strip_zone { sector_t zone_start; /* Zone offset in md_dev (in sectors) */ sector_t dev_start; /* Zone offset in real dev (in sectors) */ - sector_t size; /* Zone size */ + sector_t sectors; /* Zone size in sectors */ int nb_dev; /* # of devices attached to the zone */ mdk_rdev_t **dev; /* Devices attached to the zone */ }; -- cgit v1.2.3-70-g09d2 From ccacc7d2cf03114a24ab903f710118e9e5d43273 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 9 Jan 2009 08:31:08 +1100 Subject: md: raid0: make hash_spacing and preshift sector-based. This patch renames the hash_spacing and preshift members of struct raid0_private_data to spacing and sector_shift respectively and changes the semantics as follows: We always have spacing = 2 * hash_spacing. In case sizeof(sector_t) > sizeof(u32) we also have sector_shift = preshift + 1 while sector_shift = preshift = 0 otherwise. Note that the values of nb_zone and zone are unaffected by these changes because in the sector_div() preceeding the assignement of these two variables both arguments double. Signed-off-by: Andre Noll Signed-off-by: NeilBrown --- drivers/md/raid0.c | 58 +++++++++++++++++++++++----------------------- include/linux/raid/raid0.h | 4 ++-- 2 files changed, 31 insertions(+), 31 deletions(-) (limited to 'include/linux/raid/raid0.h') diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 6e85e88bbae..90f5b24f6e6 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -213,16 +213,16 @@ static int create_strip_zones (mddev_t *mddev) * strip though as it's size has no bearing on the efficacy of the hash * table. */ - conf->hash_spacing = curr_zone_start / 2; - min_spacing = curr_zone_start / 2; + conf->spacing = curr_zone_start; + min_spacing = curr_zone_start; sector_div(min_spacing, PAGE_SIZE/sizeof(struct strip_zone*)); for (i=0; i < conf->nr_strip_zones-1; i++) { - sector_t sz = 0; - for (j=i; jnr_strip_zones-1 && - sz < min_spacing ; j++) - sz += conf->strip_zone[j].sectors / 2; - if (sz >= min_spacing && sz < conf->hash_spacing) - conf->hash_spacing = sz; + sector_t s = 0; + for (j = i; j < conf->nr_strip_zones - 1 && + s < min_spacing; j++) + s += conf->strip_zone[j].sectors; + if (s >= min_spacing && s < conf->spacing) + conf->spacing = s; } mddev->queue->unplug_fn = raid0_unplug; @@ -265,7 +265,7 @@ static int raid0_mergeable_bvec(struct request_queue *q, static int raid0_run (mddev_t *mddev) { unsigned cur=0, i=0, nb_zone; - s64 size; + s64 sectors; raid0_conf_t *conf; mdk_rdev_t *rdev; struct list_head *tmp; @@ -297,51 +297,51 @@ static int raid0_run (mddev_t *mddev) rdev_for_each(rdev, tmp, mddev) mddev->array_sectors += rdev->size * 2; - printk("raid0 : md_size is %llu blocks.\n", - (unsigned long long)mddev->array_sectors / 2); - printk("raid0 : conf->hash_spacing is %llu blocks.\n", - (unsigned long long)conf->hash_spacing); + printk(KERN_INFO "raid0 : md_size is %llu sectors.\n", + (unsigned long long)mddev->array_sectors); + printk(KERN_INFO "raid0 : conf->spacing is %llu sectors.\n", + (unsigned long long)conf->spacing); { - sector_t s = mddev->array_sectors / 2; - sector_t space = conf->hash_spacing; + sector_t s = mddev->array_sectors; + sector_t space = conf->spacing; int round; - conf->preshift = 0; + conf->sector_shift = 0; if (sizeof(sector_t) > sizeof(u32)) { /*shift down space and s so that sector_div will work */ while (space > (sector_t) (~(u32)0)) { s >>= 1; space >>= 1; s += 1; /* force round-up */ - conf->preshift++; + conf->sector_shift++; } } round = sector_div(s, (u32)space) ? 1 : 0; nb_zone = s + round; } - printk("raid0 : nb_zone is %d.\n", nb_zone); + printk(KERN_INFO "raid0 : nb_zone is %d.\n", nb_zone); - printk("raid0 : Allocating %Zd bytes for hash.\n", + printk(KERN_INFO "raid0 : Allocating %zu bytes for hash.\n", nb_zone*sizeof(struct strip_zone*)); conf->hash_table = kmalloc (sizeof (struct strip_zone *)*nb_zone, GFP_KERNEL); if (!conf->hash_table) goto out_free_conf; - size = conf->strip_zone[cur].sectors / 2; + sectors = conf->strip_zone[cur].sectors; conf->hash_table[0] = conf->strip_zone + cur; for (i=1; i< nb_zone; i++) { - while (size <= conf->hash_spacing) { + while (sectors <= conf->spacing) { cur++; - size += conf->strip_zone[cur].sectors / 2; + sectors += conf->strip_zone[cur].sectors; } - size -= conf->hash_spacing; + sectors -= conf->spacing; conf->hash_table[i] = conf->strip_zone + cur; } - if (conf->preshift) { - conf->hash_spacing >>= conf->preshift; - /* round hash_spacing up so when we divide by it, we + if (conf->sector_shift) { + conf->spacing >>= conf->sector_shift; + /* round spacing up so when we divide by it, we * err on the side of too-low, which is safest */ - conf->hash_spacing++; + conf->spacing++; } /* calculate the max read-ahead size. @@ -435,8 +435,8 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio) { - sector_t x = sector >> (conf->preshift + 1); - sector_div(x, (u32)conf->hash_spacing); + sector_t x = sector >> conf->sector_shift; + sector_div(x, (u32)conf->spacing); zone = conf->hash_table[x]; } diff --git a/include/linux/raid/raid0.h b/include/linux/raid/raid0.h index c12521d027e..fd42aa87c39 100644 --- a/include/linux/raid/raid0.h +++ b/include/linux/raid/raid0.h @@ -19,8 +19,8 @@ struct raid0_private_data mdk_rdev_t **devlist; /* lists of rdevs, pointed to by strip_zone->dev */ int nr_strip_zones; - sector_t hash_spacing; - int preshift; /* shift this before divide by hash_spacing */ + sector_t spacing; + int sector_shift; /* shift this before divide by spacing */ }; typedef struct raid0_private_data raid0_conf_t; -- cgit v1.2.3-70-g09d2