md: move funcs from pers->resize to update_size

raid1_resize and raid5_resize should also check the
mddev->queue if run underneath dm-raid.

And both set_capacity and revalidate_disk are used in
pers->resize such as raid1, raid10 and raid5. So
move them from personality file to common code.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
This commit is contained in:
Guoqing Jiang 2017-02-24 11:15:23 +08:00 committed by Shaohua Li
parent 75df023f4f
commit c948363421
4 changed files with 6 additions and 10 deletions

View File

@ -6525,8 +6525,12 @@ static int update_size(struct mddev *mddev, sector_t num_sectors)
return -ENOSPC; return -ENOSPC;
} }
rv = mddev->pers->resize(mddev, num_sectors); rv = mddev->pers->resize(mddev, num_sectors);
if (!rv) if (!rv) {
revalidate_disk(mddev->gendisk); if (mddev->queue) {
set_capacity(mddev->gendisk, mddev->array_sectors);
revalidate_disk(mddev->gendisk);
}
}
return rv; return rv;
} }

View File

@ -3246,8 +3246,6 @@ static int raid1_resize(struct mddev *mddev, sector_t sectors)
return ret; return ret;
} }
md_set_array_sectors(mddev, newsize); md_set_array_sectors(mddev, newsize);
set_capacity(mddev->gendisk, mddev->array_sectors);
revalidate_disk(mddev->gendisk);
if (sectors > mddev->dev_sectors && if (sectors > mddev->dev_sectors &&
mddev->recovery_cp > mddev->dev_sectors) { mddev->recovery_cp > mddev->dev_sectors) {
mddev->recovery_cp = mddev->dev_sectors; mddev->recovery_cp = mddev->dev_sectors;

View File

@ -3956,10 +3956,6 @@ static int raid10_resize(struct mddev *mddev, sector_t sectors)
return ret; return ret;
} }
md_set_array_sectors(mddev, size); md_set_array_sectors(mddev, size);
if (mddev->queue) {
set_capacity(mddev->gendisk, mddev->array_sectors);
revalidate_disk(mddev->gendisk);
}
if (sectors > mddev->dev_sectors && if (sectors > mddev->dev_sectors &&
mddev->recovery_cp > oldsize) { mddev->recovery_cp > oldsize) {
mddev->recovery_cp = oldsize; mddev->recovery_cp = oldsize;

View File

@ -7605,8 +7605,6 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors)
return ret; return ret;
} }
md_set_array_sectors(mddev, newsize); md_set_array_sectors(mddev, newsize);
set_capacity(mddev->gendisk, mddev->array_sectors);
revalidate_disk(mddev->gendisk);
if (sectors > mddev->dev_sectors && if (sectors > mddev->dev_sectors &&
mddev->recovery_cp > mddev->dev_sectors) { mddev->recovery_cp > mddev->dev_sectors) {
mddev->recovery_cp = mddev->dev_sectors; mddev->recovery_cp = mddev->dev_sectors;