diff options
author | Guoqing Jiang <gqjiang@suse.com> | 2016-10-12 08:24:07 +0200 |
---|---|---|
committer | Jes Sorensen <Jes.Sorensen@redhat.com> | 2016-10-19 17:21:15 +0200 |
commit | 119b66a47320ea906e43488de719f7173cb7286c (patch) | |
tree | b6100dc8a7c443775a8894afd3ae16e602c1fe7b | |
parent | Fix some issues found by clang (diff) | |
download | mdadm-119b66a47320ea906e43488de719f7173cb7286c.tar.xz mdadm-119b66a47320ea906e43488de719f7173cb7286c.zip |
super1: make write_bitmap1 compatible with previous mdadm versions
For older mdadm version, v1.x metadata has different bitmap_offset,
we can't ensure all the bitmaps are on a 4K boundary since writing
4K for bitmap could corrupt the superblock, and Anthony reported
the bug about it at below link.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=837964
So let's check about the alignment for bitmap_offset before set
the boundary to 4096 unconditionally. Thanks for Neil's detailed
explanation.
Reported-by: Anthony DeRobertis <anthony@derobert.net>
Fixes: 95a05b37e8eb ("Create n bitmaps for clustered mode")
Cc: Neil Brown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
-rw-r--r-- | super1.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -2433,7 +2433,15 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update memset(buf, 0xff, 4096); memcpy(buf, (char *)bms, sizeof(bitmap_super_t)); - towrite = calc_bitmap_size(bms, 4096); + /* + * use 4096 boundary if bitmap_offset is aligned + * with 8 sectors, then it should compatible with + * older mdadm. + */ + if (__le32_to_cpu(sb->bitmap_offset) & 7) + towrite = calc_bitmap_size(bms, 512); + else + towrite = calc_bitmap_size(bms, 4096); while (towrite > 0) { n = towrite; if (n > 4096) |