md: centralize ->array_sectors modifications
authorDan Williams <dan.j.williams@intel.com>
Tue, 31 Mar 2009 03:59:03 +0000 (14:59 +1100)
committerDan Williams <dan.j.williams@intel.com>
Tue, 31 Mar 2009 03:59:03 +0000 (14:59 +1100)
Get personalities out of the business of directly modifying
->array_sectors.  Lays groundwork to introduce policy on when
->array_sectors can be modified.

Reviewed-by: Andre Noll <maan@systemlinux.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/md/faulty.c
drivers/md/linear.c
drivers/md/md.c
drivers/md/md.h
drivers/md/multipath.c
drivers/md/raid0.c
drivers/md/raid1.c
drivers/md/raid10.c
drivers/md/raid5.c

index d76c87f2a8318f0ef44100ae8f8d65e7843d311c..8695809b24b05f049c13a3dc667bf2a02d9b4ba6 100644 (file)
@@ -312,7 +312,7 @@ static int run(mddev_t *mddev)
        list_for_each_entry(rdev, &mddev->disks, same_set)
                conf->rdev = rdev;
 
-       mddev->array_sectors = faulty_size(mddev, 0, 0);
+       md_set_array_sectors(mddev, faulty_size(mddev, 0, 0));
        mddev->private = conf;
 
        reconfig(mddev, mddev->layout, -1);
index b6bb976123daaa0cf765818f07e5c6a1549570a0..7a36e38393a1e9ff24defd03c756138a9f5da903 100644 (file)
@@ -263,7 +263,7 @@ static int linear_run (mddev_t *mddev)
        if (!conf)
                return 1;
        mddev->private = conf;
-       mddev->array_sectors = linear_size(mddev, 0, 0);
+       md_set_array_sectors(mddev, linear_size(mddev, 0, 0));
 
        blk_queue_merge_bvec(mddev->queue, linear_mergeable_bvec);
        mddev->queue->unplug_fn = linear_unplug;
@@ -297,7 +297,7 @@ static int linear_add(mddev_t *mddev, mdk_rdev_t *rdev)
        newconf->prev = mddev_to_conf(mddev);
        mddev->private = newconf;
        mddev->raid_disks++;
-       mddev->array_sectors = linear_size(mddev, 0, 0);
+       md_set_array_sectors(mddev, linear_size(mddev, 0, 0));
        set_capacity(mddev->gendisk, mddev->array_sectors);
        return 0;
 }
index 0689d89d263c21eb2be4df5b6e29e866fef9511e..76ba69b31d6a1f3e1fec28cb8acb319e37c63a1b 100644 (file)
@@ -4977,6 +4977,12 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
        return 0;
 }
 
+void md_set_array_sectors(mddev_t *mddev, sector_t array_sectors)
+{
+       mddev->array_sectors = array_sectors;
+}
+EXPORT_SYMBOL(md_set_array_sectors);
+
 static int update_size(mddev_t *mddev, sector_t num_sectors)
 {
        mdk_rdev_t *rdev;
index d2c50da1ae7fd47f874a071258b6859498addba8..ce89dda24074ed150d3d78f65952438c55e3f5d7 100644 (file)
@@ -430,3 +430,4 @@ extern void md_do_sync(mddev_t *mddev);
 extern void md_new_event(mddev_t *mddev);
 extern int md_allow_write(mddev_t *mddev);
 extern void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev);
+extern void md_set_array_sectors(mddev_t *mddev, sector_t array_sectors);
index a3f6d8668bb35af437514ea851dfee8173e3f96b..41ced0cbe823c7275cc2f79172cc9913385fcd2f 100644 (file)
@@ -510,7 +510,7 @@ static int multipath_run (mddev_t *mddev)
        /*
         * Ok, everything is just fine now
         */
-       mddev->array_sectors = multipath_size(mddev, 0, 0);
+       md_set_array_sectors(mddev, multipath_size(mddev, 0, 0));
 
        mddev->queue->unplug_fn = multipath_unplug;
        mddev->queue->backing_dev_info.congested_fn = multipath_congested;
index bb0df6a18443c4291235f96406668ff8cb3bb94a..6f7e538c8763434d67605ef5830e00cdacf81795 100644 (file)
@@ -306,7 +306,7 @@ static int raid0_run (mddev_t *mddev)
                goto out_free_conf;
 
        /* calculate array device size */
-       mddev->array_sectors = raid0_size(mddev, 0, 0);
+       md_set_array_sectors(mddev, raid0_size(mddev, 0, 0));
 
        printk(KERN_INFO "raid0 : md_size is %llu sectors.\n",
                (unsigned long long)mddev->array_sectors);
index a2a83b0d5a95fbcf3e320de16d77a2bbea851329..044116b53f7a2ef63d1fff9e8bad63bb79cc6ca1 100644 (file)
@@ -2059,7 +2059,7 @@ static int run(mddev_t *mddev)
        /*
         * Ok, everything is just fine now
         */
-       mddev->array_sectors = raid1_size(mddev, 0, 0);
+       md_set_array_sectors(mddev, raid1_size(mddev, 0, 0));
 
        mddev->queue->unplug_fn = raid1_unplug;
        mddev->queue->backing_dev_info.congested_fn = raid1_congested;
@@ -2124,7 +2124,7 @@ static int raid1_resize(mddev_t *mddev, sector_t sectors)
         * any io in the removed space completes, but it hardly seems
         * worth it.
         */
-       mddev->array_sectors = raid1_size(mddev, sectors, 0);
+       md_set_array_sectors(mddev, raid1_size(mddev, sectors, 0));
        set_capacity(mddev->gendisk, mddev->array_sectors);
        mddev->changed = 1;
        if (mddev->array_sectors > mddev->dev_sectors &&
index 5bf1b24ae802d9e64e5fe82534268d9865b5059d..ad153b24ea0de4bbee717a50b417b7716643126f 100644 (file)
@@ -2193,7 +2193,7 @@ static int run(mddev_t *mddev)
        /*
         * Ok, everything is just fine now
         */
-       mddev->array_sectors = raid10_size(mddev, 0, 0);
+       md_set_array_sectors(mddev, raid10_size(mddev, 0, 0));
        mddev->resync_max_sectors = mddev->array_sectors;
 
        mddev->queue->unplug_fn = raid10_unplug;
index 2cd619ff07614cef56d781f31ebd23c76bf76a54..2930fc26a852d94336acae8cf10a8c980a69c501 100644 (file)
@@ -4474,7 +4474,7 @@ static int run(mddev_t *mddev)
        mddev->queue->backing_dev_info.congested_data = mddev;
        mddev->queue->backing_dev_info.congested_fn = raid5_congested;
 
-       mddev->array_sectors = raid5_size(mddev, 0, 0);
+       md_set_array_sectors(mddev, raid5_size(mddev, 0, 0));
 
        blk_queue_merge_bvec(mddev->queue, raid5_mergeable_bvec);
 
@@ -4698,7 +4698,8 @@ static int raid5_resize(mddev_t *mddev, sector_t sectors)
         * worth it.
         */
        sectors &= ~((sector_t)mddev->chunk_size/512 - 1);
-       mddev->array_sectors = raid5_size(mddev, sectors, mddev->raid_disks);
+       md_set_array_sectors(mddev, raid5_size(mddev, sectors,
+                                              mddev->raid_disks));
        set_capacity(mddev->gendisk, mddev->array_sectors);
        mddev->changed = 1;
        if (sectors > mddev->dev_sectors && mddev->recovery_cp == MaxSector) {
@@ -4836,7 +4837,8 @@ static void end_reshape(raid5_conf_t *conf)
        if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) {
                mddev_t *mddev = conf->mddev;
 
-               mddev->array_sectors = raid5_size(mddev, 0, conf->raid_disks);
+               md_set_array_sectors(mddev, raid5_size(mddev, 0,
+                                                      conf->raid_disks));
                set_capacity(mddev->gendisk, mddev->array_sectors);
                mddev->changed = 1;
                conf->previous_raid_disks = conf->raid_disks;