diff options
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index c1a837ca193c..1b1d32694f6f 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -222,6 +222,9 @@ static void mddev_put(mddev_t *mddev) | |||
222 | list_del(&mddev->all_mddevs); | 222 | list_del(&mddev->all_mddevs); |
223 | spin_unlock(&all_mddevs_lock); | 223 | spin_unlock(&all_mddevs_lock); |
224 | blk_cleanup_queue(mddev->queue); | 224 | blk_cleanup_queue(mddev->queue); |
225 | if (mddev->sysfs_state) | ||
226 | sysfs_put(mddev->sysfs_state); | ||
227 | mddev->sysfs_state = NULL; | ||
225 | kobject_put(&mddev->kobj); | 228 | kobject_put(&mddev->kobj); |
226 | } else | 229 | } else |
227 | spin_unlock(&all_mddevs_lock); | 230 | spin_unlock(&all_mddevs_lock); |
@@ -1459,6 +1462,8 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) | |||
1459 | kobject_del(&rdev->kobj); | 1462 | kobject_del(&rdev->kobj); |
1460 | goto fail; | 1463 | goto fail; |
1461 | } | 1464 | } |
1465 | rdev->sysfs_state = sysfs_get_dirent(rdev->kobj.sd, "state"); | ||
1466 | |||
1462 | list_add_rcu(&rdev->same_set, &mddev->disks); | 1467 | list_add_rcu(&rdev->same_set, &mddev->disks); |
1463 | bd_claim_by_disk(rdev->bdev, rdev->bdev->bd_holder, mddev->gendisk); | 1468 | bd_claim_by_disk(rdev->bdev, rdev->bdev->bd_holder, mddev->gendisk); |
1464 | return 0; | 1469 | return 0; |
@@ -1488,7 +1493,8 @@ static void unbind_rdev_from_array(mdk_rdev_t * rdev) | |||
1488 | printk(KERN_INFO "md: unbind<%s>\n", bdevname(rdev->bdev,b)); | 1493 | printk(KERN_INFO "md: unbind<%s>\n", bdevname(rdev->bdev,b)); |
1489 | rdev->mddev = NULL; | 1494 | rdev->mddev = NULL; |
1490 | sysfs_remove_link(&rdev->kobj, "block"); | 1495 | sysfs_remove_link(&rdev->kobj, "block"); |
1491 | 1496 | sysfs_put(rdev->sysfs_state); | |
1497 | rdev->sysfs_state = NULL; | ||
1492 | /* We need to delay this, otherwise we can deadlock when | 1498 | /* We need to delay this, otherwise we can deadlock when |
1493 | * writing to 'remove' to "dev/state". We also need | 1499 | * writing to 'remove' to "dev/state". We also need |
1494 | * to delay it due to rcu usage. | 1500 | * to delay it due to rcu usage. |
@@ -1923,8 +1929,8 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len) | |||
1923 | 1929 | ||
1924 | err = 0; | 1930 | err = 0; |
1925 | } | 1931 | } |
1926 | if (!err) | 1932 | if (!err && rdev->sysfs_state) |
1927 | sysfs_notify(&rdev->kobj, NULL, "state"); | 1933 | sysfs_notify_dirent(rdev->sysfs_state); |
1928 | return err ? err : len; | 1934 | return err ? err : len; |
1929 | } | 1935 | } |
1930 | static struct rdev_sysfs_entry rdev_state = | 1936 | static struct rdev_sysfs_entry rdev_state = |
@@ -2019,7 +2025,7 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len) | |||
2019 | rdev->raid_disk = -1; | 2025 | rdev->raid_disk = -1; |
2020 | return err; | 2026 | return err; |
2021 | } else | 2027 | } else |
2022 | sysfs_notify(&rdev->kobj, NULL, "state"); | 2028 | sysfs_notify_dirent(rdev->sysfs_state); |
2023 | sprintf(nm, "rd%d", rdev->raid_disk); | 2029 | sprintf(nm, "rd%d", rdev->raid_disk); |
2024 | if (sysfs_create_link(&rdev->mddev->kobj, &rdev->kobj, nm)) | 2030 | if (sysfs_create_link(&rdev->mddev->kobj, &rdev->kobj, nm)) |
2025 | printk(KERN_WARNING | 2031 | printk(KERN_WARNING |
@@ -2036,7 +2042,7 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len) | |||
2036 | clear_bit(Faulty, &rdev->flags); | 2042 | clear_bit(Faulty, &rdev->flags); |
2037 | clear_bit(WriteMostly, &rdev->flags); | 2043 | clear_bit(WriteMostly, &rdev->flags); |
2038 | set_bit(In_sync, &rdev->flags); | 2044 | set_bit(In_sync, &rdev->flags); |
2039 | sysfs_notify(&rdev->kobj, NULL, "state"); | 2045 | sysfs_notify_dirent(rdev->sysfs_state); |
2040 | } | 2046 | } |
2041 | return len; | 2047 | return len; |
2042 | } | 2048 | } |
@@ -2770,7 +2776,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len) | |||
2770 | if (err) | 2776 | if (err) |
2771 | return err; | 2777 | return err; |
2772 | else { | 2778 | else { |
2773 | sysfs_notify(&mddev->kobj, NULL, "array_state"); | 2779 | sysfs_notify_dirent(mddev->sysfs_state); |
2774 | return len; | 2780 | return len; |
2775 | } | 2781 | } |
2776 | } | 2782 | } |
@@ -3457,6 +3463,11 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data) | |||
3457 | disk->fops = &md_fops; | 3463 | disk->fops = &md_fops; |
3458 | disk->private_data = mddev; | 3464 | disk->private_data = mddev; |
3459 | disk->queue = mddev->queue; | 3465 | disk->queue = mddev->queue; |
3466 | /* Allow extended partitions. This makes the | ||
3467 | * 'mdp' device redundant, but we can really | ||
3468 | * remove it now. | ||
3469 | */ | ||
3470 | disk->flags |= GENHD_FL_EXT_DEVT; | ||
3460 | add_disk(disk); | 3471 | add_disk(disk); |
3461 | mddev->gendisk = disk; | 3472 | mddev->gendisk = disk; |
3462 | error = kobject_init_and_add(&mddev->kobj, &md_ktype, | 3473 | error = kobject_init_and_add(&mddev->kobj, &md_ktype, |
@@ -3465,8 +3476,10 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data) | |||
3465 | if (error) | 3476 | if (error) |
3466 | printk(KERN_WARNING "md: cannot register %s/md - name in use\n", | 3477 | printk(KERN_WARNING "md: cannot register %s/md - name in use\n", |
3467 | disk->disk_name); | 3478 | disk->disk_name); |
3468 | else | 3479 | else { |
3469 | kobject_uevent(&mddev->kobj, KOBJ_ADD); | 3480 | kobject_uevent(&mddev->kobj, KOBJ_ADD); |
3481 | mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, "array_state"); | ||
3482 | } | ||
3470 | return NULL; | 3483 | return NULL; |
3471 | } | 3484 | } |
3472 | 3485 | ||
@@ -3477,7 +3490,7 @@ static void md_safemode_timeout(unsigned long data) | |||
3477 | if (!atomic_read(&mddev->writes_pending)) { | 3490 | if (!atomic_read(&mddev->writes_pending)) { |
3478 | mddev->safemode = 1; | 3491 | mddev->safemode = 1; |
3479 | if (mddev->external) | 3492 | if (mddev->external) |
3480 | set_bit(MD_NOTIFY_ARRAY_STATE, &mddev->flags); | 3493 | sysfs_notify_dirent(mddev->sysfs_state); |
3481 | } | 3494 | } |
3482 | md_wakeup_thread(mddev->thread); | 3495 | md_wakeup_thread(mddev->thread); |
3483 | } | 3496 | } |
@@ -3578,7 +3591,7 @@ static int do_md_run(mddev_t * mddev) | |||
3578 | return -EINVAL; | 3591 | return -EINVAL; |
3579 | } | 3592 | } |
3580 | } | 3593 | } |
3581 | sysfs_notify(&rdev->kobj, NULL, "state"); | 3594 | sysfs_notify_dirent(rdev->sysfs_state); |
3582 | } | 3595 | } |
3583 | 3596 | ||
3584 | md_probe(mddev->unit, NULL, NULL); | 3597 | md_probe(mddev->unit, NULL, NULL); |
@@ -3740,7 +3753,7 @@ static int do_md_run(mddev_t * mddev) | |||
3740 | 3753 | ||
3741 | mddev->changed = 1; | 3754 | mddev->changed = 1; |
3742 | md_new_event(mddev); | 3755 | md_new_event(mddev); |
3743 | sysfs_notify(&mddev->kobj, NULL, "array_state"); | 3756 | sysfs_notify_dirent(mddev->sysfs_state); |
3744 | sysfs_notify(&mddev->kobj, NULL, "sync_action"); | 3757 | sysfs_notify(&mddev->kobj, NULL, "sync_action"); |
3745 | sysfs_notify(&mddev->kobj, NULL, "degraded"); | 3758 | sysfs_notify(&mddev->kobj, NULL, "degraded"); |
3746 | kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); | 3759 | kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); |
@@ -3767,7 +3780,7 @@ static int restart_array(mddev_t *mddev) | |||
3767 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); | 3780 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); |
3768 | md_wakeup_thread(mddev->thread); | 3781 | md_wakeup_thread(mddev->thread); |
3769 | md_wakeup_thread(mddev->sync_thread); | 3782 | md_wakeup_thread(mddev->sync_thread); |
3770 | sysfs_notify(&mddev->kobj, NULL, "array_state"); | 3783 | sysfs_notify_dirent(mddev->sysfs_state); |
3771 | return 0; | 3784 | return 0; |
3772 | } | 3785 | } |
3773 | 3786 | ||
@@ -3847,7 +3860,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open) | |||
3847 | module_put(mddev->pers->owner); | 3860 | module_put(mddev->pers->owner); |
3848 | mddev->pers = NULL; | 3861 | mddev->pers = NULL; |
3849 | /* tell userspace to handle 'inactive' */ | 3862 | /* tell userspace to handle 'inactive' */ |
3850 | sysfs_notify(&mddev->kobj, NULL, "array_state"); | 3863 | sysfs_notify_dirent(mddev->sysfs_state); |
3851 | 3864 | ||
3852 | set_capacity(disk, 0); | 3865 | set_capacity(disk, 0); |
3853 | mddev->changed = 1; | 3866 | mddev->changed = 1; |
@@ -3927,13 +3940,14 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open) | |||
3927 | mddev->degraded = 0; | 3940 | mddev->degraded = 0; |
3928 | mddev->barriers_work = 0; | 3941 | mddev->barriers_work = 0; |
3929 | mddev->safemode = 0; | 3942 | mddev->safemode = 0; |
3943 | kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); | ||
3930 | 3944 | ||
3931 | } else if (mddev->pers) | 3945 | } else if (mddev->pers) |
3932 | printk(KERN_INFO "md: %s switched to read-only mode.\n", | 3946 | printk(KERN_INFO "md: %s switched to read-only mode.\n", |
3933 | mdname(mddev)); | 3947 | mdname(mddev)); |
3934 | err = 0; | 3948 | err = 0; |
3935 | md_new_event(mddev); | 3949 | md_new_event(mddev); |
3936 | sysfs_notify(&mddev->kobj, NULL, "array_state"); | 3950 | sysfs_notify_dirent(mddev->sysfs_state); |
3937 | out: | 3951 | out: |
3938 | return err; | 3952 | return err; |
3939 | } | 3953 | } |
@@ -4297,7 +4311,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) | |||
4297 | if (err) | 4311 | if (err) |
4298 | export_rdev(rdev); | 4312 | export_rdev(rdev); |
4299 | else | 4313 | else |
4300 | sysfs_notify(&rdev->kobj, NULL, "state"); | 4314 | sysfs_notify_dirent(rdev->sysfs_state); |
4301 | 4315 | ||
4302 | md_update_sb(mddev, 1); | 4316 | md_update_sb(mddev, 1); |
4303 | if (mddev->degraded) | 4317 | if (mddev->degraded) |
@@ -4938,7 +4952,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, | |||
4938 | if (_IOC_TYPE(cmd) == MD_MAJOR && mddev->ro && mddev->pers) { | 4952 | if (_IOC_TYPE(cmd) == MD_MAJOR && mddev->ro && mddev->pers) { |
4939 | if (mddev->ro == 2) { | 4953 | if (mddev->ro == 2) { |
4940 | mddev->ro = 0; | 4954 | mddev->ro = 0; |
4941 | sysfs_notify(&mddev->kobj, NULL, "array_state"); | 4955 | sysfs_notify_dirent(mddev->sysfs_state); |
4942 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); | 4956 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); |
4943 | md_wakeup_thread(mddev->thread); | 4957 | md_wakeup_thread(mddev->thread); |
4944 | } else { | 4958 | } else { |
@@ -5612,7 +5626,7 @@ void md_write_start(mddev_t *mddev, struct bio *bi) | |||
5612 | spin_unlock_irq(&mddev->write_lock); | 5626 | spin_unlock_irq(&mddev->write_lock); |
5613 | } | 5627 | } |
5614 | if (did_change) | 5628 | if (did_change) |
5615 | sysfs_notify(&mddev->kobj, NULL, "array_state"); | 5629 | sysfs_notify_dirent(mddev->sysfs_state); |
5616 | wait_event(mddev->sb_wait, | 5630 | wait_event(mddev->sb_wait, |
5617 | !test_bit(MD_CHANGE_CLEAN, &mddev->flags) && | 5631 | !test_bit(MD_CHANGE_CLEAN, &mddev->flags) && |
5618 | !test_bit(MD_CHANGE_PENDING, &mddev->flags)); | 5632 | !test_bit(MD_CHANGE_PENDING, &mddev->flags)); |
@@ -5655,7 +5669,7 @@ int md_allow_write(mddev_t *mddev) | |||
5655 | mddev->safemode = 1; | 5669 | mddev->safemode = 1; |
5656 | spin_unlock_irq(&mddev->write_lock); | 5670 | spin_unlock_irq(&mddev->write_lock); |
5657 | md_update_sb(mddev, 0); | 5671 | md_update_sb(mddev, 0); |
5658 | sysfs_notify(&mddev->kobj, NULL, "array_state"); | 5672 | sysfs_notify_dirent(mddev->sysfs_state); |
5659 | } else | 5673 | } else |
5660 | spin_unlock_irq(&mddev->write_lock); | 5674 | spin_unlock_irq(&mddev->write_lock); |
5661 | 5675 | ||
@@ -6048,9 +6062,6 @@ void md_check_recovery(mddev_t *mddev) | |||
6048 | if (mddev->bitmap) | 6062 | if (mddev->bitmap) |
6049 | bitmap_daemon_work(mddev->bitmap); | 6063 | bitmap_daemon_work(mddev->bitmap); |
6050 | 6064 | ||
6051 | if (test_and_clear_bit(MD_NOTIFY_ARRAY_STATE, &mddev->flags)) | ||
6052 | sysfs_notify(&mddev->kobj, NULL, "array_state"); | ||
6053 | |||
6054 | if (mddev->ro) | 6065 | if (mddev->ro) |
6055 | return; | 6066 | return; |
6056 | 6067 | ||
@@ -6103,7 +6114,7 @@ void md_check_recovery(mddev_t *mddev) | |||
6103 | mddev->safemode = 0; | 6114 | mddev->safemode = 0; |
6104 | spin_unlock_irq(&mddev->write_lock); | 6115 | spin_unlock_irq(&mddev->write_lock); |
6105 | if (did_change) | 6116 | if (did_change) |
6106 | sysfs_notify(&mddev->kobj, NULL, "array_state"); | 6117 | sysfs_notify_dirent(mddev->sysfs_state); |
6107 | } | 6118 | } |
6108 | 6119 | ||
6109 | if (mddev->flags) | 6120 | if (mddev->flags) |
@@ -6111,7 +6122,7 @@ void md_check_recovery(mddev_t *mddev) | |||
6111 | 6122 | ||
6112 | rdev_for_each(rdev, rtmp, mddev) | 6123 | rdev_for_each(rdev, rtmp, mddev) |
6113 | if (test_and_clear_bit(StateChanged, &rdev->flags)) | 6124 | if (test_and_clear_bit(StateChanged, &rdev->flags)) |
6114 | sysfs_notify(&rdev->kobj, NULL, "state"); | 6125 | sysfs_notify_dirent(rdev->sysfs_state); |
6115 | 6126 | ||
6116 | 6127 | ||
6117 | if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) && | 6128 | if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) && |
@@ -6221,7 +6232,7 @@ void md_check_recovery(mddev_t *mddev) | |||
6221 | 6232 | ||
6222 | void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev) | 6233 | void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev) |
6223 | { | 6234 | { |
6224 | sysfs_notify(&rdev->kobj, NULL, "state"); | 6235 | sysfs_notify_dirent(rdev->sysfs_state); |
6225 | wait_event_timeout(rdev->blocked_wait, | 6236 | wait_event_timeout(rdev->blocked_wait, |
6226 | !test_bit(Blocked, &rdev->flags), | 6237 | !test_bit(Blocked, &rdev->flags), |
6227 | msecs_to_jiffies(5000)); | 6238 | msecs_to_jiffies(5000)); |