Commit bd8839e0 authored by NeilBrown's avatar NeilBrown

md: refuse to change shape of array if it is active but read-only

read-only arrays should not be changed.  This includes changing
the level, layout, size, or number of devices.

So reject those changes for readonly arrays.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 2ac295a5
...@@ -3448,6 +3448,8 @@ level_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -3448,6 +3448,8 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
mddev->level = LEVEL_NONE; mddev->level = LEVEL_NONE;
return rv; return rv;
} }
if (mddev->ro)
return -EROFS;
/* request to change the personality. Need to ensure: /* request to change the personality. Need to ensure:
* - array is not engaged in resync/recovery/reshape * - array is not engaged in resync/recovery/reshape
...@@ -3634,6 +3636,8 @@ layout_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -3634,6 +3636,8 @@ layout_store(struct mddev *mddev, const char *buf, size_t len)
int err; int err;
if (mddev->pers->check_reshape == NULL) if (mddev->pers->check_reshape == NULL)
return -EBUSY; return -EBUSY;
if (mddev->ro)
return -EROFS;
mddev->new_layout = n; mddev->new_layout = n;
err = mddev->pers->check_reshape(mddev); err = mddev->pers->check_reshape(mddev);
if (err) { if (err) {
...@@ -3723,6 +3727,8 @@ chunk_size_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -3723,6 +3727,8 @@ chunk_size_store(struct mddev *mddev, const char *buf, size_t len)
int err; int err;
if (mddev->pers->check_reshape == NULL) if (mddev->pers->check_reshape == NULL)
return -EBUSY; return -EBUSY;
if (mddev->ro)
return -EROFS;
mddev->new_chunk_sectors = n >> 9; mddev->new_chunk_sectors = n >> 9;
err = mddev->pers->check_reshape(mddev); err = mddev->pers->check_reshape(mddev);
if (err) { if (err) {
...@@ -6135,6 +6141,8 @@ static int update_size(struct mddev *mddev, sector_t num_sectors) ...@@ -6135,6 +6141,8 @@ static int update_size(struct mddev *mddev, sector_t num_sectors)
*/ */
if (mddev->sync_thread) if (mddev->sync_thread)
return -EBUSY; return -EBUSY;
if (mddev->ro)
return -EROFS;
rdev_for_each(rdev, mddev) { rdev_for_each(rdev, mddev) {
sector_t avail = rdev->sectors; sector_t avail = rdev->sectors;
...@@ -6157,6 +6165,8 @@ static int update_raid_disks(struct mddev *mddev, int raid_disks) ...@@ -6157,6 +6165,8 @@ static int update_raid_disks(struct mddev *mddev, int raid_disks)
/* change the number of raid disks */ /* change the number of raid disks */
if (mddev->pers->check_reshape == NULL) if (mddev->pers->check_reshape == NULL)
return -EINVAL; return -EINVAL;
if (mddev->ro)
return -EROFS;
if (raid_disks <= 0 || if (raid_disks <= 0 ||
(mddev->max_disks && raid_disks >= mddev->max_disks)) (mddev->max_disks && raid_disks >= mddev->max_disks))
return -EINVAL; return -EINVAL;
......
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