@@ -531,11 +531,6 @@ static void mddev_delayed_delete(struct work_struct *ws);
static void mddev_put(struct mddev *mddev)
{
- struct bio_set bs, sync_bs;
-
- memset(&bs, 0, sizeof(bs));
- memset(&sync_bs, 0, sizeof(sync_bs));
-
if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock))
return;
if (!mddev->raid_disks && list_empty(&mddev->disks) &&
@@ -543,10 +538,14 @@ static void mddev_put(struct mddev *mddev)
/* Array is not configured at all, and not held active,
* so destroy it */
list_del_init(&mddev->all_mddevs);
- bs = mddev->bio_set;
- sync_bs = mddev->sync_set;
+ spin_unlock(&all_mddevs_lock);
+
+ bioset_exit(&mddev->bio_set);
memset(&mddev->bio_set, 0, sizeof(mddev->bio_set));
+
+ bioset_exit(&mddev->sync_set);
memset(&mddev->sync_set, 0, sizeof(mddev->sync_set));
+
if (mddev->gendisk) {
/* We did a probe so need to clean up. Call
* queue_work inside the spinlock so that
@@ -557,10 +556,9 @@ static void mddev_put(struct mddev *mddev)
queue_work(md_misc_wq, &mddev->del_work);
} else
kfree(mddev);
+ } else {
+ spin_unlock(&all_mddevs_lock);
}
- spin_unlock(&all_mddevs_lock);
- bioset_exit(&bs);
- bioset_exit(&sync_bs);
}
static void md_safemode_timeout(struct timer_list *t);