summaryrefslogtreecommitdiffstats
path: root/bitmap.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-05-15 04:21:33 +0000
committerNeil Brown <neilb@suse.de>2006-05-15 04:21:33 +0000
commit1bfdbe01ff300ebbf92d68c15722d2ba861aac3b (patch)
treecc0f64dabdaddf62383a377f317ad0e2b94dc9ce /bitmap.c
parent8686f3ed069671e5cbf8660cfd73c92b066563d0 (diff)
downloadmdadm-1bfdbe01ff300ebbf92d68c15722d2ba861aac3b.tar.gz
mdadm-1bfdbe01ff300ebbf92d68c15722d2ba861aac3b.tar.xz
mdadm-1bfdbe01ff300ebbf92d68c15722d2ba861aac3b.zip
Limit size of bitmap to 2million chunks.
When creating a file bitmap, choose a default size that results in fewer than 2^21 chunks. Without this kmalloc failure in the kernel becomes likely. Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'bitmap.c')
-rw-r--r--bitmap.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/bitmap.c b/bitmap.c
index 33deab1..75492f7 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -341,6 +341,17 @@ int CreateBitmap(char *filename, int force, char uuid[16],
return rv;
}
+ if (chunksize == UnSet) {
+ /* We don't want more than 2^21 chunks, as 2^11 fill up one
+ * 4K page (2 bytes per chunk), and 2^10 address of those
+ * fill up a 4K indexing page. 2^20 might be safer...
+ */
+ chunksize = DEFAULT_BITMAP_CHUNK;
+ /* <<21 for 2^21 chunks, >>9 to convert bytes to sectors */
+ while (array_size > (chunksize << (21-9)))
+ chunksize <<= 1;
+ }
+
memset(&sb, 0, sizeof(sb));
sb.magic = BITMAP_MAGIC;
sb.version = major;