diff options
author | NeilBrown <neilb@suse.de> | 2009-12-13 20:49:52 -0500 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-12-13 20:51:41 -0500 |
commit | c3d9714e88c8685cf9bc837c3241fc005f95fb82 (patch) | |
tree | dd11e16ec911983bb7452bb4fb092769ba612e3b /drivers/md/md.c | |
parent | 709ae4879ae33628ded276ce7da8cd5acfec476b (diff) |
md: collect bitmap-specific fields into one structure.
In preparation for making bitmap fields configurable via sysfs,
start tidying up by making a single structure to contain the
configuration fields.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 569f25183db6..63da0a51852d 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -463,7 +463,7 @@ static mddev_t * mddev_find(dev_t unit) | |||
463 | 463 | ||
464 | mutex_init(&new->open_mutex); | 464 | mutex_init(&new->open_mutex); |
465 | mutex_init(&new->reconfig_mutex); | 465 | mutex_init(&new->reconfig_mutex); |
466 | mutex_init(&new->bitmap_mutex); | 466 | mutex_init(&new->bitmap_info.mutex); |
467 | INIT_LIST_HEAD(&new->disks); | 467 | INIT_LIST_HEAD(&new->disks); |
468 | INIT_LIST_HEAD(&new->all_mddevs); | 468 | INIT_LIST_HEAD(&new->all_mddevs); |
469 | init_timer(&new->safemode_timer); | 469 | init_timer(&new->safemode_timer); |
@@ -850,7 +850,7 @@ struct super_type { | |||
850 | */ | 850 | */ |
851 | int md_check_no_bitmap(mddev_t *mddev) | 851 | int md_check_no_bitmap(mddev_t *mddev) |
852 | { | 852 | { |
853 | if (!mddev->bitmap_file && !mddev->bitmap_offset) | 853 | if (!mddev->bitmap_info.file && !mddev->bitmap_info.offset) |
854 | return 0; | 854 | return 0; |
855 | printk(KERN_ERR "%s: bitmaps are not supported for %s\n", | 855 | printk(KERN_ERR "%s: bitmaps are not supported for %s\n", |
856 | mdname(mddev), mddev->pers->name); | 856 | mdname(mddev), mddev->pers->name); |
@@ -978,8 +978,8 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev) | |||
978 | mddev->raid_disks = sb->raid_disks; | 978 | mddev->raid_disks = sb->raid_disks; |
979 | mddev->dev_sectors = sb->size * 2; | 979 | mddev->dev_sectors = sb->size * 2; |
980 | mddev->events = ev1; | 980 | mddev->events = ev1; |
981 | mddev->bitmap_offset = 0; | 981 | mddev->bitmap_info.offset = 0; |
982 | mddev->default_bitmap_offset = MD_SB_BYTES >> 9; | 982 | mddev->bitmap_info.default_offset = MD_SB_BYTES >> 9; |
983 | 983 | ||
984 | if (mddev->minor_version >= 91) { | 984 | if (mddev->minor_version >= 91) { |
985 | mddev->reshape_position = sb->reshape_position; | 985 | mddev->reshape_position = sb->reshape_position; |
@@ -1013,8 +1013,9 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1013 | mddev->max_disks = MD_SB_DISKS; | 1013 | mddev->max_disks = MD_SB_DISKS; |
1014 | 1014 | ||
1015 | if (sb->state & (1<<MD_SB_BITMAP_PRESENT) && | 1015 | if (sb->state & (1<<MD_SB_BITMAP_PRESENT) && |
1016 | mddev->bitmap_file == NULL) | 1016 | mddev->bitmap_info.file == NULL) |
1017 | mddev->bitmap_offset = mddev->default_bitmap_offset; | 1017 | mddev->bitmap_info.offset = |
1018 | mddev->bitmap_info.default_offset; | ||
1018 | 1019 | ||
1019 | } else if (mddev->pers == NULL) { | 1020 | } else if (mddev->pers == NULL) { |
1020 | /* Insist on good event counter while assembling */ | 1021 | /* Insist on good event counter while assembling */ |
@@ -1131,7 +1132,7 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1131 | sb->layout = mddev->layout; | 1132 | sb->layout = mddev->layout; |
1132 | sb->chunk_size = mddev->chunk_sectors << 9; | 1133 | sb->chunk_size = mddev->chunk_sectors << 9; |
1133 | 1134 | ||
1134 | if (mddev->bitmap && mddev->bitmap_file == NULL) | 1135 | if (mddev->bitmap && mddev->bitmap_info.file == NULL) |
1135 | sb->state |= (1<<MD_SB_BITMAP_PRESENT); | 1136 | sb->state |= (1<<MD_SB_BITMAP_PRESENT); |
1136 | 1137 | ||
1137 | sb->disks[0].state = (1<<MD_DISK_REMOVED); | 1138 | sb->disks[0].state = (1<<MD_DISK_REMOVED); |
@@ -1209,7 +1210,7 @@ super_90_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors) | |||
1209 | { | 1210 | { |
1210 | if (num_sectors && num_sectors < rdev->mddev->dev_sectors) | 1211 | if (num_sectors && num_sectors < rdev->mddev->dev_sectors) |
1211 | return 0; /* component must fit device */ | 1212 | return 0; /* component must fit device */ |
1212 | if (rdev->mddev->bitmap_offset) | 1213 | if (rdev->mddev->bitmap_info.offset) |
1213 | return 0; /* can't move bitmap */ | 1214 | return 0; /* can't move bitmap */ |
1214 | rdev->sb_start = calc_dev_sboffset(rdev->bdev); | 1215 | rdev->sb_start = calc_dev_sboffset(rdev->bdev); |
1215 | if (!num_sectors || num_sectors > rdev->sb_start) | 1216 | if (!num_sectors || num_sectors > rdev->sb_start) |
@@ -1388,8 +1389,8 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1388 | mddev->raid_disks = le32_to_cpu(sb->raid_disks); | 1389 | mddev->raid_disks = le32_to_cpu(sb->raid_disks); |
1389 | mddev->dev_sectors = le64_to_cpu(sb->size); | 1390 | mddev->dev_sectors = le64_to_cpu(sb->size); |
1390 | mddev->events = ev1; | 1391 | mddev->events = ev1; |
1391 | mddev->bitmap_offset = 0; | 1392 | mddev->bitmap_info.offset = 0; |
1392 | mddev->default_bitmap_offset = 1024 >> 9; | 1393 | mddev->bitmap_info.default_offset = 1024 >> 9; |
1393 | 1394 | ||
1394 | mddev->recovery_cp = le64_to_cpu(sb->resync_offset); | 1395 | mddev->recovery_cp = le64_to_cpu(sb->resync_offset); |
1395 | memcpy(mddev->uuid, sb->set_uuid, 16); | 1396 | memcpy(mddev->uuid, sb->set_uuid, 16); |
@@ -1397,8 +1398,9 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1397 | mddev->max_disks = (4096-256)/2; | 1398 | mddev->max_disks = (4096-256)/2; |
1398 | 1399 | ||
1399 | if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) && | 1400 | if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) && |
1400 | mddev->bitmap_file == NULL ) | 1401 | mddev->bitmap_info.file == NULL ) |
1401 | mddev->bitmap_offset = (__s32)le32_to_cpu(sb->bitmap_offset); | 1402 | mddev->bitmap_info.offset = |
1403 | (__s32)le32_to_cpu(sb->bitmap_offset); | ||
1402 | 1404 | ||
1403 | if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE)) { | 1405 | if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE)) { |
1404 | mddev->reshape_position = le64_to_cpu(sb->reshape_position); | 1406 | mddev->reshape_position = le64_to_cpu(sb->reshape_position); |
@@ -1492,8 +1494,8 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1492 | sb->level = cpu_to_le32(mddev->level); | 1494 | sb->level = cpu_to_le32(mddev->level); |
1493 | sb->layout = cpu_to_le32(mddev->layout); | 1495 | sb->layout = cpu_to_le32(mddev->layout); |
1494 | 1496 | ||
1495 | if (mddev->bitmap && mddev->bitmap_file == NULL) { | 1497 | if (mddev->bitmap && mddev->bitmap_info.file == NULL) { |
1496 | sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset); | 1498 | sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_info.offset); |
1497 | sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); | 1499 | sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); |
1498 | } | 1500 | } |
1499 | 1501 | ||
@@ -1560,7 +1562,7 @@ super_1_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors) | |||
1560 | max_sectors -= rdev->data_offset; | 1562 | max_sectors -= rdev->data_offset; |
1561 | if (!num_sectors || num_sectors > max_sectors) | 1563 | if (!num_sectors || num_sectors > max_sectors) |
1562 | num_sectors = max_sectors; | 1564 | num_sectors = max_sectors; |
1563 | } else if (rdev->mddev->bitmap_offset) { | 1565 | } else if (rdev->mddev->bitmap_info.offset) { |
1564 | /* minor version 0 with bitmap we can't move */ | 1566 | /* minor version 0 with bitmap we can't move */ |
1565 | return 0; | 1567 | return 0; |
1566 | } else { | 1568 | } else { |
@@ -4507,12 +4509,12 @@ out: | |||
4507 | printk(KERN_INFO "md: %s stopped.\n", mdname(mddev)); | 4509 | printk(KERN_INFO "md: %s stopped.\n", mdname(mddev)); |
4508 | 4510 | ||
4509 | bitmap_destroy(mddev); | 4511 | bitmap_destroy(mddev); |
4510 | if (mddev->bitmap_file) { | 4512 | if (mddev->bitmap_info.file) { |
4511 | restore_bitmap_write_access(mddev->bitmap_file); | 4513 | restore_bitmap_write_access(mddev->bitmap_info.file); |
4512 | fput(mddev->bitmap_file); | 4514 | fput(mddev->bitmap_info.file); |
4513 | mddev->bitmap_file = NULL; | 4515 | mddev->bitmap_info.file = NULL; |
4514 | } | 4516 | } |
4515 | mddev->bitmap_offset = 0; | 4517 | mddev->bitmap_info.offset = 0; |
4516 | 4518 | ||
4517 | /* make sure all md_delayed_delete calls have finished */ | 4519 | /* make sure all md_delayed_delete calls have finished */ |
4518 | flush_scheduled_work(); | 4520 | flush_scheduled_work(); |
@@ -4553,6 +4555,8 @@ out: | |||
4553 | mddev->degraded = 0; | 4555 | mddev->degraded = 0; |
4554 | mddev->barriers_work = 0; | 4556 | mddev->barriers_work = 0; |
4555 | mddev->safemode = 0; | 4557 | mddev->safemode = 0; |
4558 | mddev->bitmap_info.offset = 0; | ||
4559 | mddev->bitmap_info.default_offset = 0; | ||
4556 | kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); | 4560 | kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); |
4557 | if (mddev->hold_active == UNTIL_STOP) | 4561 | if (mddev->hold_active == UNTIL_STOP) |
4558 | mddev->hold_active = 0; | 4562 | mddev->hold_active = 0; |
@@ -4738,7 +4742,7 @@ static int get_array_info(mddev_t * mddev, void __user * arg) | |||
4738 | info.state = 0; | 4742 | info.state = 0; |
4739 | if (mddev->in_sync) | 4743 | if (mddev->in_sync) |
4740 | info.state = (1<<MD_SB_CLEAN); | 4744 | info.state = (1<<MD_SB_CLEAN); |
4741 | if (mddev->bitmap && mddev->bitmap_offset) | 4745 | if (mddev->bitmap && mddev->bitmap_info.offset) |
4742 | info.state = (1<<MD_SB_BITMAP_PRESENT); | 4746 | info.state = (1<<MD_SB_BITMAP_PRESENT); |
4743 | info.active_disks = insync; | 4747 | info.active_disks = insync; |
4744 | info.working_disks = working; | 4748 | info.working_disks = working; |
@@ -5096,23 +5100,23 @@ static int set_bitmap_file(mddev_t *mddev, int fd) | |||
5096 | if (fd >= 0) { | 5100 | if (fd >= 0) { |
5097 | if (mddev->bitmap) | 5101 | if (mddev->bitmap) |
5098 | return -EEXIST; /* cannot add when bitmap is present */ | 5102 | return -EEXIST; /* cannot add when bitmap is present */ |
5099 | mddev->bitmap_file = fget(fd); | 5103 | mddev->bitmap_info.file = fget(fd); |
5100 | 5104 | ||
5101 | if (mddev->bitmap_file == NULL) { | 5105 | if (mddev->bitmap_info.file == NULL) { |
5102 | printk(KERN_ERR "%s: error: failed to get bitmap file\n", | 5106 | printk(KERN_ERR "%s: error: failed to get bitmap file\n", |
5103 | mdname(mddev)); | 5107 | mdname(mddev)); |
5104 | return -EBADF; | 5108 | return -EBADF; |
5105 | } | 5109 | } |
5106 | 5110 | ||
5107 | err = deny_bitmap_write_access(mddev->bitmap_file); | 5111 | err = deny_bitmap_write_access(mddev->bitmap_info.file); |
5108 | if (err) { | 5112 | if (err) { |
5109 | printk(KERN_ERR "%s: error: bitmap file is already in use\n", | 5113 | printk(KERN_ERR "%s: error: bitmap file is already in use\n", |
5110 | mdname(mddev)); | 5114 | mdname(mddev)); |
5111 | fput(mddev->bitmap_file); | 5115 | fput(mddev->bitmap_info.file); |
5112 | mddev->bitmap_file = NULL; | 5116 | mddev->bitmap_info.file = NULL; |
5113 | return err; | 5117 | return err; |
5114 | } | 5118 | } |
5115 | mddev->bitmap_offset = 0; /* file overrides offset */ | 5119 | mddev->bitmap_info.offset = 0; /* file overrides offset */ |
5116 | } else if (mddev->bitmap == NULL) | 5120 | } else if (mddev->bitmap == NULL) |
5117 | return -ENOENT; /* cannot remove what isn't there */ | 5121 | return -ENOENT; /* cannot remove what isn't there */ |
5118 | err = 0; | 5122 | err = 0; |
@@ -5127,11 +5131,11 @@ static int set_bitmap_file(mddev_t *mddev, int fd) | |||
5127 | mddev->pers->quiesce(mddev, 0); | 5131 | mddev->pers->quiesce(mddev, 0); |
5128 | } | 5132 | } |
5129 | if (fd < 0) { | 5133 | if (fd < 0) { |
5130 | if (mddev->bitmap_file) { | 5134 | if (mddev->bitmap_info.file) { |
5131 | restore_bitmap_write_access(mddev->bitmap_file); | 5135 | restore_bitmap_write_access(mddev->bitmap_info.file); |
5132 | fput(mddev->bitmap_file); | 5136 | fput(mddev->bitmap_info.file); |
5133 | } | 5137 | } |
5134 | mddev->bitmap_file = NULL; | 5138 | mddev->bitmap_info.file = NULL; |
5135 | } | 5139 | } |
5136 | 5140 | ||
5137 | return err; | 5141 | return err; |
@@ -5198,8 +5202,8 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info) | |||
5198 | mddev->flags = 0; | 5202 | mddev->flags = 0; |
5199 | set_bit(MD_CHANGE_DEVS, &mddev->flags); | 5203 | set_bit(MD_CHANGE_DEVS, &mddev->flags); |
5200 | 5204 | ||
5201 | mddev->default_bitmap_offset = MD_SB_BYTES >> 9; | 5205 | mddev->bitmap_info.default_offset = MD_SB_BYTES >> 9; |
5202 | mddev->bitmap_offset = 0; | 5206 | mddev->bitmap_info.offset = 0; |
5203 | 5207 | ||
5204 | mddev->reshape_position = MaxSector; | 5208 | mddev->reshape_position = MaxSector; |
5205 | 5209 | ||
@@ -5299,7 +5303,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info) | |||
5299 | int state = 0; | 5303 | int state = 0; |
5300 | 5304 | ||
5301 | /* calculate expected state,ignoring low bits */ | 5305 | /* calculate expected state,ignoring low bits */ |
5302 | if (mddev->bitmap && mddev->bitmap_offset) | 5306 | if (mddev->bitmap && mddev->bitmap_info.offset) |
5303 | state |= (1 << MD_SB_BITMAP_PRESENT); | 5307 | state |= (1 << MD_SB_BITMAP_PRESENT); |
5304 | 5308 | ||
5305 | if (mddev->major_version != info->major_version || | 5309 | if (mddev->major_version != info->major_version || |
@@ -5358,9 +5362,10 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info) | |||
5358 | /* add the bitmap */ | 5362 | /* add the bitmap */ |
5359 | if (mddev->bitmap) | 5363 | if (mddev->bitmap) |
5360 | return -EEXIST; | 5364 | return -EEXIST; |
5361 | if (mddev->default_bitmap_offset == 0) | 5365 | if (mddev->bitmap_info.default_offset == 0) |
5362 | return -EINVAL; | 5366 | return -EINVAL; |
5363 | mddev->bitmap_offset = mddev->default_bitmap_offset; | 5367 | mddev->bitmap_info.offset = |
5368 | mddev->bitmap_info.default_offset; | ||
5364 | mddev->pers->quiesce(mddev, 1); | 5369 | mddev->pers->quiesce(mddev, 1); |
5365 | rv = bitmap_create(mddev); | 5370 | rv = bitmap_create(mddev); |
5366 | if (rv) | 5371 | if (rv) |
@@ -5375,7 +5380,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info) | |||
5375 | mddev->pers->quiesce(mddev, 1); | 5380 | mddev->pers->quiesce(mddev, 1); |
5376 | bitmap_destroy(mddev); | 5381 | bitmap_destroy(mddev); |
5377 | mddev->pers->quiesce(mddev, 0); | 5382 | mddev->pers->quiesce(mddev, 0); |
5378 | mddev->bitmap_offset = 0; | 5383 | mddev->bitmap_info.offset = 0; |
5379 | } | 5384 | } |
5380 | } | 5385 | } |
5381 | md_update_sb(mddev, 1); | 5386 | md_update_sb(mddev, 1); |