diff options
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 84acfe7d10e4..ee981737edfc 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -570,7 +570,7 @@ static void mddev_put(struct mddev *mddev) | |||
570 | mddev->ctime == 0 && !mddev->hold_active) { | 570 | mddev->ctime == 0 && !mddev->hold_active) { |
571 | /* Array is not configured at all, and not held active, | 571 | /* Array is not configured at all, and not held active, |
572 | * so destroy it */ | 572 | * so destroy it */ |
573 | list_del(&mddev->all_mddevs); | 573 | list_del_init(&mddev->all_mddevs); |
574 | bs = mddev->bio_set; | 574 | bs = mddev->bio_set; |
575 | mddev->bio_set = NULL; | 575 | mddev->bio_set = NULL; |
576 | if (mddev->gendisk) { | 576 | if (mddev->gendisk) { |
@@ -2546,7 +2546,8 @@ state_show(struct md_rdev *rdev, char *page) | |||
2546 | sep = ","; | 2546 | sep = ","; |
2547 | } | 2547 | } |
2548 | if (test_bit(Blocked, &rdev->flags) || | 2548 | if (test_bit(Blocked, &rdev->flags) || |
2549 | rdev->badblocks.unacked_exist) { | 2549 | (rdev->badblocks.unacked_exist |
2550 | && !test_bit(Faulty, &rdev->flags))) { | ||
2550 | len += sprintf(page+len, "%sblocked", sep); | 2551 | len += sprintf(page+len, "%sblocked", sep); |
2551 | sep = ","; | 2552 | sep = ","; |
2552 | } | 2553 | } |
@@ -3788,6 +3789,8 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len) | |||
3788 | if (err) | 3789 | if (err) |
3789 | return err; | 3790 | return err; |
3790 | else { | 3791 | else { |
3792 | if (mddev->hold_active == UNTIL_IOCTL) | ||
3793 | mddev->hold_active = 0; | ||
3791 | sysfs_notify_dirent_safe(mddev->sysfs_state); | 3794 | sysfs_notify_dirent_safe(mddev->sysfs_state); |
3792 | return len; | 3795 | return len; |
3793 | } | 3796 | } |
@@ -4487,11 +4490,20 @@ md_attr_show(struct kobject *kobj, struct attribute *attr, char *page) | |||
4487 | 4490 | ||
4488 | if (!entry->show) | 4491 | if (!entry->show) |
4489 | return -EIO; | 4492 | return -EIO; |
4493 | spin_lock(&all_mddevs_lock); | ||
4494 | if (list_empty(&mddev->all_mddevs)) { | ||
4495 | spin_unlock(&all_mddevs_lock); | ||
4496 | return -EBUSY; | ||
4497 | } | ||
4498 | mddev_get(mddev); | ||
4499 | spin_unlock(&all_mddevs_lock); | ||
4500 | |||
4490 | rv = mddev_lock(mddev); | 4501 | rv = mddev_lock(mddev); |
4491 | if (!rv) { | 4502 | if (!rv) { |
4492 | rv = entry->show(mddev, page); | 4503 | rv = entry->show(mddev, page); |
4493 | mddev_unlock(mddev); | 4504 | mddev_unlock(mddev); |
4494 | } | 4505 | } |
4506 | mddev_put(mddev); | ||
4495 | return rv; | 4507 | return rv; |
4496 | } | 4508 | } |
4497 | 4509 | ||
@@ -4507,13 +4519,19 @@ md_attr_store(struct kobject *kobj, struct attribute *attr, | |||
4507 | return -EIO; | 4519 | return -EIO; |
4508 | if (!capable(CAP_SYS_ADMIN)) | 4520 | if (!capable(CAP_SYS_ADMIN)) |
4509 | return -EACCES; | 4521 | return -EACCES; |
4522 | spin_lock(&all_mddevs_lock); | ||
4523 | if (list_empty(&mddev->all_mddevs)) { | ||
4524 | spin_unlock(&all_mddevs_lock); | ||
4525 | return -EBUSY; | ||
4526 | } | ||
4527 | mddev_get(mddev); | ||
4528 | spin_unlock(&all_mddevs_lock); | ||
4510 | rv = mddev_lock(mddev); | 4529 | rv = mddev_lock(mddev); |
4511 | if (mddev->hold_active == UNTIL_IOCTL) | ||
4512 | mddev->hold_active = 0; | ||
4513 | if (!rv) { | 4530 | if (!rv) { |
4514 | rv = entry->store(mddev, page, length); | 4531 | rv = entry->store(mddev, page, length); |
4515 | mddev_unlock(mddev); | 4532 | mddev_unlock(mddev); |
4516 | } | 4533 | } |
4534 | mddev_put(mddev); | ||
4517 | return rv; | 4535 | return rv; |
4518 | } | 4536 | } |
4519 | 4537 | ||
@@ -7840,6 +7858,7 @@ int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors, | |||
7840 | s + rdev->data_offset, sectors, acknowledged); | 7858 | s + rdev->data_offset, sectors, acknowledged); |
7841 | if (rv) { | 7859 | if (rv) { |
7842 | /* Make sure they get written out promptly */ | 7860 | /* Make sure they get written out promptly */ |
7861 | sysfs_notify_dirent_safe(rdev->sysfs_state); | ||
7843 | set_bit(MD_CHANGE_CLEAN, &rdev->mddev->flags); | 7862 | set_bit(MD_CHANGE_CLEAN, &rdev->mddev->flags); |
7844 | md_wakeup_thread(rdev->mddev->thread); | 7863 | md_wakeup_thread(rdev->mddev->thread); |
7845 | } | 7864 | } |