diff options
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 1ed5152db450..f19b874753a9 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -163,9 +163,19 @@ void md_new_event(mddev_t *mddev) | |||
163 | { | 163 | { |
164 | atomic_inc(&md_event_count); | 164 | atomic_inc(&md_event_count); |
165 | wake_up(&md_event_waiters); | 165 | wake_up(&md_event_waiters); |
166 | sysfs_notify(&mddev->kobj, NULL, "sync_action"); | ||
166 | } | 167 | } |
167 | EXPORT_SYMBOL_GPL(md_new_event); | 168 | EXPORT_SYMBOL_GPL(md_new_event); |
168 | 169 | ||
170 | /* Alternate version that can be called from interrupts | ||
171 | * when calling sysfs_notify isn't needed. | ||
172 | */ | ||
173 | void md_new_event_inintr(mddev_t *mddev) | ||
174 | { | ||
175 | atomic_inc(&md_event_count); | ||
176 | wake_up(&md_event_waiters); | ||
177 | } | ||
178 | |||
169 | /* | 179 | /* |
170 | * Enables to iterate over all existing md arrays | 180 | * Enables to iterate over all existing md arrays |
171 | * all_mddevs_lock protects this list. | 181 | * all_mddevs_lock protects this list. |
@@ -278,11 +288,6 @@ static inline int mddev_lock(mddev_t * mddev) | |||
278 | return mutex_lock_interruptible(&mddev->reconfig_mutex); | 288 | return mutex_lock_interruptible(&mddev->reconfig_mutex); |
279 | } | 289 | } |
280 | 290 | ||
281 | static inline void mddev_lock_uninterruptible(mddev_t * mddev) | ||
282 | { | ||
283 | mutex_lock(&mddev->reconfig_mutex); | ||
284 | } | ||
285 | |||
286 | static inline int mddev_trylock(mddev_t * mddev) | 291 | static inline int mddev_trylock(mddev_t * mddev) |
287 | { | 292 | { |
288 | return mutex_trylock(&mddev->reconfig_mutex); | 293 | return mutex_trylock(&mddev->reconfig_mutex); |
@@ -2256,7 +2261,7 @@ action_store(mddev_t *mddev, const char *page, size_t len) | |||
2256 | } else { | 2261 | } else { |
2257 | if (cmd_match(page, "check")) | 2262 | if (cmd_match(page, "check")) |
2258 | set_bit(MD_RECOVERY_CHECK, &mddev->recovery); | 2263 | set_bit(MD_RECOVERY_CHECK, &mddev->recovery); |
2259 | else if (cmd_match(page, "repair")) | 2264 | else if (!cmd_match(page, "repair")) |
2260 | return -EINVAL; | 2265 | return -EINVAL; |
2261 | set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); | 2266 | set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); |
2262 | set_bit(MD_RECOVERY_SYNC, &mddev->recovery); | 2267 | set_bit(MD_RECOVERY_SYNC, &mddev->recovery); |
@@ -2457,9 +2462,11 @@ md_attr_show(struct kobject *kobj, struct attribute *attr, char *page) | |||
2457 | 2462 | ||
2458 | if (!entry->show) | 2463 | if (!entry->show) |
2459 | return -EIO; | 2464 | return -EIO; |
2460 | mddev_lock(mddev); | 2465 | rv = mddev_lock(mddev); |
2461 | rv = entry->show(mddev, page); | 2466 | if (!rv) { |
2462 | mddev_unlock(mddev); | 2467 | rv = entry->show(mddev, page); |
2468 | mddev_unlock(mddev); | ||
2469 | } | ||
2463 | return rv; | 2470 | return rv; |
2464 | } | 2471 | } |
2465 | 2472 | ||
@@ -2473,9 +2480,11 @@ md_attr_store(struct kobject *kobj, struct attribute *attr, | |||
2473 | 2480 | ||
2474 | if (!entry->store) | 2481 | if (!entry->store) |
2475 | return -EIO; | 2482 | return -EIO; |
2476 | mddev_lock(mddev); | 2483 | rv = mddev_lock(mddev); |
2477 | rv = entry->store(mddev, page, length); | 2484 | if (!rv) { |
2478 | mddev_unlock(mddev); | 2485 | rv = entry->store(mddev, page, length); |
2486 | mddev_unlock(mddev); | ||
2487 | } | ||
2479 | return rv; | 2488 | return rv; |
2480 | } | 2489 | } |
2481 | 2490 | ||
@@ -4149,7 +4158,7 @@ void md_error(mddev_t *mddev, mdk_rdev_t *rdev) | |||
4149 | set_bit(MD_RECOVERY_INTR, &mddev->recovery); | 4158 | set_bit(MD_RECOVERY_INTR, &mddev->recovery); |
4150 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); | 4159 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); |
4151 | md_wakeup_thread(mddev->thread); | 4160 | md_wakeup_thread(mddev->thread); |
4152 | md_new_event(mddev); | 4161 | md_new_event_inintr(mddev); |
4153 | } | 4162 | } |
4154 | 4163 | ||
4155 | /* seq_file implementation /proc/mdstat */ | 4164 | /* seq_file implementation /proc/mdstat */ |
@@ -4340,8 +4349,9 @@ static int md_seq_show(struct seq_file *seq, void *v) | |||
4340 | return 0; | 4349 | return 0; |
4341 | } | 4350 | } |
4342 | 4351 | ||
4343 | if (mddev_lock(mddev)!=0) | 4352 | if (mddev_lock(mddev) < 0) |
4344 | return -EINTR; | 4353 | return -EINTR; |
4354 | |||
4345 | if (mddev->pers || mddev->raid_disks || !list_empty(&mddev->disks)) { | 4355 | if (mddev->pers || mddev->raid_disks || !list_empty(&mddev->disks)) { |
4346 | seq_printf(seq, "%s : %sactive", mdname(mddev), | 4356 | seq_printf(seq, "%s : %sactive", mdname(mddev), |
4347 | mddev->pers ? "" : "in"); | 4357 | mddev->pers ? "" : "in"); |
@@ -5027,8 +5037,10 @@ static int md_notify_reboot(struct notifier_block *this, | |||
5027 | printk(KERN_INFO "md: stopping all md devices.\n"); | 5037 | printk(KERN_INFO "md: stopping all md devices.\n"); |
5028 | 5038 | ||
5029 | ITERATE_MDDEV(mddev,tmp) | 5039 | ITERATE_MDDEV(mddev,tmp) |
5030 | if (mddev_trylock(mddev)) | 5040 | if (mddev_trylock(mddev)) { |
5031 | do_md_stop (mddev, 1); | 5041 | do_md_stop (mddev, 1); |
5042 | mddev_unlock(mddev); | ||
5043 | } | ||
5032 | /* | 5044 | /* |
5033 | * certain more exotic SCSI devices are known to be | 5045 | * certain more exotic SCSI devices are known to be |
5034 | * volatile wrt too early system reboots. While the | 5046 | * volatile wrt too early system reboots. While the |