]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
bcache: move closure debug file into debug directory
authorChengguang Xu <cgxu519@gmx.com>
Mon, 19 Mar 2018 00:36:23 +0000 (17:36 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 19 Mar 2018 02:15:20 +0000 (20:15 -0600)
In current code closure debug file is outside of debug directory
and when unloading module there is lack of removing operation
for closure debug file, so it will cause creating error when trying
to reload  module.

This patch move closure debug file into "bcache" debug direcory
so that the file can get deleted properly.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Reviewed-by: Tang Junhui <tang.junhui@zte.com.cn>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/closure.c
drivers/md/bcache/closure.h
drivers/md/bcache/debug.c
drivers/md/bcache/super.c

index 7f12920c14f7ade2086e1f1813fd832e047a8699..c0949c9f843bb99583c338ee112c5dafe217c22e 100644 (file)
@@ -157,7 +157,7 @@ void closure_debug_destroy(struct closure *cl)
 }
 EXPORT_SYMBOL(closure_debug_destroy);
 
-static struct dentry *debug;
+static struct dentry *closure_debug;
 
 static int debug_seq_show(struct seq_file *f, void *data)
 {
@@ -199,11 +199,12 @@ static const struct file_operations debug_ops = {
        .release        = single_release
 };
 
-void __init closure_debug_init(void)
+int __init closure_debug_init(void)
 {
-       debug = debugfs_create_file("closures", 0400, NULL, NULL, &debug_ops);
+       closure_debug = debugfs_create_file("closures",
+                               0400, bcache_debug, NULL, &debug_ops);
+       return IS_ERR_OR_NULL(closure_debug);
 }
-
 #endif
 
 MODULE_AUTHOR("Kent Overstreet <koverstreet@google.com>");
index 3b9dfc9962ad91404b319c715bf509a8fd52707b..71427eb5fdaeb191cb435742eab97027a07d0dbd 100644 (file)
 struct closure;
 struct closure_syncer;
 typedef void (closure_fn) (struct closure *);
+extern struct dentry *bcache_debug;
 
 struct closure_waitlist {
        struct llist_head       list;
@@ -185,13 +186,13 @@ static inline void closure_sync(struct closure *cl)
 
 #ifdef CONFIG_BCACHE_CLOSURES_DEBUG
 
-void closure_debug_init(void);
+int closure_debug_init(void);
 void closure_debug_create(struct closure *cl);
 void closure_debug_destroy(struct closure *cl);
 
 #else
 
-static inline void closure_debug_init(void) {}
+static inline int closure_debug_init(void) { return 0; }
 static inline void closure_debug_create(struct closure *cl) {}
 static inline void closure_debug_destroy(struct closure *cl) {}
 
index af89408befe847a25164cc34b46d0cd941294ace..028f7b386e014b6bae1bf1dc5d8b9f687faa0746 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/random.h>
 #include <linux/seq_file.h>
 
-static struct dentry *debug;
+struct dentry *bcache_debug;
 
 #ifdef CONFIG_BCACHE_DEBUG
 
@@ -232,11 +232,11 @@ static const struct file_operations cache_set_debug_ops = {
 
 void bch_debug_init_cache_set(struct cache_set *c)
 {
-       if (!IS_ERR_OR_NULL(debug)) {
+       if (!IS_ERR_OR_NULL(bcache_debug)) {
                char name[50];
                snprintf(name, 50, "bcache-%pU", c->sb.set_uuid);
 
-               c->debug = debugfs_create_file(name, 0400, debug, c,
+               c->debug = debugfs_create_file(name, 0400, bcache_debug, c,
                                               &cache_set_debug_ops);
        }
 }
@@ -245,13 +245,13 @@ void bch_debug_init_cache_set(struct cache_set *c)
 
 void bch_debug_exit(void)
 {
-       if (!IS_ERR_OR_NULL(debug))
-               debugfs_remove_recursive(debug);
+       if (!IS_ERR_OR_NULL(bcache_debug))
+               debugfs_remove_recursive(bcache_debug);
 }
 
 int __init bch_debug_init(struct kobject *kobj)
 {
-       debug = debugfs_create_dir("bcache", NULL);
+       bcache_debug = debugfs_create_dir("bcache", NULL);
 
-       return IS_ERR_OR_NULL(debug);
+       return IS_ERR_OR_NULL(bcache_debug);
 }
index 7b45160e9a227af14d9deb94f71319845e4caabc..f1f64853114b92268cbc1b4133e06cde9d6e37da 100644 (file)
@@ -2224,7 +2224,6 @@ static int __init bcache_init(void)
        mutex_init(&bch_register_lock);
        init_waitqueue_head(&unregister_wait);
        register_reboot_notifier(&reboot);
-       closure_debug_init();
 
        bcache_major = register_blkdev(0, "bcache");
        if (bcache_major < 0) {
@@ -2236,7 +2235,7 @@ static int __init bcache_init(void)
        if (!(bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0)) ||
            !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) ||
            bch_request_init() ||
-           bch_debug_init(bcache_kobj) ||
+           bch_debug_init(bcache_kobj) || closure_debug_init() ||
            sysfs_create_files(bcache_kobj, files))
                goto err;