Skip to contentSkip to conversation

md:Add a func 'dm_md_stop' for dm-raid to clear up md resources.

PATCH In review majianpeng 3 participants 4 messages Nov 15, 2012

Subsystems (2)
lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 1/3 md:Add a func 'dm_md_stop' for dm-raid to clear up md resources.

Because dm-raid used md driver, when stoped dm-raid it only call md_stop. It caused some resources omited, like bitmap, mddev->bio_set. So add a func dm_md_stop to clear up resource.

---
 drivers/md/md.c |    9 +++++++++
 drivers/md/md.h |    1 +
 2 files changed, 10 insertions(+)
drivers/md/md.c +9 -0
index 9ab768a..574b0a8 100644
@@ -5306,6 +5306,15 @@ void md_stop(struct mddev *mddev)
 }
 EXPORT_SYMBOL_GPL(md_stop);
 
+void dm_md_stop(struct mddev *mddev)
+{
+	md_stop(mddev);
+	bitmap_destroy(mddev);
+	if (mddev->bio_set)
+		bioset_free(mddev->bio_set);
+}
+EXPORT_SYMBOL_GPL(dm_md_stop);
+
 static int md_set_readonly(struct mddev *mddev, struct block_device *bdev)
 {
 	int err = 0;
drivers/md/md.h +1 -0
index af443ab..a370ece 100644
@@ -621,6 +621,7 @@ extern void md_stop(struct mddev *mddev);
 extern void md_stop_writes(struct mddev *mddev);
 extern int md_rdev_init(struct md_rdev *rdev);
 extern void md_rdev_clear(struct md_rdev *rdev);
+extern void dm_md_stop(struct mddev *mddev);
 
 extern void mddev_suspend(struct mddev *mddev);
 extern void mddev_resume(struct mddev *mddev);
Signature · 1 line
1.7.9.5
#1 lore raw

drivers/md/md.c void md_stop(struct mddev *mddev) · line 5316

Quoted 12 lines · majianpeng

So add a func dm_md_stop to clear up resource.

+++ b/drivers/md/md.c

drivers/md/md.c +8 -0
+void dm_md_stop(struct mddev *mddev)
+{
+	md_stop(mddev);
+	bitmap_destroy(mddev);
+	if (mddev->bio_set)
+		bioset_free(mddev->bio_set);
+}
+EXPORT_SYMBOL_GPL(dm_md_stop);

Let's not put a function with a dm_ prefix in an md file?

Alasdair

author
#2 lore raw
Quoted 16 lines · majianpeng

drivers/md/md.c void md_stop(struct mddev *mddev) · line 5316

Quoted 12 lines

So add a func dm_md_stop to clear up resource.

+++ b/drivers/md/md.c

drivers/md/md.c +8 -0
+void dm_md_stop(struct mddev *mddev)
+{
+	md_stop(mddev);
+	bitmap_destroy(mddev);
+	if (mddev->bio_set)
+		bioset_free(mddev->bio_set);
+}
+EXPORT_SYMBOL_GPL(dm_md_stop);

Let's not put a function with a dm_ prefix in an md file?

Quoted 2 lines

Alasdair

Can you give me a hint? My thought is this func only by dm to call and there was a md_stop already? I firstly want to add those statements in dm driver like md_stop rather than a func include those. But i think dm don't know to much.
Neil, your suggestion?

Jianpeng
Thanks!

#3 lore raw
Quoted 16 lines · majianpeng
Quoted 16 lines · majianpeng

drivers/md/md.c void md_stop(struct mddev *mddev) · line 5316

Quoted 12 lines

So add a func dm_md_stop to clear up resource.

+++ b/drivers/md/md.c

drivers/md/md.c +8 -0
+void dm_md_stop(struct mddev *mddev)
+{
+	md_stop(mddev);
+	bitmap_destroy(mddev);
+	if (mddev->bio_set)
+		bioset_free(mddev->bio_set);
+}
+EXPORT_SYMBOL_GPL(dm_md_stop);

Let's not put a function with a dm_ prefix in an md file?

Quoted 5 lines
Quoted 2 lines

Alasdair

Can you give me a hint? My thought is this func only by dm to call and there was a md_stop already? I firstly want to add those statements in dm driver like md_stop rather than a func include those. But i think dm don't know to much.

Nmae it mddev_stop_and_cleanup?