Skip to contentSkip to conversation

bcache: explicitly destory mutex while exiting

PATCH Superseded Liang Chen 2 participants 2 messages May 2, 2017 – May 4, 2017 bcache (block layer cache)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Liang Chen

author
#0 lore raw

PATCH 1/1 bcache: explicitly destory mutex while exiting

mutex_destroy does nothing most of time, but it's better to call it to make the code future proof and it also has some meaning for like mutex debug.

---
 drivers/md/bcache/super.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/md/bcache/super.c +2 -0
index 85e3f21..406fe03 100644
@@ -2083,6 +2083,7 @@ static void bcache_exit(void)
 	if (bcache_major)
 		unregister_blkdev(bcache_major, "bcache");
 	unregister_reboot_notifier(&reboot);
+	mutex_destroy(&bch_register_lock);
 }
 
 static int __init bcache_init(void)
@@ -2100,6 +2101,7 @@ static int __init bcache_init(void)
 
 	bcache_major = register_blkdev(0, "bcache");
 	if (bcache_major < 0) {
+		mutex_destroy(&bch_register_lock);
 		unregister_reboot_notifier(&reboot);
 		return bcache_major;
 	}
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 4 lines · Liang Chen

mutex_destroy does nothing most of time, but it's better to call it to make the code future proof and it also has some meaning for like mutex debug.

Hi Liang,

Could you please explain a little bit more about how mutex_destroy() helps to future proof of the code, and how it helps to mutex debug ?

Forgive me for not catching your point.

Thanks.

Quoted 26 lines
---
 drivers/md/bcache/super.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/md/bcache/super.c +2 -0
index 85e3f21..406fe03 100644
@@ -2083,6 +2083,7 @@ static void bcache_exit(void)
 	if (bcache_major)
 		unregister_blkdev(bcache_major, "bcache");
 	unregister_reboot_notifier(&reboot);
+	mutex_destroy(&bch_register_lock);
 }
 
 static int __init bcache_init(void)
@@ -2100,6 +2101,7 @@ static int __init bcache_init(void)
 
 	bcache_major = register_blkdev(0, "bcache");
 	if (bcache_major < 0) {
+		mutex_destroy(&bch_register_lock);
 		unregister_reboot_notifier(&reboot);
 		return bcache_major;
 	}
Signature · 1 line
Coly Li