diff options
author | Hou Tao <houtao1@huawei.com> | 2017-11-06 10:11:25 +0800 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2017-11-09 07:30:50 -0800 |
commit | 97f0eb9f0fec0563c1c796d95123e871b8bb65c0 (patch) | |
tree | 083bd0c08b7f665b762a84ff3142b3d62fbc4509 /drivers/md | |
parent | db0505d320660b6ad92418847e7eca6b61b246ac (diff) | |
download | linux-97f0eb9f0fec0563c1c796d95123e871b8bb65c0.tar.gz linux-97f0eb9f0fec0563c1c796d95123e871b8bb65c0.tar.bz2 linux-97f0eb9f0fec0563c1c796d95123e871b8bb65c0.zip |
md/bitmap: clear BITMAP_WRITE_ERROR bit before writing it to sb
For a RAID1 device using a file-based bitmap, if a bitmap write error
occurs but the later writes succeed, it's possible both BITMAP_STALE
and BITMAP_WRITE_ERROR bits will be written to the bitmap super block,
the BITMAP_STALE bit will be handled properly and be cleared, but the
BITMAP_WRITE_ERROR bit in sb->flags will make bitmap_create() to fail.
So clear it to protect against the write failure-and-then-recovery case.
Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md-bitmap.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index d1b3b60669ea..a60e46529d9f 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -459,7 +459,11 @@ void bitmap_update_sb(struct bitmap *bitmap) /* rocking back to read-only */ bitmap->events_cleared = bitmap->mddev->events; sb->events_cleared = cpu_to_le64(bitmap->events_cleared); - sb->state = cpu_to_le32(bitmap->flags); + /* + * clear BITMAP_WRITE_ERROR bit to protect against the case that + * a bitmap write error occurred but the later writes succeeded. + */ + sb->state = cpu_to_le32(bitmap->flags & ~BIT(BITMAP_WRITE_ERROR)); /* Just in case these have been changed via sysfs: */ sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ); sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind); |