summaryrefslogtreecommitdiffstats
path: root/super1.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-02-24 11:31:48 +1100
committerNeilBrown <neilb@suse.de>2010-02-24 11:31:48 +1100
commita31128d2de3c3b60e6cbcceef391479ad3c0cfb4 (patch)
treeb8694b007a1f0ee89c2b9da6f9ab4acdb0971dfd /super1.c
parentb179246f4f519082158279b2f45e5fd51842cc42 (diff)
downloadmdadm-a31128d2de3c3b60e6cbcceef391479ad3c0cfb4.tar.gz
mdadm-a31128d2de3c3b60e6cbcceef391479ad3c0cfb4.tar.xz
mdadm-a31128d2de3c3b60e6cbcceef391479ad3c0cfb4.zip
super1: put bitmap on a 4K boundary when possible.
Some devices have 4K sector sizes. So try to align the bitmap on a 4K boundary. This isn't possible when hot-adding a bitmap, but will be once we add support for configuring the bitmap via sysfs. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'super1.c')
-rw-r--r--super1.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/super1.c b/super1.c
index 40fbb81..7861cf4 100644
--- a/super1.c
+++ b/super1.c
@@ -1445,8 +1445,8 @@ add_internal_bitmap1(struct supertype *st,
switch(st->minor_version) {
case 0:
- /* either 3K after the superblock, or some amount of space
- * before.
+ /* either 3K after the superblock (when hot-add),
+ * or some amount of space before.
*/
if (may_change) {
/* We are creating array, so we *know* how much room has
@@ -1454,11 +1454,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)
@@ -1519,8 +1514,12 @@ add_internal_bitmap1(struct supertype *st,
return 0;
if (offset == 0) {
+ /* start bitmap on a 4K boundary with enough space for
+ * the bitmap
+ */
bits = (size*512) / chunk + 1;
- room = ((bits+7)/8 + sizeof(bitmap_super_t) +511)/512;
+ room = ((bits+7)/8 + sizeof(bitmap_super_t) +4095)/4096;
+ room *= 8; /* convert 4K blocks to sectors */
offset = -room;
}