diff options
author | NeilBrown <neilb@suse.de> | 2009-08-12 19:54:02 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-08-12 19:54:02 -0400 |
commit | 51d5668cb2e3fd1827a55184e48606fff054c5be (patch) | |
tree | 117824cc3a25c04c939856578105c6c93af6ac8b | |
parent | c8c00a6915a2e3d10416e8bdd3138429beb96210 (diff) |
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: NeilBrown <neilb@suse.de>
-rw-r--r-- | drivers/md/md.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 5614500092e3..d18805fea111 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1975,17 +1975,14 @@ repeat: | |||
1975 | /* otherwise we have to go forward and ... */ | 1975 | /* otherwise we have to go forward and ... */ |
1976 | mddev->events ++; | 1976 | mddev->events ++; |
1977 | if (!mddev->in_sync || mddev->recovery_cp != MaxSector) { /* not clean */ | 1977 | if (!mddev->in_sync || mddev->recovery_cp != MaxSector) { /* not clean */ |
1978 | /* .. if the array isn't clean, insist on an odd 'events' */ | 1978 | /* .. if the array isn't clean, an 'even' event must also go |
1979 | if ((mddev->events&1)==0) { | 1979 | * to spares. */ |
1980 | mddev->events++; | 1980 | if ((mddev->events&1)==0) |
1981 | nospares = 0; | 1981 | nospares = 0; |
1982 | } | ||
1983 | } else { | 1982 | } else { |
1984 | /* otherwise insist on an even 'events' (for clean states) */ | 1983 | /* otherwise an 'odd' event must go to spares */ |
1985 | if ((mddev->events&1)) { | 1984 | if ((mddev->events&1)) |
1986 | mddev->events++; | ||
1987 | nospares = 0; | 1985 | nospares = 0; |
1988 | } | ||
1989 | } | 1986 | } |
1990 | } | 1987 | } |
1991 | 1988 | ||