Compare changes

Choose any two refs to compare.

+43 -43
+1 -9
drivers/md/bcache/Kconfig
··· 4 4 tristate "Block device as cache" 5 5 select BLOCK_HOLDER_DEPRECATED if SYSFS 6 6 select CRC64 7 + select CLOSURES 7 8 help 8 9 Allows a block device to be used as cache for other devices; uses 9 10 a btree for indexing and the layout is optimized for SSDs. ··· 19 20 Enables extra debugging tools, allows expensive runtime checks to be 20 21 turned on. 21 22 22 - config BCACHE_CLOSURES_DEBUG 23 - bool "Debug closures" 24 - depends on BCACHE 25 - select DEBUG_FS 26 - help 27 - Keeps all active closures in a linked list and provides a debugfs 28 - interface to list them, which makes it possible to see asynchronous 29 - operations that get stuck. 30 - 31 23 config BCACHE_ASYNC_REGISTRATION 32 24 bool "Asynchronous device registration" 33 25 depends on BCACHE
+2 -2
drivers/md/bcache/Makefile
··· 2 2 3 3 obj-$(CONFIG_BCACHE) += bcache.o 4 4 5 - bcache-y := alloc.o bset.o btree.o closure.o debug.o extents.o\ 6 - io.o journal.o movinggc.o request.o stats.o super.o sysfs.o trace.o\ 5 + bcache-y := alloc.o bset.o btree.o debug.o extents.o io.o\ 6 + journal.o movinggc.o request.o stats.o super.o sysfs.o trace.o\ 7 7 util.o writeback.o features.o
+1 -1
drivers/md/bcache/bcache.h
··· 179 179 #define pr_fmt(fmt) "bcache: %s() " fmt, __func__ 180 180 181 181 #include <linux/bio.h> 182 + #include <linux/closure.h> 182 183 #include <linux/kobject.h> 183 184 #include <linux/list.h> 184 185 #include <linux/mutex.h> ··· 192 193 #include "bcache_ondisk.h" 193 194 #include "bset.h" 194 195 #include "util.h" 195 - #include "closure.h" 196 196 197 197 struct bucket { 198 198 atomic_t pin;
-1
drivers/md/bcache/super.c
··· 2905 2905 goto err; 2906 2906 2907 2907 bch_debug_init(); 2908 - closure_debug_init(); 2909 2908 2910 2909 bcache_is_reboot = false; 2911 2910
+1 -2
drivers/md/bcache/util.h
··· 4 4 #define _BCACHE_UTIL_H 5 5 6 6 #include <linux/blkdev.h> 7 + #include <linux/closure.h> 7 8 #include <linux/errno.h> 8 9 #include <linux/kernel.h> 9 10 #include <linux/sched/clock.h> ··· 13 14 #include <linux/workqueue.h> 14 15 #include <linux/crc64.h> 15 16 16 - #include "closure.h" 17 - 18 17 struct closure; 19 18 20 19 #ifdef CONFIG_BCACHE_DEBUG
+8 -9
drivers/md/bcache/closure.h include/linux/closure.h
··· 155 155 156 156 atomic_t remaining; 157 157 158 - #ifdef CONFIG_BCACHE_CLOSURES_DEBUG 158 + #ifdef CONFIG_DEBUG_CLOSURES 159 159 #define CLOSURE_MAGIC_DEAD 0xc054dead 160 160 #define CLOSURE_MAGIC_ALIVE 0xc054a11e 161 161 ··· 184 184 __closure_sync(cl); 185 185 } 186 186 187 - #ifdef CONFIG_BCACHE_CLOSURES_DEBUG 187 + #ifdef CONFIG_DEBUG_CLOSURES 188 188 189 - void closure_debug_init(void); 190 189 void closure_debug_create(struct closure *cl); 191 190 void closure_debug_destroy(struct closure *cl); 192 191 193 192 #else 194 193 195 - static inline void closure_debug_init(void) {} 196 194 static inline void closure_debug_create(struct closure *cl) {} 197 195 static inline void closure_debug_destroy(struct closure *cl) {} 198 196 ··· 200 198 201 199 static inline void closure_set_ip(struct closure *cl) 202 200 { 203 - #ifdef CONFIG_BCACHE_CLOSURES_DEBUG 201 + #ifdef CONFIG_DEBUG_CLOSURES 204 202 cl->ip = _THIS_IP_; 205 203 #endif 206 204 } 207 205 208 206 static inline void closure_set_ret_ip(struct closure *cl) 209 207 { 210 - #ifdef CONFIG_BCACHE_CLOSURES_DEBUG 208 + #ifdef CONFIG_DEBUG_CLOSURES 211 209 cl->ip = _RET_IP_; 212 210 #endif 213 211 } 214 212 215 213 static inline void closure_set_waiting(struct closure *cl, unsigned long f) 216 214 { 217 - #ifdef CONFIG_BCACHE_CLOSURES_DEBUG 215 + #ifdef CONFIG_DEBUG_CLOSURES 218 216 cl->waiting_on = f; 219 217 #endif 220 218 } ··· 243 241 */ 244 242 BUILD_BUG_ON(offsetof(struct closure, fn) 245 243 != offsetof(struct work_struct, func)); 244 + 246 245 if (wq) { 247 246 INIT_WORK(&cl->work, cl->work.func); 248 247 BUG_ON(!queue_work(wq, &cl->work)); ··· 255 254 */ 256 255 static inline void closure_get(struct closure *cl) 257 256 { 258 - #ifdef CONFIG_BCACHE_CLOSURES_DEBUG 257 + #ifdef CONFIG_DEBUG_CLOSURES 259 258 BUG_ON((atomic_inc_return(&cl->remaining) & 260 259 CLOSURE_REMAINING_MASK) <= 1); 261 260 #else ··· 271 270 */ 272 271 static inline void closure_init(struct closure *cl, struct closure *parent) 273 272 { 274 - memset(cl, 0, sizeof(struct closure)); 273 + cl->fn = NULL; 275 274 cl->parent = parent; 276 275 if (parent) 277 276 closure_get(parent);
+3
lib/Kconfig
··· 506 506 507 507 for more information. 508 508 509 + config CLOSURES 510 + bool 511 + 509 512 config HAS_IOMEM 510 513 bool 511 514 depends on !NO_IOMEM
+9
lib/Kconfig.debug
··· 1720 1720 This is a relatively cheap check but if you care about maximum 1721 1721 performance, say N. 1722 1722 1723 + config DEBUG_CLOSURES 1724 + bool "Debug closures (bcache async widgits)" 1725 + depends on CLOSURES 1726 + select DEBUG_FS 1727 + help 1728 + Keeps all active closures in a linked list and provides a debugfs 1729 + interface to list them, which makes it possible to see asynchronous 1730 + operations that get stuck. 1731 + 1723 1732 config DEBUG_MAPLE_TREE 1724 1733 bool "Debug maple trees" 1725 1734 depends on DEBUG_KERNEL
+2
lib/Makefile
··· 255 255 256 256 obj-$(CONFIG_CPU_RMAP) += cpu_rmap.o 257 257 258 + obj-$(CONFIG_CLOSURES) += closure.o 259 + 258 260 obj-$(CONFIG_DQL) += dynamic_queue_limits.o 259 261 260 262 obj-$(CONFIG_GLOB) += glob.o
+16 -19
drivers/md/bcache/closure.c lib/closure.c
··· 6 6 * Copyright 2012 Google, Inc. 7 7 */ 8 8 9 + #include <linux/closure.h> 9 10 #include <linux/debugfs.h> 10 - #include <linux/module.h> 11 + #include <linux/export.h> 11 12 #include <linux/seq_file.h> 12 13 #include <linux/sched/debug.h> 13 14 14 - #include "closure.h" 15 - 16 15 static inline void closure_put_after_sub(struct closure *cl, int flags) 17 16 { 18 17 int r = flags & CLOSURE_REMAINING_MASK; ··· 45 44 { 46 45 closure_put_after_sub(cl, atomic_sub_return(v, &cl->remaining)); 47 46 } 47 + EXPORT_SYMBOL(closure_sub); 48 48 49 49 /* 50 50 * closure_put - decrement a closure's refcount ··· 53 53 { 54 54 closure_put_after_sub(cl, atomic_dec_return(&cl->remaining)); 55 55 } 56 + EXPORT_SYMBOL(closure_put); 56 57 57 58 /* 58 59 * closure_wake_up - wake up all closures on a wait list, without memory barrier ··· 74 75 closure_sub(cl, CLOSURE_WAITING + 1); 75 76 } 76 77 } 78 + EXPORT_SYMBOL(__closure_wake_up); 77 79 78 80 /** 79 81 * closure_wait - add a closure to a waitlist ··· 93 95 94 96 return true; 95 97 } 98 + EXPORT_SYMBOL(closure_wait); 96 99 97 100 struct closure_syncer { 98 101 struct task_struct *task; ··· 127 130 128 131 __set_current_state(TASK_RUNNING); 129 132 } 133 + EXPORT_SYMBOL(__closure_sync); 130 134 131 - #ifdef CONFIG_BCACHE_CLOSURES_DEBUG 135 + #ifdef CONFIG_DEBUG_CLOSURES 132 136 133 137 static LIST_HEAD(closure_list); 134 138 static DEFINE_SPINLOCK(closure_list_lock); ··· 144 148 list_add(&cl->all, &closure_list); 145 149 spin_unlock_irqrestore(&closure_list_lock, flags); 146 150 } 151 + EXPORT_SYMBOL(closure_debug_create); 147 152 148 153 void closure_debug_destroy(struct closure *cl) 149 154 { ··· 156 161 list_del(&cl->all); 157 162 spin_unlock_irqrestore(&closure_list_lock, flags); 158 163 } 159 - 160 - static struct dentry *closure_debug; 164 + EXPORT_SYMBOL(closure_debug_destroy); 161 165 162 166 static int debug_show(struct seq_file *f, void *data) 163 167 { ··· 181 185 seq_printf(f, " W %pS\n", 182 186 (void *) cl->waiting_on); 183 187 184 - seq_printf(f, "\n"); 188 + seq_puts(f, "\n"); 185 189 } 186 190 187 191 spin_unlock_irq(&closure_list_lock); ··· 190 194 191 195 DEFINE_SHOW_ATTRIBUTE(debug); 192 196 193 - void __init closure_debug_init(void) 197 + static int __init closure_debug_init(void) 194 198 { 195 - if (!IS_ERR_OR_NULL(bcache_debug)) 196 - /* 197 - * it is unnecessary to check return value of 198 - * debugfs_create_file(), we should not care 199 - * about this. 200 - */ 201 - closure_debug = debugfs_create_file( 202 - "closures", 0400, bcache_debug, NULL, &debug_fops); 199 + debugfs_create_file("closures", 0400, NULL, NULL, &debug_fops); 200 + return 0; 203 201 } 204 - #endif 202 + late_initcall(closure_debug_init) 205 203 206 - MODULE_AUTHOR("Kent Overstreet <koverstreet@google.com>"); 207 - MODULE_LICENSE("GPL"); 204 + #endif