Commit 2c247c51 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

md: use set_capacity_and_notify

Use set_capacity_and_notify to set the size of both the disk and block
device.  This also gets the uevent notifications for the resize for free.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarSong Liu <song@kernel.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent dc2985a8
...@@ -581,8 +581,7 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg) ...@@ -581,8 +581,7 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
process_metadata_update(mddev, msg); process_metadata_update(mddev, msg);
break; break;
case CHANGE_CAPACITY: case CHANGE_CAPACITY:
set_capacity(mddev->gendisk, mddev->array_sectors); set_capacity_and_notify(mddev->gendisk, mddev->array_sectors);
revalidate_disk_size(mddev->gendisk, true);
break; break;
case RESYNCING: case RESYNCING:
set_bit(MD_RESYNCING_REMOTE, &mddev->recovery); set_bit(MD_RESYNCING_REMOTE, &mddev->recovery);
...@@ -1296,8 +1295,7 @@ static void update_size(struct mddev *mddev, sector_t old_dev_sectors) ...@@ -1296,8 +1295,7 @@ static void update_size(struct mddev *mddev, sector_t old_dev_sectors)
if (ret) if (ret)
pr_err("%s:%d: failed to send CHANGE_CAPACITY msg\n", pr_err("%s:%d: failed to send CHANGE_CAPACITY msg\n",
__func__, __LINE__); __func__, __LINE__);
set_capacity(mddev->gendisk, mddev->array_sectors); set_capacity_and_notify(mddev->gendisk, mddev->array_sectors);
revalidate_disk_size(mddev->gendisk, true);
} else { } else {
/* revert to previous sectors */ /* revert to previous sectors */
ret = mddev->pers->resize(mddev, old_dev_sectors); ret = mddev->pers->resize(mddev, old_dev_sectors);
......
...@@ -200,9 +200,8 @@ static int linear_add(struct mddev *mddev, struct md_rdev *rdev) ...@@ -200,9 +200,8 @@ static int linear_add(struct mddev *mddev, struct md_rdev *rdev)
"copied raid_disks doesn't match mddev->raid_disks"); "copied raid_disks doesn't match mddev->raid_disks");
rcu_assign_pointer(mddev->private, newconf); rcu_assign_pointer(mddev->private, newconf);
md_set_array_sectors(mddev, linear_size(mddev, 0, 0)); md_set_array_sectors(mddev, linear_size(mddev, 0, 0));
set_capacity(mddev->gendisk, mddev->array_sectors); set_capacity_and_notify(mddev->gendisk, mddev->array_sectors);
mddev_resume(mddev); mddev_resume(mddev);
revalidate_disk_size(mddev->gendisk, true);
kfree_rcu(oldconf, rcu); kfree_rcu(oldconf, rcu);
return 0; return 0;
} }
......
...@@ -5355,10 +5355,9 @@ array_size_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -5355,10 +5355,9 @@ array_size_store(struct mddev *mddev, const char *buf, size_t len)
if (!err) { if (!err) {
mddev->array_sectors = sectors; mddev->array_sectors = sectors;
if (mddev->pers) { if (mddev->pers)
set_capacity(mddev->gendisk, mddev->array_sectors); set_capacity_and_notify(mddev->gendisk,
revalidate_disk_size(mddev->gendisk, true); mddev->array_sectors);
}
} }
mddev_unlock(mddev); mddev_unlock(mddev);
return err ?: len; return err ?: len;
...@@ -6108,8 +6107,7 @@ int do_md_run(struct mddev *mddev) ...@@ -6108,8 +6107,7 @@ int do_md_run(struct mddev *mddev)
md_wakeup_thread(mddev->thread); md_wakeup_thread(mddev->thread);
md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */ md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
set_capacity(mddev->gendisk, mddev->array_sectors); set_capacity_and_notify(mddev->gendisk, mddev->array_sectors);
revalidate_disk_size(mddev->gendisk, true);
clear_bit(MD_NOT_READY, &mddev->flags); clear_bit(MD_NOT_READY, &mddev->flags);
mddev->changed = 1; mddev->changed = 1;
kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
...@@ -6424,10 +6422,9 @@ static int do_md_stop(struct mddev *mddev, int mode, ...@@ -6424,10 +6422,9 @@ static int do_md_stop(struct mddev *mddev, int mode,
if (rdev->raid_disk >= 0) if (rdev->raid_disk >= 0)
sysfs_unlink_rdev(mddev, rdev); sysfs_unlink_rdev(mddev, rdev);
set_capacity(disk, 0); set_capacity_and_notify(disk, 0);
mutex_unlock(&mddev->open_mutex); mutex_unlock(&mddev->open_mutex);
mddev->changed = 1; mddev->changed = 1;
revalidate_disk_size(disk, true);
if (mddev->ro) if (mddev->ro)
mddev->ro = 0; mddev->ro = 0;
...@@ -7258,8 +7255,8 @@ static int update_size(struct mddev *mddev, sector_t num_sectors) ...@@ -7258,8 +7255,8 @@ static int update_size(struct mddev *mddev, sector_t num_sectors)
if (mddev_is_clustered(mddev)) if (mddev_is_clustered(mddev))
md_cluster_ops->update_size(mddev, old_dev_sectors); md_cluster_ops->update_size(mddev, old_dev_sectors);
else if (mddev->queue) { else if (mddev->queue) {
set_capacity(mddev->gendisk, mddev->array_sectors); set_capacity_and_notify(mddev->gendisk,
revalidate_disk_size(mddev->gendisk, true); mddev->array_sectors);
} }
} }
return rv; return rv;
...@@ -9036,10 +9033,9 @@ void md_do_sync(struct md_thread *thread) ...@@ -9036,10 +9033,9 @@ void md_do_sync(struct md_thread *thread)
mddev_lock_nointr(mddev); mddev_lock_nointr(mddev);
md_set_array_sectors(mddev, mddev->pers->size(mddev, 0, 0)); md_set_array_sectors(mddev, mddev->pers->size(mddev, 0, 0));
mddev_unlock(mddev); mddev_unlock(mddev);
if (!mddev_is_clustered(mddev)) { if (!mddev_is_clustered(mddev))
set_capacity(mddev->gendisk, mddev->array_sectors); set_capacity_and_notify(mddev->gendisk,
revalidate_disk_size(mddev->gendisk, true); mddev->array_sectors);
}
} }
spin_lock(&mddev->lock); spin_lock(&mddev->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment