You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
[PATCH] md: Improve locking around error handling
The error handling routines don't use proper locking, and so two concurrent
errors could trigger a problem.
So:
- use test-and-set and test-and-clear to synchonise
the In_sync bits with the ->degraded count
- use the spinlock to protect updates to the
degraded count (could use an atomic_t but that
would be a bigger change in code, and isn't
really justified)
- remove un-necessary locking in raid5
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
11ce99e625
commit
c04be0aa82
+8
-4
@@ -950,14 +950,16 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
|
||||
* really dead" tests...
|
||||
*/
|
||||
return;
|
||||
if (test_bit(In_sync, &rdev->flags)) {
|
||||
if (test_and_clear_bit(In_sync, &rdev->flags)) {
|
||||
unsigned long flags;
|
||||
spin_lock_irqsave(&conf->device_lock, flags);
|
||||
mddev->degraded++;
|
||||
spin_unlock_irqrestore(&conf->device_lock, flags);
|
||||
/*
|
||||
* if recovery is running, make sure it aborts.
|
||||
*/
|
||||
set_bit(MD_RECOVERY_ERR, &mddev->recovery);
|
||||
}
|
||||
clear_bit(In_sync, &rdev->flags);
|
||||
set_bit(Faulty, &rdev->flags);
|
||||
set_bit(MD_CHANGE_DEVS, &mddev->flags);
|
||||
printk(KERN_ALERT "raid10: Disk failure on %s, disabling device. \n"
|
||||
@@ -1033,9 +1035,11 @@ static int raid10_spare_active(mddev_t *mddev)
|
||||
tmp = conf->mirrors + i;
|
||||
if (tmp->rdev
|
||||
&& !test_bit(Faulty, &tmp->rdev->flags)
|
||||
&& !test_bit(In_sync, &tmp->rdev->flags)) {
|
||||
&& !test_and_set_bit(In_sync, &tmp->rdev->flags)) {
|
||||
unsigned long flags;
|
||||
spin_lock_irqsave(&conf->device_lock, flags);
|
||||
mddev->degraded--;
|
||||
set_bit(In_sync, &tmp->rdev->flags);
|
||||
spin_unlock_irqrestore(&conf->device_lock, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user