md/bitmap: record the space available for the bitmap in the superblock.
[deliverable/linux.git] / drivers / md / bitmap.c
index a35561f8f57debc6188dc2d075725d8b920da914..15dbe03117e473da9ce6166b6978b7f496b7bc2a 100644 (file)
@@ -420,6 +420,11 @@ void bitmap_update_sb(struct bitmap *bitmap)
        /* Just in case these have been changed via sysfs: */
        sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ);
        sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind);
+       /* This might have been changed by a reshape */
+       sb->sync_size = cpu_to_le64(bitmap->mddev->resync_max_sectors);
+       sb->chunksize = cpu_to_le32(bitmap->mddev->bitmap_info.chunksize);
+       sb->sectors_reserved = cpu_to_le32(bitmap->mddev->
+                                          bitmap_info.space);
        kunmap_atomic(sb);
        write_page(bitmap, bitmap->storage.sb_page, 1);
 }
@@ -533,6 +538,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
        bitmap_super_t *sb;
        unsigned long chunksize, daemon_sleep, write_behind;
        unsigned long long events;
+       unsigned long sectors_reserved = 0;
        int err = -EINVAL;
        struct page *sb_page;
 
@@ -570,6 +576,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
        chunksize = le32_to_cpu(sb->chunksize);
        daemon_sleep = le32_to_cpu(sb->daemon_sleep) * HZ;
        write_behind = le32_to_cpu(sb->write_behind);
+       sectors_reserved = le32_to_cpu(sb->sectors_reserved);
 
        /* verify that the bitmap-specific fields are valid */
        if (sb->magic != cpu_to_le32(BITMAP_MAGIC))
@@ -630,6 +637,9 @@ out_no_sb:
        bitmap->mddev->bitmap_info.chunksize = chunksize;
        bitmap->mddev->bitmap_info.daemon_sleep = daemon_sleep;
        bitmap->mddev->bitmap_info.max_write_behind = write_behind;
+       if (bitmap->mddev->bitmap_info.space == 0 ||
+           bitmap->mddev->bitmap_info.space > sectors_reserved)
+               bitmap->mddev->bitmap_info.space = sectors_reserved;
        if (err)
                bitmap_print_sb(bitmap);
        return err;
This page took 0.030525 seconds and 5 git commands to generate.