[PATCH] md: Fix badness in sysfs_notify caused by md_new_event

From: NeilBrown <neilb@suse.de>

If an error is reported by a drive in a RAID array (which is done via
bi_end_io - in interrupt context), we call md_error and md_new_event which
calls sysfs_notify. However sysfs_notify grabs a mutex and so cannot be
called in interrupt context.

This patch just creates a variant of md_new_event which avoids the sysfs
call, and uses that. A better fix for later is to arrange for the event to
be called from user-context.

Note: avoiding the sysfs call isn't a problem as an error will not, by
itself, modify the sync_action attribute. (We do still need to
wake_up(&md_event_waiters) as an error by itself will modify /proc/mdstat).

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by NeilBrown and committed by Linus Torvalds c331eb04 a835fa79

+10 -1
+10 -1
drivers/md/md.c
··· 167 167 } 168 168 EXPORT_SYMBOL_GPL(md_new_event); 169 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 + 170 179 /* 171 180 * Enables to iterate over all existing md arrays 172 181 * all_mddevs_lock protects this list. ··· 4158 4149 set_bit(MD_RECOVERY_INTR, &mddev->recovery); 4159 4150 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 4160 4151 md_wakeup_thread(mddev->thread); 4161 - md_new_event(mddev); 4152 + md_new_event_inintr(mddev); 4162 4153 } 4163 4154 4164 4155 /* seq_file implementation /proc/mdstat */