aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-12-13 20:49:54 -0500
committerNeilBrown <neilb@suse.de>2009-12-13 20:51:41 -0500
commitf6af949c5672115313cc3c976d85b0533f607d7e (patch)
tree6d00471bd4ee7c3aee67f9ad4c0a3023109b88e0 /drivers/md
parent9cd30fdc33cde9ae4ac55a1ccbbb89f3f7b9b2f2 (diff)
md: support bitmap offset appropriate for external-metadata arrays.
For md arrays were metadata is managed externally, the kernel does not know about a superblock so the superblock offset is 0. If we want to have a write-intent-bitmap near the end of the devices of such an array, we should support sector_t sized offset. We need offset be possibly negative for when the bitmap is before the metadata, so use loff_t instead. Also add sanity check that bitmap does not overlap with data. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/bitmap.c14
-rw-r--r--drivers/md/md.h6
2 files changed, 15 insertions, 5 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index b1bcd36ca963..958865445f06 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -212,7 +212,7 @@ static void bitmap_checkfree(struct bitmap *bitmap, unsigned long page)
212 */ 212 */
213 213
214/* IO operations when bitmap is stored near all superblocks */ 214/* IO operations when bitmap is stored near all superblocks */
215static struct page *read_sb_page(mddev_t *mddev, long offset, 215static struct page *read_sb_page(mddev_t *mddev, loff_t offset,
216 struct page *page, 216 struct page *page,
217 unsigned long index, int size) 217 unsigned long index, int size)
218{ 218{
@@ -287,14 +287,22 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
287 287
288 while ((rdev = next_active_rdev(rdev, mddev)) != NULL) { 288 while ((rdev = next_active_rdev(rdev, mddev)) != NULL) {
289 int size = PAGE_SIZE; 289 int size = PAGE_SIZE;
290 long offset = mddev->bitmap_info.offset; 290 loff_t offset = mddev->bitmap_info.offset;
291 if (page->index == bitmap->file_pages-1) 291 if (page->index == bitmap->file_pages-1)
292 size = roundup(bitmap->last_page_size, 292 size = roundup(bitmap->last_page_size,
293 bdev_logical_block_size(rdev->bdev)); 293 bdev_logical_block_size(rdev->bdev));
294 /* Just make sure we aren't corrupting data or 294 /* Just make sure we aren't corrupting data or
295 * metadata 295 * metadata
296 */ 296 */
297 if (offset < 0) { 297 if (mddev->external) {
298 /* Bitmap could be anywhere. */
299 if (rdev->sb_start + offset + (page->index *(PAGE_SIZE/512)) >
300 rdev->data_offset &&
301 rdev->sb_start + offset <
302 rdev->data_offset + mddev->dev_sectors +
303 (PAGE_SIZE/512))
304 goto bad_alignment;
305 } else if (offset < 0) {
298 /* DATA BITMAP METADATA */ 306 /* DATA BITMAP METADATA */
299 if (offset 307 if (offset
300 + (long)(page->index * (PAGE_SIZE/512)) 308 + (long)(page->index * (PAGE_SIZE/512))
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 4b07e0ab3841..df692953a12f 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -282,11 +282,13 @@ struct mddev_s
282 struct bitmap *bitmap; /* the bitmap for the device */ 282 struct bitmap *bitmap; /* the bitmap for the device */
283 struct { 283 struct {
284 struct file *file; /* the bitmap file */ 284 struct file *file; /* the bitmap file */
285 long offset; /* offset from superblock of 285 loff_t offset; /* offset from superblock of
286 * start of bitmap. May be 286 * start of bitmap. May be
287 * negative, but not '0' 287 * negative, but not '0'
288 * For external metadata, offset
289 * from start of device.
288 */ 290 */
289 long default_offset; /* this is the offset to use when 291 loff_t default_offset; /* this is the offset to use when
290 * hot-adding a bitmap. It should 292 * hot-adding a bitmap. It should
291 * eventually be settable by sysfs. 293 * eventually be settable by sysfs.
292 */ 294 */