diff options
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 8fda38d23e38..34846856dbc6 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -3448,6 +3448,8 @@ level_store(struct mddev *mddev, const char *buf, size_t len) | |||
3448 | mddev->level = LEVEL_NONE; | 3448 | mddev->level = LEVEL_NONE; |
3449 | return rv; | 3449 | return rv; |
3450 | } | 3450 | } |
3451 | if (mddev->ro) | ||
3452 | return -EROFS; | ||
3451 | 3453 | ||
3452 | /* request to change the personality. Need to ensure: | 3454 | /* request to change the personality. Need to ensure: |
3453 | * - array is not engaged in resync/recovery/reshape | 3455 | * - array is not engaged in resync/recovery/reshape |
@@ -3634,6 +3636,8 @@ layout_store(struct mddev *mddev, const char *buf, size_t len) | |||
3634 | int err; | 3636 | int err; |
3635 | if (mddev->pers->check_reshape == NULL) | 3637 | if (mddev->pers->check_reshape == NULL) |
3636 | return -EBUSY; | 3638 | return -EBUSY; |
3639 | if (mddev->ro) | ||
3640 | return -EROFS; | ||
3637 | mddev->new_layout = n; | 3641 | mddev->new_layout = n; |
3638 | err = mddev->pers->check_reshape(mddev); | 3642 | err = mddev->pers->check_reshape(mddev); |
3639 | if (err) { | 3643 | if (err) { |
@@ -3723,6 +3727,8 @@ chunk_size_store(struct mddev *mddev, const char *buf, size_t len) | |||
3723 | int err; | 3727 | int err; |
3724 | if (mddev->pers->check_reshape == NULL) | 3728 | if (mddev->pers->check_reshape == NULL) |
3725 | return -EBUSY; | 3729 | return -EBUSY; |
3730 | if (mddev->ro) | ||
3731 | return -EROFS; | ||
3726 | mddev->new_chunk_sectors = n >> 9; | 3732 | mddev->new_chunk_sectors = n >> 9; |
3727 | err = mddev->pers->check_reshape(mddev); | 3733 | err = mddev->pers->check_reshape(mddev); |
3728 | if (err) { | 3734 | if (err) { |
@@ -6135,6 +6141,8 @@ static int update_size(struct mddev *mddev, sector_t num_sectors) | |||
6135 | */ | 6141 | */ |
6136 | if (mddev->sync_thread) | 6142 | if (mddev->sync_thread) |
6137 | return -EBUSY; | 6143 | return -EBUSY; |
6144 | if (mddev->ro) | ||
6145 | return -EROFS; | ||
6138 | 6146 | ||
6139 | rdev_for_each(rdev, mddev) { | 6147 | rdev_for_each(rdev, mddev) { |
6140 | sector_t avail = rdev->sectors; | 6148 | sector_t avail = rdev->sectors; |
@@ -6157,6 +6165,8 @@ static int update_raid_disks(struct mddev *mddev, int raid_disks) | |||
6157 | /* change the number of raid disks */ | 6165 | /* change the number of raid disks */ |
6158 | if (mddev->pers->check_reshape == NULL) | 6166 | if (mddev->pers->check_reshape == NULL) |
6159 | return -EINVAL; | 6167 | return -EINVAL; |
6168 | if (mddev->ro) | ||
6169 | return -EROFS; | ||
6160 | if (raid_disks <= 0 || | 6170 | if (raid_disks <= 0 || |
6161 | (mddev->max_disks && raid_disks >= mddev->max_disks)) | 6171 | (mddev->max_disks && raid_disks >= mddev->max_disks)) |
6162 | return -EINVAL; | 6172 | return -EINVAL; |
@@ -7381,8 +7391,10 @@ void md_do_sync(struct md_thread *thread) | |||
7381 | /* just incase thread restarts... */ | 7391 | /* just incase thread restarts... */ |
7382 | if (test_bit(MD_RECOVERY_DONE, &mddev->recovery)) | 7392 | if (test_bit(MD_RECOVERY_DONE, &mddev->recovery)) |
7383 | return; | 7393 | return; |
7384 | if (mddev->ro) /* never try to sync a read-only array */ | 7394 | if (mddev->ro) {/* never try to sync a read-only array */ |
7395 | set_bit(MD_RECOVERY_INTR, &mddev->recovery); | ||
7385 | return; | 7396 | return; |
7397 | } | ||
7386 | 7398 | ||
7387 | if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) { | 7399 | if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) { |
7388 | if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) { | 7400 | if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) { |
@@ -7824,6 +7836,7 @@ void md_check_recovery(struct mddev *mddev) | |||
7824 | /* There is no thread, but we need to call | 7836 | /* There is no thread, but we need to call |
7825 | * ->spare_active and clear saved_raid_disk | 7837 | * ->spare_active and clear saved_raid_disk |
7826 | */ | 7838 | */ |
7839 | set_bit(MD_RECOVERY_INTR, &mddev->recovery); | ||
7827 | md_reap_sync_thread(mddev); | 7840 | md_reap_sync_thread(mddev); |
7828 | clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery); | 7841 | clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery); |
7829 | goto unlock; | 7842 | goto unlock; |
@@ -8330,7 +8343,7 @@ static int md_clear_badblocks(struct badblocks *bb, sector_t s, int sectors) | |||
8330 | if (a < s) { | 8343 | if (a < s) { |
8331 | /* we need to split this range */ | 8344 | /* we need to split this range */ |
8332 | if (bb->count >= MD_MAX_BADBLOCKS) { | 8345 | if (bb->count >= MD_MAX_BADBLOCKS) { |
8333 | rv = 0; | 8346 | rv = -ENOSPC; |
8334 | goto out; | 8347 | goto out; |
8335 | } | 8348 | } |
8336 | memmove(p+lo+1, p+lo, (bb->count - lo) * 8); | 8349 | memmove(p+lo+1, p+lo, (bb->count - lo) * 8); |
@@ -8516,7 +8529,8 @@ static int md_notify_reboot(struct notifier_block *this, | |||
8516 | if (mddev_trylock(mddev)) { | 8529 | if (mddev_trylock(mddev)) { |
8517 | if (mddev->pers) | 8530 | if (mddev->pers) |
8518 | __md_stop_writes(mddev); | 8531 | __md_stop_writes(mddev); |
8519 | mddev->safemode = 2; | 8532 | if (mddev->persistent) |
8533 | mddev->safemode = 2; | ||
8520 | mddev_unlock(mddev); | 8534 | mddev_unlock(mddev); |
8521 | } | 8535 | } |
8522 | need_delay = 1; | 8536 | need_delay = 1; |