aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r--drivers/md/bitmap.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index c98f2fee1bd0..7a3be0d4103e 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -203,9 +203,13 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
203 203
204 bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev; 204 bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev;
205 205
206 if (page->index == store->file_pages-1) 206 if (page->index == store->file_pages-1) {
207 size = roundup(store->last_page_size, 207 int last_page_size = store->bytes & (PAGE_SIZE-1);
208 if (last_page_size == 0)
209 last_page_size = PAGE_SIZE;
210 size = roundup(last_page_size,
208 bdev_logical_block_size(bdev)); 211 bdev_logical_block_size(bdev));
212 }
209 /* Just make sure we aren't corrupting data or 213 /* Just make sure we aren't corrupting data or
210 * metadata 214 * metadata
211 */ 215 */
@@ -973,6 +977,8 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
973 if (!bitmap->mddev->bitmap_info.external) 977 if (!bitmap->mddev->bitmap_info.external)
974 bytes += sizeof(bitmap_super_t); 978 bytes += sizeof(bitmap_super_t);
975 979
980 store->bytes = bytes;
981
976 num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE); 982 num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE);
977 983
978 if (file && i_size_read(file->f_mapping->host) < bytes) { 984 if (file && i_size_read(file->f_mapping->host) < bytes) {
@@ -1042,8 +1048,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
1042 1048
1043 oldindex = index; 1049 oldindex = index;
1044 1050
1045 store->last_page_size = count;
1046
1047 if (outofdate) { 1051 if (outofdate) {
1048 /* 1052 /*
1049 * if bitmap is out of date, dirty the 1053 * if bitmap is out of date, dirty the
@@ -1965,9 +1969,7 @@ space_store(struct mddev *mddev, const char *buf, size_t len)
1965 return -EINVAL; 1969 return -EINVAL;
1966 1970
1967 if (mddev->bitmap && 1971 if (mddev->bitmap &&
1968 sectors < ((mddev->bitmap->storage.file_pages - 1) 1972 sectors < (mddev->bitmap->storage.bytes + 511) >> 9)
1969 * PAGE_SIZE
1970 + mddev->bitmap->storage.last_page_size + 511) >> 9)
1971 return -EFBIG; /* Bitmap is too big for this small space */ 1973 return -EFBIG; /* Bitmap is too big for this small space */
1972 1974
1973 /* could make sure it isn't too big, but that isn't really 1975 /* could make sure it isn't too big, but that isn't really