Skip to content

Commit 330a4db

Browse files
LiangChen77axboe
authored andcommitted
bcache: explicitly destroy 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. As Coly pointed out in a previous review, bcache_exit() may not be able to handle all the references properly if userspace registers cache and backing devices right before bch_debug_init runs and bch_debug_init failes later. So not exposing userspace interface until everything is ready to avoid that issue. Signed-off-by: Liang Chen <liangchen.linux@gmail.com> Reviewed-by: Michael Lyle <mlyle@lyle.org> Reviewed-by: Coly Li <colyli@suse.de> Reviewed-by: Eric Wheeler <bcache@linux.ewheeler.net> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c157313 commit 330a4db

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/md/bcache/super.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,6 +2095,7 @@ static void bcache_exit(void)
20952095
if (bcache_major)
20962096
unregister_blkdev(bcache_major, "bcache");
20972097
unregister_reboot_notifier(&reboot);
2098+
mutex_destroy(&bch_register_lock);
20982099
}
20992100

21002101
static int __init bcache_init(void)
@@ -2113,14 +2114,15 @@ static int __init bcache_init(void)
21132114
bcache_major = register_blkdev(0, "bcache");
21142115
if (bcache_major < 0) {
21152116
unregister_reboot_notifier(&reboot);
2117+
mutex_destroy(&bch_register_lock);
21162118
return bcache_major;
21172119
}
21182120

21192121
if (!(bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0)) ||
21202122
!(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) ||
2121-
sysfs_create_files(bcache_kobj, files) ||
21222123
bch_request_init() ||
2123-
bch_debug_init(bcache_kobj))
2124+
bch_debug_init(bcache_kobj) ||
2125+
sysfs_create_files(bcache_kobj, files))
21242126
goto err;
21252127

21262128
return 0;

0 commit comments

Comments
 (0)