diff options
author | NeilBrown <neilb@suse.de> | 2012-05-21 23:55:11 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-05-21 23:55:11 -0400 |
commit | 9b1215c102d4b12f6c815d7fdd35d0628db35b28 (patch) | |
tree | 52f04de53b1b7302535d66820d9f85b0610b0b1f /drivers | |
parent | 1ec885cdd01a9ad867dbb9fd32a1bfcc0875c486 (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/bitmap.c | 16 | ||||
-rw-r--r-- | drivers/md/bitmap.h | 2 |
2 files changed, 10 insertions, 8 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 |
diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h index 162ab095b866..26689260e179 100644 --- a/drivers/md/bitmap.h +++ b/drivers/md/bitmap.h | |||
@@ -197,7 +197,7 @@ struct bitmap { | |||
197 | unsigned long *filemap_attr; /* attributes associated | 197 | unsigned long *filemap_attr; /* attributes associated |
198 | * w/ filemap pages */ | 198 | * w/ filemap pages */ |
199 | unsigned long file_pages; /* number of pages in the file*/ | 199 | unsigned long file_pages; /* number of pages in the file*/ |
200 | int last_page_size; /* bytes in the last page */ | 200 | unsigned long bytes; /* total bytes in the bitmap */ |
201 | } storage; | 201 | } storage; |
202 | 202 | ||
203 | unsigned long flags; | 203 | unsigned long flags; |