aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@gmx.com>2018-03-18 20:36:23 -0400
committerJens Axboe <axboe@kernel.dk>2018-03-18 22:15:20 -0400
commitdf2b94313ae5b4f60d49e01d4dff5acb4c2757cf (patch)
tree124c33fcd0df9753d7c9805c435320bcb89d373a /drivers/md
parentca71df31661a0518ed58a1a59cf1993962153ebb (diff)
bcache: move closure debug file into debug directory
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>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/bcache/closure.c9
-rw-r--r--drivers/md/bcache/closure.h5
-rw-r--r--drivers/md/bcache/debug.c14
-rw-r--r--drivers/md/bcache/super.c3
4 files changed, 16 insertions, 15 deletions
diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
index 7f12920c14f7..c0949c9f843b 100644
--- a/drivers/md/bcache/closure.c
+++ b/drivers/md/bcache/closure.c
@@ -157,7 +157,7 @@ void closure_debug_destroy(struct closure *cl)
157} 157}
158EXPORT_SYMBOL(closure_debug_destroy); 158EXPORT_SYMBOL(closure_debug_destroy);
159 159
160static struct dentry *debug; 160static struct dentry *closure_debug;
161 161
162static int debug_seq_show(struct seq_file *f, void *data) 162static int debug_seq_show(struct seq_file *f, void *data)
163{ 163{
@@ -199,11 +199,12 @@ static const struct file_operations debug_ops = {
199 .release = single_release 199 .release = single_release
200}; 200};
201 201
202void __init closure_debug_init(void) 202int __init closure_debug_init(void)
203{ 203{
204 debug = debugfs_create_file("closures", 0400, NULL, NULL, &debug_ops); 204 closure_debug = debugfs_create_file("closures",
205 0400, bcache_debug, NULL, &debug_ops);
206 return IS_ERR_OR_NULL(closure_debug);
205} 207}
206
207#endif 208#endif
208 209
209MODULE_AUTHOR("Kent Overstreet <koverstreet@google.com>"); 210MODULE_AUTHOR("Kent Overstreet <koverstreet@google.com>");
diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
index 3b9dfc9962ad..71427eb5fdae 100644
--- a/drivers/md/bcache/closure.h
+++ b/drivers/md/bcache/closure.h
@@ -105,6 +105,7 @@
105struct closure; 105struct closure;
106struct closure_syncer; 106struct closure_syncer;
107typedef void (closure_fn) (struct closure *); 107typedef void (closure_fn) (struct closure *);
108extern struct dentry *bcache_debug;
108 109
109struct closure_waitlist { 110struct closure_waitlist {
110 struct llist_head list; 111 struct llist_head list;
@@ -185,13 +186,13 @@ static inline void closure_sync(struct closure *cl)
185 186
186#ifdef CONFIG_BCACHE_CLOSURES_DEBUG 187#ifdef CONFIG_BCACHE_CLOSURES_DEBUG
187 188
188void closure_debug_init(void); 189int closure_debug_init(void);
189void closure_debug_create(struct closure *cl); 190void closure_debug_create(struct closure *cl);
190void closure_debug_destroy(struct closure *cl); 191void closure_debug_destroy(struct closure *cl);
191 192
192#else 193#else
193 194
194static inline void closure_debug_init(void) {} 195static inline int closure_debug_init(void) { return 0; }
195static inline void closure_debug_create(struct closure *cl) {} 196static inline void closure_debug_create(struct closure *cl) {}
196static inline void closure_debug_destroy(struct closure *cl) {} 197static inline void closure_debug_destroy(struct closure *cl) {}
197 198
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index af89408befe8..028f7b386e01 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -17,7 +17,7 @@
17#include <linux/random.h> 17#include <linux/random.h>
18#include <linux/seq_file.h> 18#include <linux/seq_file.h>
19 19
20static struct dentry *debug; 20struct dentry *bcache_debug;
21 21
22#ifdef CONFIG_BCACHE_DEBUG 22#ifdef CONFIG_BCACHE_DEBUG
23 23
@@ -232,11 +232,11 @@ static const struct file_operations cache_set_debug_ops = {
232 232
233void bch_debug_init_cache_set(struct cache_set *c) 233void bch_debug_init_cache_set(struct cache_set *c)
234{ 234{
235 if (!IS_ERR_OR_NULL(debug)) { 235 if (!IS_ERR_OR_NULL(bcache_debug)) {
236 char name[50]; 236 char name[50];
237 snprintf(name, 50, "bcache-%pU", c->sb.set_uuid); 237 snprintf(name, 50, "bcache-%pU", c->sb.set_uuid);
238 238
239 c->debug = debugfs_create_file(name, 0400, debug, c, 239 c->debug = debugfs_create_file(name, 0400, bcache_debug, c,
240 &cache_set_debug_ops); 240 &cache_set_debug_ops);
241 } 241 }
242} 242}
@@ -245,13 +245,13 @@ void bch_debug_init_cache_set(struct cache_set *c)
245 245
246void bch_debug_exit(void) 246void bch_debug_exit(void)
247{ 247{
248 if (!IS_ERR_OR_NULL(debug)) 248 if (!IS_ERR_OR_NULL(bcache_debug))
249 debugfs_remove_recursive(debug); 249 debugfs_remove_recursive(bcache_debug);
250} 250}
251 251
252int __init bch_debug_init(struct kobject *kobj) 252int __init bch_debug_init(struct kobject *kobj)
253{ 253{
254 debug = debugfs_create_dir("bcache", NULL); 254 bcache_debug = debugfs_create_dir("bcache", NULL);
255 255
256 return IS_ERR_OR_NULL(debug); 256 return IS_ERR_OR_NULL(bcache_debug);
257} 257}
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 7b45160e9a22..f1f64853114b 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2224,7 +2224,6 @@ static int __init bcache_init(void)
2224 mutex_init(&bch_register_lock); 2224 mutex_init(&bch_register_lock);
2225 init_waitqueue_head(&unregister_wait); 2225 init_waitqueue_head(&unregister_wait);
2226 register_reboot_notifier(&reboot); 2226 register_reboot_notifier(&reboot);
2227 closure_debug_init();
2228 2227
2229 bcache_major = register_blkdev(0, "bcache"); 2228 bcache_major = register_blkdev(0, "bcache");
2230 if (bcache_major < 0) { 2229 if (bcache_major < 0) {
@@ -2236,7 +2235,7 @@ static int __init bcache_init(void)
2236 if (!(bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0)) || 2235 if (!(bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0)) ||
2237 !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) || 2236 !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) ||
2238 bch_request_init() || 2237 bch_request_init() ||
2239 bch_debug_init(bcache_kobj) || 2238 bch_debug_init(bcache_kobj) || closure_debug_init() ||
2240 sysfs_create_files(bcache_kobj, files)) 2239 sysfs_create_files(bcache_kobj, files))
2241 goto err; 2240 goto err;
2242 2241