aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/bitmap.c7
-rw-r--r--drivers/md/bitmap.h4
2 files changed, 10 insertions, 1 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 8f681da00277..15dbe03117e4 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -423,6 +423,8 @@ void bitmap_update_sb(struct bitmap *bitmap)
423 /* This might have been changed by a reshape */ 423 /* This might have been changed by a reshape */
424 sb->sync_size = cpu_to_le64(bitmap->mddev->resync_max_sectors); 424 sb->sync_size = cpu_to_le64(bitmap->mddev->resync_max_sectors);
425 sb->chunksize = cpu_to_le32(bitmap->mddev->bitmap_info.chunksize); 425 sb->chunksize = cpu_to_le32(bitmap->mddev->bitmap_info.chunksize);
426 sb->sectors_reserved = cpu_to_le32(bitmap->mddev->
427 bitmap_info.space);
426 kunmap_atomic(sb); 428 kunmap_atomic(sb);
427 write_page(bitmap, bitmap->storage.sb_page, 1); 429 write_page(bitmap, bitmap->storage.sb_page, 1);
428} 430}
@@ -536,6 +538,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
536 bitmap_super_t *sb; 538 bitmap_super_t *sb;
537 unsigned long chunksize, daemon_sleep, write_behind; 539 unsigned long chunksize, daemon_sleep, write_behind;
538 unsigned long long events; 540 unsigned long long events;
541 unsigned long sectors_reserved = 0;
539 int err = -EINVAL; 542 int err = -EINVAL;
540 struct page *sb_page; 543 struct page *sb_page;
541 544
@@ -573,6 +576,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
573 chunksize = le32_to_cpu(sb->chunksize); 576 chunksize = le32_to_cpu(sb->chunksize);
574 daemon_sleep = le32_to_cpu(sb->daemon_sleep) * HZ; 577 daemon_sleep = le32_to_cpu(sb->daemon_sleep) * HZ;
575 write_behind = le32_to_cpu(sb->write_behind); 578 write_behind = le32_to_cpu(sb->write_behind);
579 sectors_reserved = le32_to_cpu(sb->sectors_reserved);
576 580
577 /* verify that the bitmap-specific fields are valid */ 581 /* verify that the bitmap-specific fields are valid */
578 if (sb->magic != cpu_to_le32(BITMAP_MAGIC)) 582 if (sb->magic != cpu_to_le32(BITMAP_MAGIC))
@@ -633,6 +637,9 @@ out_no_sb:
633 bitmap->mddev->bitmap_info.chunksize = chunksize; 637 bitmap->mddev->bitmap_info.chunksize = chunksize;
634 bitmap->mddev->bitmap_info.daemon_sleep = daemon_sleep; 638 bitmap->mddev->bitmap_info.daemon_sleep = daemon_sleep;
635 bitmap->mddev->bitmap_info.max_write_behind = write_behind; 639 bitmap->mddev->bitmap_info.max_write_behind = write_behind;
640 if (bitmap->mddev->bitmap_info.space == 0 ||
641 bitmap->mddev->bitmap_info.space > sectors_reserved)
642 bitmap->mddev->bitmap_info.space = sectors_reserved;
636 if (err) 643 if (err)
637 bitmap_print_sb(bitmap); 644 bitmap_print_sb(bitmap);
638 return err; 645 return err;
diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h
index 04dcde3871be..df4aeb6ac6f0 100644
--- a/drivers/md/bitmap.h
+++ b/drivers/md/bitmap.h
@@ -128,8 +128,10 @@ typedef struct bitmap_super_s {
128 __le32 chunksize; /* 52 the bitmap chunk size in bytes */ 128 __le32 chunksize; /* 52 the bitmap chunk size in bytes */
129 __le32 daemon_sleep; /* 56 seconds between disk flushes */ 129 __le32 daemon_sleep; /* 56 seconds between disk flushes */
130 __le32 write_behind; /* 60 number of outstanding write-behind writes */ 130 __le32 write_behind; /* 60 number of outstanding write-behind writes */
131 __le32 sectors_reserved; /* 64 number of 512-byte sectors that are
132 * reserved for the bitmap. */
131 133
132 __u8 pad[256 - 64]; /* set to zero */ 134 __u8 pad[256 - 68]; /* set to zero */
133} bitmap_super_t; 135} bitmap_super_t;
134 136
135/* notes: 137/* notes: