md_stop() would stop an array, but not free various attached
data structures.
For internal arrays, these are freed later in do_md_stop() or
mddev_put(), but they don't apply for dm-raid arrays.
So get md_stop() to free them, and only all it from dm-raid.
For internal arrays we now call __md_stop.

Reported-by: majianpeng <[email protected]>
Signed-off-by: NeilBrown <[email protected]>

Upstream-ID: 5eff3c439d3478ba9e8ba5f8c0aaf6e6fadb6e58
Stable-trees: 3.0.x
Signed-off-by: CAI Qian <[email protected]>

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 98262e5..d513932 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4809,7 +4809,7 @@ void md_stop_writes(mddev_t *mddev)
 }
 EXPORT_SYMBOL_GPL(md_stop_writes);
 
-void md_stop(mddev_t *mddev)
+static void __md_stop(mddev_t *mddev)
 {
        mddev->ready = 0;
        mddev->pers->stop(mddev);
@@ -4819,6 +4819,18 @@ void md_stop(mddev_t *mddev)
        mddev->pers = NULL;
        clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
 }
+
+void md_stop(struct mddev *mddev)
+{
+       /* stop the array and free an attached data structures.
+        * This is called from dm-raid
+        */
+       __md_stop(mddev);
+       bitmap_destroy(mddev);
+       if (mddev->bio_set)
+               bioset_free(mddev->bio_set);
+}
+
 EXPORT_SYMBOL_GPL(md_stop);
 
 static int md_set_readonly(mddev_t *mddev, int is_open)
@@ -4869,7 +4881,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int 
is_open)
                        set_disk_ro(disk, 0);
 
                __md_stop_writes(mddev);
-               md_stop(mddev);
+               __md_stop(mddev);
                mddev->queue->merge_bvec_fn = NULL;
                mddev->queue->backing_dev_info.congested_fn = NULL;
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to