]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.32.9/md-fix-degraded-calculation-when-starting-a-reshape.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.9 / md-fix-degraded-calculation-when-starting-a-reshape.patch
CommitLineData
739e1c91
GKH
1From 9eb07c259207d048e3ee8be2a77b2a4680b1edd4 Mon Sep 17 00:00:00 2001
2From: NeilBrown <neilb@suse.de>
3Date: Tue, 9 Feb 2010 12:31:47 +1100
4Subject: md: fix 'degraded' calculation when starting a reshape.
5
6From: NeilBrown <neilb@suse.de>
7
8commit 9eb07c259207d048e3ee8be2a77b2a4680b1edd4 upstream.
9
10This code was written long ago when it was not possible to
11reshape a degraded array. Now it is so the current level of
12degraded-ness needs to be taken in to account. Also newly addded
13devices should only reduce degradedness if they are deemed to be
14in-sync.
15
16In particular, if you convert a RAID5 to a RAID6, and increase the
17number of devices at the same time, then the 5->6 conversion will
18make the array degraded so the current code will produce a wrong
19value for 'degraded' - "-1" to be precise.
20
21If the reshape runs to completion end_reshape will calculate a correct
22new value for 'degraded', but if a device fails during the reshape an
23incorrect decision might be made based on the incorrect value of
24"degraded".
25
26This patch is suitable for 2.6.32-stable and if they are still open,
272.6.31-stable and 2.6.30-stable as well.
28
29Reported-by: Michael Evans <mjevans1983@gmail.com>
30Signed-off-by: NeilBrown <neilb@suse.de>
31Signed-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 }