super1: don't allow adding a bitmap if there is no space.

If the data is too close to the superblock there may be
no space for a bitmap.
If that happens, fail the adding of the bitmap rather than
corrupt data.

Reported-by:  Lars Wijtemans <rhelbugzilla@lars.wijtemans.nl>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=922944
This commit is contained in:
NeilBrown 2014-08-15 15:45:54 +10:00
parent 73ff073271
commit 268cccac2e
1 changed files with 4 additions and 0 deletions

View File

@ -2105,6 +2105,10 @@ add_internal_bitmap1(struct supertype *st,
/* Limit to 128K of bitmap when chunk size not requested */
room = 128*2;
if (room <= 1)
/* No room for a bitmap */
return 0;
max_bits = (room * 512 - sizeof(bitmap_super_t)) * 8;
min_chunk = 4096; /* sub-page chunks don't work yet.. */