summaryrefslogtreecommitdiffstats
path: root/super1.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2008-04-29 17:13:53 +1000
committerNeil Brown <neilb@suse.de>2008-04-29 17:13:53 +1000
commit519561f73f7ba987affde8b174d2691bb098439d (patch)
tree2ce0ec3127821bded9355feeb9ccb1ea072e2f2d /super1.c
parent5f98d3cbd9bdff77c59d7bb896af3732a938aa9c (diff)
downloadmdadm-519561f73f7ba987affde8b174d2691bb098439d.tar.gz
mdadm-519561f73f7ba987affde8b174d2691bb098439d.tar.xz
mdadm-519561f73f7ba987affde8b174d2691bb098439d.zip
Fix possible bug with bitmap space allocation with v1.0 metadata
When adding a device to an array, make sure we don't reserve so much space for the bitmap that there isn't room for the data.
Diffstat (limited to 'super1.c')
-rw-r--r--super1.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/super1.c b/super1.c
index 887db10..7ea6958 100644
--- a/super1.c
+++ b/super1.c
@@ -905,7 +905,7 @@ static int write_init_super1(struct supertype *st,
* for a bitmap.
*/
array_size = __le64_to_cpu(sb->size);
- /* work out how much space we left of a bitmap */
+ /* work out how much space we left for a bitmap */
bm_space = choose_bm_space(array_size);
switch(st->minor_version) {
@@ -915,6 +915,8 @@ static int write_init_super1(struct supertype *st,
sb_offset &= ~(4*2-1);
sb->super_offset = __cpu_to_le64(sb_offset);
sb->data_offset = __cpu_to_le64(0);
+ if (sb_offset - bm_space < array_size)
+ bm_space = sb_offset - array_size;
sb->data_size = __cpu_to_le64(sb_offset - bm_space);
break;
case 1: