diff options
author | NeilBrown <neilb@suse.de> | 2010-03-28 20:37:13 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-05-18 01:27:53 -0400 |
commit | 6177b472ab14e1ac88896960370dd54ba577d926 (patch) | |
tree | 387eec24b0ac82e028edfdd77d8b425077ca0bfb /drivers/md | |
parent | fe60b0142813002be16dfae28780d9779ee22473 (diff) |
md: start to refactor do_md_stop
do_md_stop is large and clunky, so hard to understand.
This is a first step of refactoring, pulling two simple
sub-functions out.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 98 |
1 files changed, 55 insertions, 43 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index e752332268d2..002d0a34d6ea 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -4568,6 +4568,58 @@ void restore_bitmap_write_access(struct file *file) | |||
4568 | spin_unlock(&inode->i_lock); | 4568 | spin_unlock(&inode->i_lock); |
4569 | } | 4569 | } |
4570 | 4570 | ||
4571 | static void md_clean(mddev_t *mddev) | ||
4572 | { | ||
4573 | mddev->array_sectors = 0; | ||
4574 | mddev->external_size = 0; | ||
4575 | mddev->dev_sectors = 0; | ||
4576 | mddev->raid_disks = 0; | ||
4577 | mddev->recovery_cp = 0; | ||
4578 | mddev->resync_min = 0; | ||
4579 | mddev->resync_max = MaxSector; | ||
4580 | mddev->reshape_position = MaxSector; | ||
4581 | mddev->external = 0; | ||
4582 | mddev->persistent = 0; | ||
4583 | mddev->level = LEVEL_NONE; | ||
4584 | mddev->clevel[0] = 0; | ||
4585 | mddev->flags = 0; | ||
4586 | mddev->ro = 0; | ||
4587 | mddev->metadata_type[0] = 0; | ||
4588 | mddev->chunk_sectors = 0; | ||
4589 | mddev->ctime = mddev->utime = 0; | ||
4590 | mddev->layout = 0; | ||
4591 | mddev->max_disks = 0; | ||
4592 | mddev->events = 0; | ||
4593 | mddev->delta_disks = 0; | ||
4594 | mddev->new_level = LEVEL_NONE; | ||
4595 | mddev->new_layout = 0; | ||
4596 | mddev->new_chunk_sectors = 0; | ||
4597 | mddev->curr_resync = 0; | ||
4598 | mddev->resync_mismatches = 0; | ||
4599 | mddev->suspend_lo = mddev->suspend_hi = 0; | ||
4600 | mddev->sync_speed_min = mddev->sync_speed_max = 0; | ||
4601 | mddev->recovery = 0; | ||
4602 | mddev->in_sync = 0; | ||
4603 | mddev->degraded = 0; | ||
4604 | mddev->barriers_work = 0; | ||
4605 | mddev->safemode = 0; | ||
4606 | mddev->bitmap_info.offset = 0; | ||
4607 | mddev->bitmap_info.default_offset = 0; | ||
4608 | mddev->bitmap_info.chunksize = 0; | ||
4609 | mddev->bitmap_info.daemon_sleep = 0; | ||
4610 | mddev->bitmap_info.max_write_behind = 0; | ||
4611 | } | ||
4612 | |||
4613 | static void md_stop(mddev_t *mddev) | ||
4614 | { | ||
4615 | mddev->pers->stop(mddev); | ||
4616 | if (mddev->pers->sync_request && mddev->to_remove == NULL) | ||
4617 | mddev->to_remove = &md_redundancy_group; | ||
4618 | module_put(mddev->pers->owner); | ||
4619 | mddev->pers = NULL; | ||
4620 | |||
4621 | } | ||
4622 | |||
4571 | /* mode: | 4623 | /* mode: |
4572 | * 0 - completely stop and dis-assemble array | 4624 | * 0 - completely stop and dis-assemble array |
4573 | * 1 - switch to readonly | 4625 | * 1 - switch to readonly |
@@ -4608,14 +4660,11 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open) | |||
4608 | if (mddev->ro) | 4660 | if (mddev->ro) |
4609 | set_disk_ro(disk, 0); | 4661 | set_disk_ro(disk, 0); |
4610 | 4662 | ||
4611 | mddev->pers->stop(mddev); | 4663 | md_stop(mddev); |
4612 | mddev->queue->merge_bvec_fn = NULL; | 4664 | mddev->queue->merge_bvec_fn = NULL; |
4613 | mddev->queue->unplug_fn = NULL; | 4665 | mddev->queue->unplug_fn = NULL; |
4614 | mddev->queue->backing_dev_info.congested_fn = NULL; | 4666 | mddev->queue->backing_dev_info.congested_fn = NULL; |
4615 | module_put(mddev->pers->owner); | 4667 | |
4616 | if (mddev->pers->sync_request && mddev->to_remove == NULL) | ||
4617 | mddev->to_remove = &md_redundancy_group; | ||
4618 | mddev->pers = NULL; | ||
4619 | /* tell userspace to handle 'inactive' */ | 4668 | /* tell userspace to handle 'inactive' */ |
4620 | sysfs_notify_dirent(mddev->sysfs_state); | 4669 | sysfs_notify_dirent(mddev->sysfs_state); |
4621 | 4670 | ||
@@ -4663,44 +4712,7 @@ out: | |||
4663 | 4712 | ||
4664 | export_array(mddev); | 4713 | export_array(mddev); |
4665 | 4714 | ||
4666 | mddev->array_sectors = 0; | 4715 | md_clean(mddev); |
4667 | mddev->external_size = 0; | ||
4668 | mddev->dev_sectors = 0; | ||
4669 | mddev->raid_disks = 0; | ||
4670 | mddev->recovery_cp = 0; | ||
4671 | mddev->resync_min = 0; | ||
4672 | mddev->resync_max = MaxSector; | ||
4673 | mddev->reshape_position = MaxSector; | ||
4674 | mddev->external = 0; | ||
4675 | mddev->persistent = 0; | ||
4676 | mddev->level = LEVEL_NONE; | ||
4677 | mddev->clevel[0] = 0; | ||
4678 | mddev->flags = 0; | ||
4679 | mddev->ro = 0; | ||
4680 | mddev->metadata_type[0] = 0; | ||
4681 | mddev->chunk_sectors = 0; | ||
4682 | mddev->ctime = mddev->utime = 0; | ||
4683 | mddev->layout = 0; | ||
4684 | mddev->max_disks = 0; | ||
4685 | mddev->events = 0; | ||
4686 | mddev->delta_disks = 0; | ||
4687 | mddev->new_level = LEVEL_NONE; | ||
4688 | mddev->new_layout = 0; | ||
4689 | mddev->new_chunk_sectors = 0; | ||
4690 | mddev->curr_resync = 0; | ||
4691 | mddev->resync_mismatches = 0; | ||
4692 | mddev->suspend_lo = mddev->suspend_hi = 0; | ||
4693 | mddev->sync_speed_min = mddev->sync_speed_max = 0; | ||
4694 | mddev->recovery = 0; | ||
4695 | mddev->in_sync = 0; | ||
4696 | mddev->degraded = 0; | ||
4697 | mddev->barriers_work = 0; | ||
4698 | mddev->safemode = 0; | ||
4699 | mddev->bitmap_info.offset = 0; | ||
4700 | mddev->bitmap_info.default_offset = 0; | ||
4701 | mddev->bitmap_info.chunksize = 0; | ||
4702 | mddev->bitmap_info.daemon_sleep = 0; | ||
4703 | mddev->bitmap_info.max_write_behind = 0; | ||
4704 | kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); | 4716 | kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); |
4705 | if (mddev->hold_active == UNTIL_STOP) | 4717 | if (mddev->hold_active == UNTIL_STOP) |
4706 | mddev->hold_active = 0; | 4718 | mddev->hold_active = 0; |