mdadm/bitmap-4k-boundary.patch

41 lines
1.2 KiB
Diff
Raw Normal View History

From: NeilBrown <neilb@suse.de>
Some devices (dasd!) have 4K sectors, so metadata must be
aligned on 4K boundaries.
superblock already is, but bitmap might not be. So force the
bitmap to a 4K boundary for v1.x metadata
It already is for v1.1 and v1.2, so just fix for v1.0
(Note that v0.90 already uses a 4K boundary too).
Signed-off-by: NeilBrown <neilb@suse.de>
diff --git a/super1.c b/super1.c
index fee22a9..66e9771 100644
--- a/super1.c
+++ b/super1.c
@@ -1437,11 +1437,6 @@ add_internal_bitmap1(struct supertype *st,
*/
offset = 0;
room = choose_bm_space(__le64_to_cpu(sb->size));
- if (room == 4*2) {
- /* make it 3K after the superblock */
- room = 3*2;
- offset = 2;
- }
} else {
room = __le64_to_cpu(sb->super_offset)
- __le64_to_cpu(sb->data_offset)
@@ -1498,8 +1493,9 @@ add_internal_bitmap1(struct supertype *st,
if (offset == 0) {
bits = (size*512) / chunk + 1;
- room = ((bits+7)/8 + sizeof(bitmap_super_t) +511)/512;
- offset = -room;
+ /* Align bitmap space to a 4K boundary as some devices need that */
+ room = ((bits+7)/8 + sizeof(bitmap_super_t) +4095)/4096;
+ offset = -room * 8; /* *8 to convert 4K blocks to sectors */
}
sb->bitmap_offset = __cpu_to_le32(offset);