]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/md/raid0.c
md: make devices disappear when they are no longer needed.
[mv-sheeva.git] / drivers / md / raid0.c
index 6e85e88bbae9103f2d4059e8cb6f3d6a574be2c9..c605ba8055863d2d0ede52e9fe7e9c4e374bd9d3 100644 (file)
@@ -57,7 +57,6 @@ static int create_strip_zones (mddev_t *mddev)
        sector_t min_spacing;
        raid0_conf_t *conf = mddev_to_conf(mddev);
        mdk_rdev_t *smallest, *rdev1, *rdev2, *rdev;
-       struct list_head *tmp1, *tmp2;
        struct strip_zone *zone;
        int cnt;
        char b[BDEVNAME_SIZE];
@@ -67,11 +66,11 @@ static int create_strip_zones (mddev_t *mddev)
         */
        conf->nr_strip_zones = 0;
  
-       rdev_for_each(rdev1, tmp1, mddev) {
+       list_for_each_entry(rdev1, &mddev->disks, same_set) {
                printk(KERN_INFO "raid0: looking at %s\n",
                        bdevname(rdev1->bdev,b));
                c = 0;
-               rdev_for_each(rdev2, tmp2, mddev) {
+               list_for_each_entry(rdev2, &mddev->disks, same_set) {
                        printk(KERN_INFO "raid0:   comparing %s(%llu)",
                               bdevname(rdev1->bdev,b),
                               (unsigned long long)rdev1->size);
@@ -120,7 +119,7 @@ static int create_strip_zones (mddev_t *mddev)
        cnt = 0;
        smallest = NULL;
        zone->dev = conf->devlist;
-       rdev_for_each(rdev1, tmp1, mddev) {
+       list_for_each_entry(rdev1, &mddev->disks, same_set) {
                int j = rdev1->raid_disk;
 
                if (j < 0 || j >= mddev->raid_disks) {
@@ -213,16 +212,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; j<conf->nr_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,10 +264,9 @@ 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;
 
        if (mddev->chunk_size == 0) {
                printk(KERN_ERR "md/raid0: non-zero chunk size required.\n");
@@ -294,54 +292,54 @@ static int raid0_run (mddev_t *mddev)
 
        /* calculate array device size */
        mddev->array_sectors = 0;
-       rdev_for_each(rdev, tmp, mddev)
+       list_for_each_entry(rdev, &mddev->disks, same_set)
                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 +433,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];
        }