diff options
author | Neil Brown <neilb@suse.de> | 2006-05-15 04:21:33 +0000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2006-05-15 04:21:33 +0000 |
commit | 1bfdbe01ff300ebbf92d68c15722d2ba861aac3b (patch) | |
tree | cc0f64dabdaddf62383a377f317ad0e2b94dc9ce /bitmap.c | |
parent | 8686f3ed069671e5cbf8660cfd73c92b066563d0 (diff) | |
download | mdadm-1bfdbe01ff300ebbf92d68c15722d2ba861aac3b.tar.gz |
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.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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; |