Package: mdadm
Version: 3.3-2
Followup-For: Bug #763080

Hi,

attached a patch to make --force work with my reshaping array. The
problem seems to be that load_devices fills in the best array only for
every second slot (and makes it 4 times as big as needed):

mdadm: best[0] = 0
mdadm: best[1] = -1
mdadm: best[2] = 1
mdadm: best[3] = -1
mdadm: best[4] = 2
mdadm: best[5] = -1
mdadm: best[6] = 3
mdadm: best[7] = -1
mdadm: best[8] = 4
mdadm: best[9] = -1
mdadm: best[10] = 5
mdadm: best[11] = -1
mdadm: best[12] = -1
mdadm: best[13] = -1
mdadm: best[14] = -1
mdadm: best[15] = -1
mdadm: best[16] = -1
mdadm: best[17] = -1
mdadm: best[18] = -1
mdadm: best[19] = -1

And then when force_array only checks up to the number of disks in the
array it misses half of them. In my case exactly those it should be
forcing.

MfG
        Goswin

-- Package-specific info:
-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.14-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=de_DE (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash

Versions of packages mdadm depends on:
ii  debconf      1.5.53
ii  initscripts  2.88dsf-53
ii  libc6        2.19-1
ii  lsb-base     4.1+Debian12
ii  makedev      2.3.1-93
ii  udev         204-10

Versions of packages mdadm recommends:
ii  exim4-daemon-heavy [mail-transport-agent]  4.82-8
ii  module-init-tools                          16-2

mdadm suggests no packages.

-- debconf information excluded
Description: Fix --force option for a reshaping array
 On a reshaping array the --force option can't find a suitable drive to
 force because it does not test all the available drives in the best array.
 For some reason only every second entry is filled in and only the first
 half gets tested when going by disk count instead of bestcnt.
 .
 This might also happen with normal arrays, I've only tested it on the one
 broken array I have here.
Author: Goswin von Brederlow <goswin-...@web.de>

---
--- mdadm-3.3.orig/Assemble.c
+++ mdadm-3.3/Assemble.c
@@ -803,7 +803,7 @@ static int force_array(struct mdinfo *co
 		int chosen_drive = -1;
 		int i;
 
-		for (i = 0; i < content->array.raid_disks && i < bestcnt; i++) {
+		for (i = 0; i < bestcnt; i++) {
 			int j = best[i];
 			if (j>=0 &&
 			    !devices[j].uptodate &&
@@ -813,8 +813,10 @@ static int force_array(struct mdinfo *co
 			     > devices[chosen_drive].i.events))
 				chosen_drive = j;
 		}
-		if (chosen_drive < 0)
+		if (chosen_drive < 0) {
+			pr_err("couldn't choose a drive to force\n");
 			break;
+		}
 		current_events = devices[chosen_drive].i.events;
 	add_another:
 		if (c->verbose >= 0)

Reply via email to