aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bitmap.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-05-11 00:26:30 -0400
committerNeilBrown <neilb@suse.de>2011-05-11 00:26:30 -0400
commit8258c53208d7a9b7207e7d4dae36d2ea384cb278 (patch)
tree8ae5e67cde859e16dcc663c49269d025b9f6ce4b /drivers/md/bitmap.c
parentbedd86b7773fd97f0d708cc0c371c8963ba7ba9a (diff)
md/bitmap: fix saving of events_cleared and other state.
If a bitmap is found to be 'stale' the events_cleared value is set to match 'events'. However if the array is degraded this does not get stored on disk. This can subsequently lead to incorrect behaviour. So change bitmap_update_sb to always update events_cleared in the superblock from the known events_cleared. For neatness also set ->state from ->flags. This requires updating ->state whenever we update ->flags, which makes sense anyway. This is suitable for any active -stable release. cc: stable@kernel.org Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r--drivers/md/bitmap.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 5c9362792f1d..70bd738b8b99 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -493,11 +493,11 @@ void bitmap_update_sb(struct bitmap *bitmap)
493 spin_unlock_irqrestore(&bitmap->lock, flags); 493 spin_unlock_irqrestore(&bitmap->lock, flags);
494 sb = kmap_atomic(bitmap->sb_page, KM_USER0); 494 sb = kmap_atomic(bitmap->sb_page, KM_USER0);
495 sb->events = cpu_to_le64(bitmap->mddev->events); 495 sb->events = cpu_to_le64(bitmap->mddev->events);
496 if (bitmap->mddev->events < bitmap->events_cleared) { 496 if (bitmap->mddev->events < bitmap->events_cleared)
497 /* rocking back to read-only */ 497 /* rocking back to read-only */
498 bitmap->events_cleared = bitmap->mddev->events; 498 bitmap->events_cleared = bitmap->mddev->events;
499 sb->events_cleared = cpu_to_le64(bitmap->events_cleared); 499 sb->events_cleared = cpu_to_le64(bitmap->events_cleared);
500 } 500 sb->state = cpu_to_le32(bitmap->flags);
501 /* Just in case these have been changed via sysfs: */ 501 /* Just in case these have been changed via sysfs: */
502 sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ); 502 sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ);
503 sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind); 503 sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind);
@@ -618,7 +618,7 @@ success:
618 if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN) 618 if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN)
619 bitmap->flags |= BITMAP_HOSTENDIAN; 619 bitmap->flags |= BITMAP_HOSTENDIAN;
620 bitmap->events_cleared = le64_to_cpu(sb->events_cleared); 620 bitmap->events_cleared = le64_to_cpu(sb->events_cleared);
621 if (sb->state & cpu_to_le32(BITMAP_STALE)) 621 if (bitmap->flags & BITMAP_STALE)
622 bitmap->events_cleared = bitmap->mddev->events; 622 bitmap->events_cleared = bitmap->mddev->events;
623 err = 0; 623 err = 0;
624out: 624out:
@@ -652,9 +652,11 @@ static int bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
652 switch (op) { 652 switch (op) {
653 case MASK_SET: 653 case MASK_SET:
654 sb->state |= cpu_to_le32(bits); 654 sb->state |= cpu_to_le32(bits);
655 bitmap->flags |= bits;
655 break; 656 break;
656 case MASK_UNSET: 657 case MASK_UNSET:
657 sb->state &= cpu_to_le32(~bits); 658 sb->state &= cpu_to_le32(~bits);
659 bitmap->flags &= ~bits;
658 break; 660 break;
659 default: 661 default:
660 BUG(); 662 BUG();