Skip to content

Commit 1176568

Browse files
committed
md: restore ability of spare drives to spin down.
Some time ago we stopped the clean/active metadata updates from being written to a 'spare' device in most cases so that it could spin down and say spun down. Device failure/removal etc are still recorded on spares. However commit 51d5668 broke this 50% of the time, depending on whether the event count is even or odd. The change log entry said: This means that the alignment between 'odd/even' and 'clean/dirty' might take a little longer to attain, how ever the code makes no attempt to create that alignment, so it could take arbitrarily long. So when we find that clean/dirty is not aligned with odd/even, force a second metadata-update immediately. There are already cases where a second metadata-update is needed immediately (e.g. when a device fails during the metadata update). We just piggy-back on that. Reported-by: Joe Bryant <tenminjoe@yahoo.com> Signed-off-by: NeilBrown <neilb@suse.de> Cc: stable@kernel.org
1 parent 87aa630 commit 1176568

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/md/md.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,12 +2109,18 @@ static void md_update_sb(mddev_t * mddev, int force_change)
21092109
if (!mddev->in_sync || mddev->recovery_cp != MaxSector) { /* not clean */
21102110
/* .. if the array isn't clean, an 'even' event must also go
21112111
* to spares. */
2112-
if ((mddev->events&1)==0)
2112+
if ((mddev->events&1)==0) {
21132113
nospares = 0;
2114+
sync_req = 2; /* force a second update to get the
2115+
* even/odd in sync */
2116+
}
21142117
} else {
21152118
/* otherwise an 'odd' event must go to spares */
2116-
if ((mddev->events&1))
2119+
if ((mddev->events&1)) {
21172120
nospares = 0;
2121+
sync_req = 2; /* force a second update to get the
2122+
* even/odd in sync */
2123+
}
21182124
}
21192125
}
21202126

0 commit comments

Comments
 (0)