Commit f5efd45ae597c96ed017afad5662b67d55b402a0

Authored by Dan Williams
Committed by NeilBrown
1 parent 1d9d52416c

md/raid5: initialize conf->device_lock earlier

Deallocating a raid5_conf_t structure requires taking 'device_lock'.
Ensure it is initialized before it is used, i.e. initialize the lock
before attempting any further initializations that might fail.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>

Showing 1 changed file with 12 additions and 13 deletions Side-by-side Diff

... ... @@ -4715,6 +4715,18 @@
4715 4715 conf = kzalloc(sizeof(raid5_conf_t), GFP_KERNEL);
4716 4716 if (conf == NULL)
4717 4717 goto abort;
  4718 + spin_lock_init(&conf->device_lock);
  4719 + init_waitqueue_head(&conf->wait_for_stripe);
  4720 + init_waitqueue_head(&conf->wait_for_overlap);
  4721 + INIT_LIST_HEAD(&conf->handle_list);
  4722 + INIT_LIST_HEAD(&conf->hold_list);
  4723 + INIT_LIST_HEAD(&conf->delayed_list);
  4724 + INIT_LIST_HEAD(&conf->bitmap_list);
  4725 + INIT_LIST_HEAD(&conf->inactive_list);
  4726 + atomic_set(&conf->active_stripes, 0);
  4727 + atomic_set(&conf->preread_active_stripes, 0);
  4728 + atomic_set(&conf->active_aligned_reads, 0);
  4729 + conf->bypass_threshold = BYPASS_THRESHOLD;
4718 4730  
4719 4731 conf->raid_disks = mddev->raid_disks;
4720 4732 conf->scribble_len = scribble_len(conf->raid_disks);
... ... @@ -4736,19 +4748,6 @@
4736 4748 conf->level = mddev->new_level;
4737 4749 if (raid5_alloc_percpu(conf) != 0)
4738 4750 goto abort;
4739   -
4740   - spin_lock_init(&conf->device_lock);
4741   - init_waitqueue_head(&conf->wait_for_stripe);
4742   - init_waitqueue_head(&conf->wait_for_overlap);
4743   - INIT_LIST_HEAD(&conf->handle_list);
4744   - INIT_LIST_HEAD(&conf->hold_list);
4745   - INIT_LIST_HEAD(&conf->delayed_list);
4746   - INIT_LIST_HEAD(&conf->bitmap_list);
4747   - INIT_LIST_HEAD(&conf->inactive_list);
4748   - atomic_set(&conf->active_stripes, 0);
4749   - atomic_set(&conf->preread_active_stripes, 0);
4750   - atomic_set(&conf->active_aligned_reads, 0);
4751   - conf->bypass_threshold = BYPASS_THRESHOLD;
4752 4751  
4753 4752 pr_debug("raid5: run(%s) called.\n", mdname(mddev));
4754 4753