Commit 51d5668c authored by NeilBrown's avatar NeilBrown

md: never advance 'events' counter by more than 1.

When assembling arrays, md allows two devices to have different event
counts as long as the difference is only '1'.  This is to cope with
a system failure between updating the metadata on two difference
devices.

However there are currently times when we update the event count by
2.  This was done to keep the event count even when the array is clean
and odd when it is dirty, which allows us to avoid writing common
update to spare devices and so allow those spares to go to sleep.

This is bad for the above reason.  So change it to never increase by
two.  This means that the alignment between 'odd/even' and
'clean/dirty' might take a little longer to attain, but that is only a
small cost.  The spares will get a few more updates but that will
still be spared (;-) most updates and can still go to sleep.

Prior to this patch there was a small chance that after a crash an
array would fail to assemble due to the overly large event count
mismatch.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent c8c00a69
...@@ -1975,19 +1975,16 @@ static void md_update_sb(mddev_t * mddev, int force_change) ...@@ -1975,19 +1975,16 @@ static void md_update_sb(mddev_t * mddev, int force_change)
/* otherwise we have to go forward and ... */ /* otherwise we have to go forward and ... */
mddev->events ++; mddev->events ++;
if (!mddev->in_sync || mddev->recovery_cp != MaxSector) { /* not clean */ if (!mddev->in_sync || mddev->recovery_cp != MaxSector) { /* not clean */
/* .. if the array isn't clean, insist on an odd 'events' */ /* .. if the array isn't clean, an 'even' event must also go
if ((mddev->events&1)==0) { * to spares. */
mddev->events++; if ((mddev->events&1)==0)
nospares = 0; nospares = 0;
}
} else { } else {
/* otherwise insist on an even 'events' (for clean states) */ /* otherwise an 'odd' event must go to spares */
if ((mddev->events&1)) { if ((mddev->events&1))
mddev->events++;
nospares = 0; nospares = 0;
} }
} }
}
if (!mddev->events) { if (!mddev->events) {
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment