aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2008-10-20 22:25:21 -0400
committerNeilBrown <neilb@suse.de>2008-10-20 22:25:21 -0400
commitb62b75905d571c29262a6c38cf9e5f089c203871 (patch)
tree0ca9a74c1d53aad0532aaebebb031b9d8edc5d90 /drivers
parent0cfd81031a26717fe14380d18275f8e217571615 (diff)
md: use sysfs_notify_dirent to notify changes to md/array_state
Now that we have sysfs_notify_dirent, use it to notify changes to md/array_state. As sysfs_notify_dirent can be called in atomic context, we can remove the delayed notify and the MD_NOTIFY_ARRAY_STATE flag. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/md.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index aaa3d465de4e..feea72dc4b69 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);
@@ -2770,7 +2773,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
2770 if (err) 2773 if (err)
2771 return err; 2774 return err;
2772 else { 2775 else {
2773 sysfs_notify(&mddev->kobj, NULL, "array_state"); 2776 sysfs_notify_dirent(mddev->sysfs_state);
2774 return len; 2777 return len;
2775 } 2778 }
2776} 2779}
@@ -3465,8 +3468,10 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
3465 if (error) 3468 if (error)
3466 printk(KERN_WARNING "md: cannot register %s/md - name in use\n", 3469 printk(KERN_WARNING "md: cannot register %s/md - name in use\n",
3467 disk->disk_name); 3470 disk->disk_name);
3468 else 3471 else {
3469 kobject_uevent(&mddev->kobj, KOBJ_ADD); 3472 kobject_uevent(&mddev->kobj, KOBJ_ADD);
3473 mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, "array_state");
3474 }
3470 return NULL; 3475 return NULL;
3471} 3476}
3472 3477
@@ -3477,7 +3482,7 @@ static void md_safemode_timeout(unsigned long data)
3477 if (!atomic_read(&mddev->writes_pending)) { 3482 if (!atomic_read(&mddev->writes_pending)) {
3478 mddev->safemode = 1; 3483 mddev->safemode = 1;
3479 if (mddev->external) 3484 if (mddev->external)
3480 set_bit(MD_NOTIFY_ARRAY_STATE, &mddev->flags); 3485 sysfs_notify_dirent(mddev->sysfs_state);
3481 } 3486 }
3482 md_wakeup_thread(mddev->thread); 3487 md_wakeup_thread(mddev->thread);
3483} 3488}
@@ -3740,7 +3745,7 @@ static int do_md_run(mddev_t * mddev)
3740 3745
3741 mddev->changed = 1; 3746 mddev->changed = 1;
3742 md_new_event(mddev); 3747 md_new_event(mddev);
3743 sysfs_notify(&mddev->kobj, NULL, "array_state"); 3748 sysfs_notify_dirent(mddev->sysfs_state);
3744 sysfs_notify(&mddev->kobj, NULL, "sync_action"); 3749 sysfs_notify(&mddev->kobj, NULL, "sync_action");
3745 sysfs_notify(&mddev->kobj, NULL, "degraded"); 3750 sysfs_notify(&mddev->kobj, NULL, "degraded");
3746 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); 3751 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
@@ -3767,7 +3772,7 @@ static int restart_array(mddev_t *mddev)
3767 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 3772 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
3768 md_wakeup_thread(mddev->thread); 3773 md_wakeup_thread(mddev->thread);
3769 md_wakeup_thread(mddev->sync_thread); 3774 md_wakeup_thread(mddev->sync_thread);
3770 sysfs_notify(&mddev->kobj, NULL, "array_state"); 3775 sysfs_notify_dirent(mddev->sysfs_state);
3771 return 0; 3776 return 0;
3772} 3777}
3773 3778
@@ -3847,7 +3852,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
3847 module_put(mddev->pers->owner); 3852 module_put(mddev->pers->owner);
3848 mddev->pers = NULL; 3853 mddev->pers = NULL;
3849 /* tell userspace to handle 'inactive' */ 3854 /* tell userspace to handle 'inactive' */
3850 sysfs_notify(&mddev->kobj, NULL, "array_state"); 3855 sysfs_notify_dirent(mddev->sysfs_state);
3851 3856
3852 set_capacity(disk, 0); 3857 set_capacity(disk, 0);
3853 mddev->changed = 1; 3858 mddev->changed = 1;
@@ -3933,7 +3938,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
3933 mdname(mddev)); 3938 mdname(mddev));
3934 err = 0; 3939 err = 0;
3935 md_new_event(mddev); 3940 md_new_event(mddev);
3936 sysfs_notify(&mddev->kobj, NULL, "array_state"); 3941 sysfs_notify_dirent(mddev->sysfs_state);
3937out: 3942out:
3938 return err; 3943 return err;
3939} 3944}
@@ -4938,7 +4943,7 @@ static int md_ioctl(struct inode *inode, struct file *file,
4938 if (_IOC_TYPE(cmd) == MD_MAJOR && mddev->ro && mddev->pers) { 4943 if (_IOC_TYPE(cmd) == MD_MAJOR && mddev->ro && mddev->pers) {
4939 if (mddev->ro == 2) { 4944 if (mddev->ro == 2) {
4940 mddev->ro = 0; 4945 mddev->ro = 0;
4941 sysfs_notify(&mddev->kobj, NULL, "array_state"); 4946 sysfs_notify_dirent(mddev->sysfs_state);
4942 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 4947 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
4943 md_wakeup_thread(mddev->thread); 4948 md_wakeup_thread(mddev->thread);
4944 } else { 4949 } else {
@@ -5612,7 +5617,7 @@ void md_write_start(mddev_t *mddev, struct bio *bi)
5612 spin_unlock_irq(&mddev->write_lock); 5617 spin_unlock_irq(&mddev->write_lock);
5613 } 5618 }
5614 if (did_change) 5619 if (did_change)
5615 sysfs_notify(&mddev->kobj, NULL, "array_state"); 5620 sysfs_notify_dirent(mddev->sysfs_state);
5616 wait_event(mddev->sb_wait, 5621 wait_event(mddev->sb_wait,
5617 !test_bit(MD_CHANGE_CLEAN, &mddev->flags) && 5622 !test_bit(MD_CHANGE_CLEAN, &mddev->flags) &&
5618 !test_bit(MD_CHANGE_PENDING, &mddev->flags)); 5623 !test_bit(MD_CHANGE_PENDING, &mddev->flags));
@@ -5655,7 +5660,7 @@ int md_allow_write(mddev_t *mddev)
5655 mddev->safemode = 1; 5660 mddev->safemode = 1;
5656 spin_unlock_irq(&mddev->write_lock); 5661 spin_unlock_irq(&mddev->write_lock);
5657 md_update_sb(mddev, 0); 5662 md_update_sb(mddev, 0);
5658 sysfs_notify(&mddev->kobj, NULL, "array_state"); 5663 sysfs_notify_dirent(mddev->sysfs_state);
5659 } else 5664 } else
5660 spin_unlock_irq(&mddev->write_lock); 5665 spin_unlock_irq(&mddev->write_lock);
5661 5666
@@ -6048,9 +6053,6 @@ void md_check_recovery(mddev_t *mddev)
6048 if (mddev->bitmap) 6053 if (mddev->bitmap)
6049 bitmap_daemon_work(mddev->bitmap); 6054 bitmap_daemon_work(mddev->bitmap);
6050 6055
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) 6056 if (mddev->ro)
6055 return; 6057 return;
6056 6058
@@ -6103,7 +6105,7 @@ void md_check_recovery(mddev_t *mddev)
6103 mddev->safemode = 0; 6105 mddev->safemode = 0;
6104 spin_unlock_irq(&mddev->write_lock); 6106 spin_unlock_irq(&mddev->write_lock);
6105 if (did_change) 6107 if (did_change)
6106 sysfs_notify(&mddev->kobj, NULL, "array_state"); 6108 sysfs_notify_dirent(mddev->sysfs_state);
6107 } 6109 }
6108 6110
6109 if (mddev->flags) 6111 if (mddev->flags)