diff options
author | NeilBrown <neilb@suse.de> | 2009-08-02 20:59:58 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-08-02 20:59:58 -0400 |
commit | 449aad3e25358812c43afc60918c5ad3819488e7 (patch) | |
tree | 45fab3b82fc1ed06959537a0801319045cf4c102 | |
parent | 64bd660b51b2da92e99a5e97349f6558349f11c5 (diff) |
md: Use revalidate_disk to effect changes in size of device.
As revalidate_disk calls check_disk_size_change, it will cause
any capacity change of a gendisk to be propagated to the blockdev
inode. So use that instead of mucking about with locks and
i_size_write.
Also add a call to revalidate_disk in do_md_run and a few other places
where the gendisk capacity is changed.
Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r-- | drivers/md/linear.c | 1 | ||||
-rw-r--r-- | drivers/md/md.c | 28 | ||||
-rw-r--r-- | drivers/md/raid1.c | 1 | ||||
-rw-r--r-- | drivers/md/raid5.c | 12 |
4 files changed, 9 insertions, 33 deletions
diff --git a/drivers/md/linear.c b/drivers/md/linear.c index 54c8677f1e59..5fe39c2a3d2b 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c | |||
@@ -257,6 +257,7 @@ static int linear_add(mddev_t *mddev, mdk_rdev_t *rdev) | |||
257 | rcu_assign_pointer(mddev->private, newconf); | 257 | rcu_assign_pointer(mddev->private, newconf); |
258 | md_set_array_sectors(mddev, linear_size(mddev, 0, 0)); | 258 | md_set_array_sectors(mddev, linear_size(mddev, 0, 0)); |
259 | set_capacity(mddev->gendisk, mddev->array_sectors); | 259 | set_capacity(mddev->gendisk, mddev->array_sectors); |
260 | revalidate_disk(mddev->gendisk); | ||
260 | call_rcu(&oldconf->rcu, free_conf); | 261 | call_rcu(&oldconf->rcu, free_conf); |
261 | return 0; | 262 | return 0; |
262 | } | 263 | } |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 52c988b072d0..5b98bea4ff9b 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -3741,17 +3741,8 @@ array_size_store(mddev_t *mddev, const char *buf, size_t len) | |||
3741 | 3741 | ||
3742 | mddev->array_sectors = sectors; | 3742 | mddev->array_sectors = sectors; |
3743 | set_capacity(mddev->gendisk, mddev->array_sectors); | 3743 | set_capacity(mddev->gendisk, mddev->array_sectors); |
3744 | if (mddev->pers) { | 3744 | if (mddev->pers) |
3745 | struct block_device *bdev = bdget_disk(mddev->gendisk, 0); | 3745 | revalidate_disk(mddev->gendisk); |
3746 | |||
3747 | if (bdev) { | ||
3748 | mutex_lock(&bdev->bd_inode->i_mutex); | ||
3749 | i_size_write(bdev->bd_inode, | ||
3750 | (loff_t)mddev->array_sectors << 9); | ||
3751 | mutex_unlock(&bdev->bd_inode->i_mutex); | ||
3752 | bdput(bdev); | ||
3753 | } | ||
3754 | } | ||
3755 | 3746 | ||
3756 | return len; | 3747 | return len; |
3757 | } | 3748 | } |
@@ -4241,6 +4232,7 @@ static int do_md_run(mddev_t * mddev) | |||
4241 | md_wakeup_thread(mddev->thread); | 4232 | md_wakeup_thread(mddev->thread); |
4242 | md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */ | 4233 | md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */ |
4243 | 4234 | ||
4235 | revalidate_disk(mddev->gendisk); | ||
4244 | mddev->changed = 1; | 4236 | mddev->changed = 1; |
4245 | md_new_event(mddev); | 4237 | md_new_event(mddev); |
4246 | sysfs_notify_dirent(mddev->sysfs_state); | 4238 | sysfs_notify_dirent(mddev->sysfs_state); |
@@ -5139,18 +5131,8 @@ static int update_size(mddev_t *mddev, sector_t num_sectors) | |||
5139 | return -ENOSPC; | 5131 | return -ENOSPC; |
5140 | } | 5132 | } |
5141 | rv = mddev->pers->resize(mddev, num_sectors); | 5133 | rv = mddev->pers->resize(mddev, num_sectors); |
5142 | if (!rv) { | 5134 | if (!rv) |
5143 | struct block_device *bdev; | 5135 | revalidate_disk(mddev->gendisk); |
5144 | |||
5145 | bdev = bdget_disk(mddev->gendisk, 0); | ||
5146 | if (bdev) { | ||
5147 | mutex_lock(&bdev->bd_inode->i_mutex); | ||
5148 | i_size_write(bdev->bd_inode, | ||
5149 | (loff_t)mddev->array_sectors << 9); | ||
5150 | mutex_unlock(&bdev->bd_inode->i_mutex); | ||
5151 | bdput(bdev); | ||
5152 | } | ||
5153 | } | ||
5154 | return rv; | 5136 | return rv; |
5155 | } | 5137 | } |
5156 | 5138 | ||
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 67e794d0097f..8726fd7ebce5 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -2134,6 +2134,7 @@ static int raid1_resize(mddev_t *mddev, sector_t sectors) | |||
2134 | return -EINVAL; | 2134 | return -EINVAL; |
2135 | set_capacity(mddev->gendisk, mddev->array_sectors); | 2135 | set_capacity(mddev->gendisk, mddev->array_sectors); |
2136 | mddev->changed = 1; | 2136 | mddev->changed = 1; |
2137 | revalidate_disk(mddev->gendisk); | ||
2137 | if (sectors > mddev->dev_sectors && | 2138 | if (sectors > mddev->dev_sectors && |
2138 | mddev->recovery_cp == MaxSector) { | 2139 | mddev->recovery_cp == MaxSector) { |
2139 | mddev->recovery_cp = mddev->dev_sectors; | 2140 | mddev->recovery_cp = mddev->dev_sectors; |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 2dc35b4c20ac..2b521ee67dfa 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -4858,6 +4858,7 @@ static int raid5_resize(mddev_t *mddev, sector_t sectors) | |||
4858 | return -EINVAL; | 4858 | return -EINVAL; |
4859 | set_capacity(mddev->gendisk, mddev->array_sectors); | 4859 | set_capacity(mddev->gendisk, mddev->array_sectors); |
4860 | mddev->changed = 1; | 4860 | mddev->changed = 1; |
4861 | revalidate_disk(mddev->gendisk); | ||
4861 | if (sectors > mddev->dev_sectors && mddev->recovery_cp == MaxSector) { | 4862 | if (sectors > mddev->dev_sectors && mddev->recovery_cp == MaxSector) { |
4862 | mddev->recovery_cp = mddev->dev_sectors; | 4863 | mddev->recovery_cp = mddev->dev_sectors; |
4863 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); | 4864 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); |
@@ -5058,7 +5059,6 @@ static void end_reshape(raid5_conf_t *conf) | |||
5058 | */ | 5059 | */ |
5059 | static void raid5_finish_reshape(mddev_t *mddev) | 5060 | static void raid5_finish_reshape(mddev_t *mddev) |
5060 | { | 5061 | { |
5061 | struct block_device *bdev; | ||
5062 | raid5_conf_t *conf = mddev->private; | 5062 | raid5_conf_t *conf = mddev->private; |
5063 | 5063 | ||
5064 | if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) { | 5064 | if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) { |
@@ -5067,15 +5067,7 @@ static void raid5_finish_reshape(mddev_t *mddev) | |||
5067 | md_set_array_sectors(mddev, raid5_size(mddev, 0, 0)); | 5067 | md_set_array_sectors(mddev, raid5_size(mddev, 0, 0)); |
5068 | set_capacity(mddev->gendisk, mddev->array_sectors); | 5068 | set_capacity(mddev->gendisk, mddev->array_sectors); |
5069 | mddev->changed = 1; | 5069 | mddev->changed = 1; |
5070 | 5070 | revalidate_disk(mddev->gendisk); | |
5071 | bdev = bdget_disk(mddev->gendisk, 0); | ||
5072 | if (bdev) { | ||
5073 | mutex_lock(&bdev->bd_inode->i_mutex); | ||
5074 | i_size_write(bdev->bd_inode, | ||
5075 | (loff_t)mddev->array_sectors << 9); | ||
5076 | mutex_unlock(&bdev->bd_inode->i_mutex); | ||
5077 | bdput(bdev); | ||
5078 | } | ||
5079 | } else { | 5071 | } else { |
5080 | int d; | 5072 | int d; |
5081 | mddev->degraded = conf->raid_disks; | 5073 | mddev->degraded = conf->raid_disks; |