md/bitmap: store bytes in file rather than just in last page.

This number is more generally useful, and bytes-in-last-page is
easily extracted from it.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2012-05-22 13:55:11 +10:00
parent 1ec885cdd0
commit 9b1215c102
2 changed files with 10 additions and 8 deletions

View File

@ -203,9 +203,13 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev; bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev;
if (page->index == store->file_pages-1) if (page->index == store->file_pages-1) {
size = roundup(store->last_page_size, int last_page_size = store->bytes & (PAGE_SIZE-1);
if (last_page_size == 0)
last_page_size = PAGE_SIZE;
size = roundup(last_page_size,
bdev_logical_block_size(bdev)); bdev_logical_block_size(bdev));
}
/* Just make sure we aren't corrupting data or /* Just make sure we aren't corrupting data or
* metadata * metadata
*/ */
@ -973,6 +977,8 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
if (!bitmap->mddev->bitmap_info.external) if (!bitmap->mddev->bitmap_info.external)
bytes += sizeof(bitmap_super_t); bytes += sizeof(bitmap_super_t);
store->bytes = bytes;
num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE); num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE);
if (file && i_size_read(file->f_mapping->host) < bytes) { 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)
oldindex = index; oldindex = index;
store->last_page_size = count;
if (outofdate) { if (outofdate) {
/* /*
* if bitmap is out of date, dirty the * if bitmap is out of date, dirty the
@ -1965,9 +1969,7 @@ space_store(struct mddev *mddev, const char *buf, size_t len)
return -EINVAL; return -EINVAL;
if (mddev->bitmap && if (mddev->bitmap &&
sectors < ((mddev->bitmap->storage.file_pages - 1) sectors < (mddev->bitmap->storage.bytes + 511) >> 9)
* PAGE_SIZE
+ mddev->bitmap->storage.last_page_size + 511) >> 9)
return -EFBIG; /* Bitmap is too big for this small space */ return -EFBIG; /* Bitmap is too big for this small space */
/* could make sure it isn't too big, but that isn't really /* could make sure it isn't too big, but that isn't really

View File

@ -197,7 +197,7 @@ struct bitmap {
unsigned long *filemap_attr; /* attributes associated unsigned long *filemap_attr; /* attributes associated
* w/ filemap pages */ * w/ filemap pages */
unsigned long file_pages; /* number of pages in the file*/ unsigned long file_pages; /* number of pages in the file*/
int last_page_size; /* bytes in the last page */ unsigned long bytes; /* total bytes in the bitmap */
} storage; } storage;
unsigned long flags; unsigned long flags;