Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 305942
b: refs/heads/master
c: 9b1215c
h: refs/heads/master
v: v3
  • Loading branch information
NeilBrown committed May 22, 2012
1 parent 9e55631 commit b3c000a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1ec885cdd01a9ad867dbb9fd32a1bfcc0875c486
refs/heads/master: 9b1215c102d4b12f6c815d7fdd35d0628db35b28
16 changes: 9 additions & 7 deletions trunk/drivers/md/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

if (page->index == store->file_pages-1)
size = roundup(store->last_page_size,
if (page->index == store->file_pages-1) {
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));
}
/* Just make sure we aren't corrupting data or
* metadata
*/
Expand Down Expand Up @@ -973,6 +977,8 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
if (!bitmap->mddev->bitmap_info.external)
bytes += sizeof(bitmap_super_t);

store->bytes = bytes;

num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE);

if (file && i_size_read(file->f_mapping->host) < bytes) {
Expand Down Expand Up @@ -1042,8 +1048,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)

oldindex = index;

store->last_page_size = count;

if (outofdate) {
/*
* if bitmap is out of date, dirty the
Expand Down Expand Up @@ -1965,9 +1969,7 @@ space_store(struct mddev *mddev, const char *buf, size_t len)
return -EINVAL;

if (mddev->bitmap &&
sectors < ((mddev->bitmap->storage.file_pages - 1)
* PAGE_SIZE
+ mddev->bitmap->storage.last_page_size + 511) >> 9)
sectors < (mddev->bitmap->storage.bytes + 511) >> 9)
return -EFBIG; /* Bitmap is too big for this small space */

/* could make sure it isn't too big, but that isn't really
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/md/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ struct bitmap {
unsigned long *filemap_attr; /* attributes associated
* w/ filemap pages */
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;

unsigned long flags;
Expand Down

0 comments on commit b3c000a

Please sign in to comment.