]>
Commit | Line | Data |
---|---|---|
739e1c91 GKH |
1 | From 9eb07c259207d048e3ee8be2a77b2a4680b1edd4 Mon Sep 17 00:00:00 2001 |
2 | From: NeilBrown <neilb@suse.de> | |
3 | Date: Tue, 9 Feb 2010 12:31:47 +1100 | |
4 | Subject: md: fix 'degraded' calculation when starting a reshape. | |
5 | ||
6 | From: NeilBrown <neilb@suse.de> | |
7 | ||
8 | commit 9eb07c259207d048e3ee8be2a77b2a4680b1edd4 upstream. | |
9 | ||
10 | This code was written long ago when it was not possible to | |
11 | reshape a degraded array. Now it is so the current level of | |
12 | degraded-ness needs to be taken in to account. Also newly addded | |
13 | devices should only reduce degradedness if they are deemed to be | |
14 | in-sync. | |
15 | ||
16 | In particular, if you convert a RAID5 to a RAID6, and increase the | |
17 | number of devices at the same time, then the 5->6 conversion will | |
18 | make the array degraded so the current code will produce a wrong | |
19 | value for 'degraded' - "-1" to be precise. | |
20 | ||
21 | If the reshape runs to completion end_reshape will calculate a correct | |
22 | new value for 'degraded', but if a device fails during the reshape an | |
23 | incorrect decision might be made based on the incorrect value of | |
24 | "degraded". | |
25 | ||
26 | This patch is suitable for 2.6.32-stable and if they are still open, | |
27 | 2.6.31-stable and 2.6.30-stable as well. | |
28 | ||
29 | Reported-by: Michael Evans <mjevans1983@gmail.com> | |
30 | Signed-off-by: NeilBrown <neilb@suse.de> | |
31 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
32 | ||
33 | --- | |
34 | drivers/md/raid5.c | 11 +++++++---- | |
35 | 1 file changed, 7 insertions(+), 4 deletions(-) | |
36 | ||
37 | --- a/drivers/md/raid5.c | |
38 | +++ b/drivers/md/raid5.c | |
39 | @@ -5432,11 +5432,11 @@ static int raid5_start_reshape(mddev_t * | |
40 | !test_bit(Faulty, &rdev->flags)) { | |
41 | if (raid5_add_disk(mddev, rdev) == 0) { | |
42 | char nm[20]; | |
43 | - if (rdev->raid_disk >= conf->previous_raid_disks) | |
44 | + if (rdev->raid_disk >= conf->previous_raid_disks) { | |
45 | set_bit(In_sync, &rdev->flags); | |
46 | - else | |
47 | + added_devices++; | |
48 | + } else | |
49 | rdev->recovery_offset = 0; | |
50 | - added_devices++; | |
51 | sprintf(nm, "rd%d", rdev->raid_disk); | |
52 | if (sysfs_create_link(&mddev->kobj, | |
53 | &rdev->kobj, nm)) | |
54 | @@ -5448,9 +5448,12 @@ static int raid5_start_reshape(mddev_t * | |
55 | break; | |
56 | } | |
57 | ||
58 | + /* When a reshape changes the number of devices, ->degraded | |
59 | + * is measured against the large of the pre and post number of | |
60 | + * devices.*/ | |
61 | if (mddev->delta_disks > 0) { | |
62 | spin_lock_irqsave(&conf->device_lock, flags); | |
63 | - mddev->degraded = (conf->raid_disks - conf->previous_raid_disks) | |
64 | + mddev->degraded += (conf->raid_disks - conf->previous_raid_disks) | |
65 | - added_devices; | |
66 | spin_unlock_irqrestore(&conf->device_lock, flags); | |
67 | } |