aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatias Bjorling <m@bjorling.me>2014-11-26 16:45:48 -0500
committerJens Axboe <axboe@fb.com>2014-11-26 16:45:48 -0500
commit709c8667ada1fa26ac941bb875892afc0046b3e2 (patch)
tree5d8c74e5ac0bc869bec66503dde23e7fae70a6ab
parentfa573f72790c2c2b9bfd758c5d33959af4a39915 (diff)
null_blk: boundary check queue_mode and irqmode
When either queue_mode or irq_mode parameter is set outside its boundaries, the driver will not complete requests. This stalls driver initialization when partitions are probed. Fix by setting out of bound values to the parameters default. Signed-off-by: Matias Bjørling <m@bjorling.me> Updated by me to have the parse+check in just one function. Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--drivers/block/null_blk.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index caa61212fdb5..ae9f615382f6 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -78,7 +78,33 @@ module_param(home_node, int, S_IRUGO);
78MODULE_PARM_DESC(home_node, "Home node for the device"); 78MODULE_PARM_DESC(home_node, "Home node for the device");
79 79
80static int queue_mode = NULL_Q_MQ; 80static int queue_mode = NULL_Q_MQ;
81module_param(queue_mode, int, S_IRUGO); 81
82static int null_param_store_val(const char *str, int *val, int min, int max)
83{
84 int ret, new_val;
85
86 ret = kstrtoint(str, 10, &new_val);
87 if (ret)
88 return -EINVAL;
89
90 if (new_val < min || new_val > max)
91 return -EINVAL;
92
93 *val = new_val;
94 return 0;
95}
96
97static int null_set_queue_mode(const char *str, const struct kernel_param *kp)
98{
99 return null_param_store_val(str, &queue_mode, NULL_Q_BIO, NULL_Q_MQ);
100}
101
102static struct kernel_param_ops null_queue_mode_param_ops = {
103 .set = null_set_queue_mode,
104 .get = param_get_int,
105};
106
107device_param_cb(queue_mode, &null_queue_mode_param_ops, &queue_mode, S_IRUGO);
82MODULE_PARM_DESC(queue_mode, "Block interface to use (0=bio,1=rq,2=multiqueue)"); 108MODULE_PARM_DESC(queue_mode, "Block interface to use (0=bio,1=rq,2=multiqueue)");
83 109
84static int gb = 250; 110static int gb = 250;
@@ -94,7 +120,19 @@ module_param(nr_devices, int, S_IRUGO);
94MODULE_PARM_DESC(nr_devices, "Number of devices to register"); 120MODULE_PARM_DESC(nr_devices, "Number of devices to register");
95 121
96static int irqmode = NULL_IRQ_SOFTIRQ; 122static int irqmode = NULL_IRQ_SOFTIRQ;
97module_param(irqmode, int, S_IRUGO); 123
124static int null_set_irqmode(const char *str, const struct kernel_param *kp)
125{
126 return null_param_store_val(str, &irqmode, NULL_IRQ_NONE,
127 NULL_IRQ_TIMER);
128}
129
130static struct kernel_param_ops null_irqmode_param_ops = {
131 .set = null_set_irqmode,
132 .get = param_get_int,
133};
134
135device_param_cb(irqmode, &null_irqmode_param_ops, &irqmode, S_IRUGO);
98MODULE_PARM_DESC(irqmode, "IRQ completion handler. 0-none, 1-softirq, 2-timer"); 136MODULE_PARM_DESC(irqmode, "IRQ completion handler. 0-none, 1-softirq, 2-timer");
99 137
100static int completion_nsec = 10000; 138static int completion_nsec = 10000;