Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
8324aa91 JA |
2 | /* |
3 | * Functions related to sysfs handling | |
4 | */ | |
5 | #include <linux/kernel.h> | |
5a0e3ad6 | 6 | #include <linux/slab.h> |
8324aa91 JA |
7 | #include <linux/module.h> |
8 | #include <linux/bio.h> | |
9 | #include <linux/blkdev.h> | |
66114cad | 10 | #include <linux/backing-dev.h> |
8324aa91 | 11 | #include <linux/blktrace_api.h> |
320ae51f | 12 | #include <linux/blk-mq.h> |
eea8f41c | 13 | #include <linux/blk-cgroup.h> |
8324aa91 JA |
14 | |
15 | #include "blk.h" | |
3edcc0ce | 16 | #include "blk-mq.h" |
d173a251 | 17 | #include "blk-mq-debugfs.h" |
87760e5e | 18 | #include "blk-wbt.h" |
8324aa91 JA |
19 | |
20 | struct queue_sysfs_entry { | |
21 | struct attribute attr; | |
22 | ssize_t (*show)(struct request_queue *, char *); | |
23 | ssize_t (*store)(struct request_queue *, const char *, size_t); | |
24 | }; | |
25 | ||
26 | static ssize_t | |
9cb308ce | 27 | queue_var_show(unsigned long var, char *page) |
8324aa91 | 28 | { |
9cb308ce | 29 | return sprintf(page, "%lu\n", var); |
8324aa91 JA |
30 | } |
31 | ||
32 | static ssize_t | |
33 | queue_var_store(unsigned long *var, const char *page, size_t count) | |
34 | { | |
b1f3b64d DR |
35 | int err; |
36 | unsigned long v; | |
37 | ||
ed751e68 | 38 | err = kstrtoul(page, 10, &v); |
b1f3b64d DR |
39 | if (err || v > UINT_MAX) |
40 | return -EINVAL; | |
41 | ||
42 | *var = v; | |
8324aa91 | 43 | |
8324aa91 JA |
44 | return count; |
45 | } | |
46 | ||
80e091d1 | 47 | static ssize_t queue_var_store64(s64 *var, const char *page) |
87760e5e JA |
48 | { |
49 | int err; | |
80e091d1 | 50 | s64 v; |
87760e5e | 51 | |
80e091d1 | 52 | err = kstrtos64(page, 10, &v); |
87760e5e JA |
53 | if (err < 0) |
54 | return err; | |
55 | ||
56 | *var = v; | |
57 | return 0; | |
58 | } | |
59 | ||
8324aa91 JA |
60 | static ssize_t queue_requests_show(struct request_queue *q, char *page) |
61 | { | |
62 | return queue_var_show(q->nr_requests, (page)); | |
63 | } | |
64 | ||
65 | static ssize_t | |
66 | queue_requests_store(struct request_queue *q, const char *page, size_t count) | |
67 | { | |
8324aa91 | 68 | unsigned long nr; |
e3a2b3f9 | 69 | int ret, err; |
b8a9ae77 | 70 | |
a1ce35fa | 71 | if (!q->mq_ops) |
b8a9ae77 JA |
72 | return -EINVAL; |
73 | ||
74 | ret = queue_var_store(&nr, page, count); | |
b1f3b64d DR |
75 | if (ret < 0) |
76 | return ret; | |
77 | ||
8324aa91 JA |
78 | if (nr < BLKDEV_MIN_RQ) |
79 | nr = BLKDEV_MIN_RQ; | |
80 | ||
a1ce35fa | 81 | err = blk_mq_update_nr_requests(q, nr); |
e3a2b3f9 JA |
82 | if (err) |
83 | return err; | |
84 | ||
8324aa91 JA |
85 | return ret; |
86 | } | |
87 | ||
88 | static ssize_t queue_ra_show(struct request_queue *q, char *page) | |
89 | { | |
dc3b17cc | 90 | unsigned long ra_kb = q->backing_dev_info->ra_pages << |
09cbfeaf | 91 | (PAGE_SHIFT - 10); |
8324aa91 JA |
92 | |
93 | return queue_var_show(ra_kb, (page)); | |
94 | } | |
95 | ||
96 | static ssize_t | |
97 | queue_ra_store(struct request_queue *q, const char *page, size_t count) | |
98 | { | |
99 | unsigned long ra_kb; | |
100 | ssize_t ret = queue_var_store(&ra_kb, page, count); | |
101 | ||
b1f3b64d DR |
102 | if (ret < 0) |
103 | return ret; | |
104 | ||
dc3b17cc | 105 | q->backing_dev_info->ra_pages = ra_kb >> (PAGE_SHIFT - 10); |
8324aa91 JA |
106 | |
107 | return ret; | |
108 | } | |
109 | ||
110 | static ssize_t queue_max_sectors_show(struct request_queue *q, char *page) | |
111 | { | |
ae03bf63 | 112 | int max_sectors_kb = queue_max_sectors(q) >> 1; |
8324aa91 JA |
113 | |
114 | return queue_var_show(max_sectors_kb, (page)); | |
115 | } | |
116 | ||
c77a5710 MP |
117 | static ssize_t queue_max_segments_show(struct request_queue *q, char *page) |
118 | { | |
119 | return queue_var_show(queue_max_segments(q), (page)); | |
120 | } | |
121 | ||
1e739730 CH |
122 | static ssize_t queue_max_discard_segments_show(struct request_queue *q, |
123 | char *page) | |
124 | { | |
125 | return queue_var_show(queue_max_discard_segments(q), (page)); | |
126 | } | |
127 | ||
13f05c8d MP |
128 | static ssize_t queue_max_integrity_segments_show(struct request_queue *q, char *page) |
129 | { | |
130 | return queue_var_show(q->limits.max_integrity_segments, (page)); | |
131 | } | |
132 | ||
c77a5710 MP |
133 | static ssize_t queue_max_segment_size_show(struct request_queue *q, char *page) |
134 | { | |
e692cb66 | 135 | if (blk_queue_cluster(q)) |
c77a5710 MP |
136 | return queue_var_show(queue_max_segment_size(q), (page)); |
137 | ||
09cbfeaf | 138 | return queue_var_show(PAGE_SIZE, (page)); |
c77a5710 MP |
139 | } |
140 | ||
e1defc4f | 141 | static ssize_t queue_logical_block_size_show(struct request_queue *q, char *page) |
e68b903c | 142 | { |
e1defc4f | 143 | return queue_var_show(queue_logical_block_size(q), page); |
e68b903c MP |
144 | } |
145 | ||
c72758f3 MP |
146 | static ssize_t queue_physical_block_size_show(struct request_queue *q, char *page) |
147 | { | |
148 | return queue_var_show(queue_physical_block_size(q), page); | |
149 | } | |
150 | ||
87caf97c HR |
151 | static ssize_t queue_chunk_sectors_show(struct request_queue *q, char *page) |
152 | { | |
153 | return queue_var_show(q->limits.chunk_sectors, page); | |
154 | } | |
155 | ||
c72758f3 MP |
156 | static ssize_t queue_io_min_show(struct request_queue *q, char *page) |
157 | { | |
158 | return queue_var_show(queue_io_min(q), page); | |
159 | } | |
160 | ||
161 | static ssize_t queue_io_opt_show(struct request_queue *q, char *page) | |
162 | { | |
163 | return queue_var_show(queue_io_opt(q), page); | |
e68b903c MP |
164 | } |
165 | ||
86b37281 MP |
166 | static ssize_t queue_discard_granularity_show(struct request_queue *q, char *page) |
167 | { | |
168 | return queue_var_show(q->limits.discard_granularity, page); | |
169 | } | |
170 | ||
0034af03 JA |
171 | static ssize_t queue_discard_max_hw_show(struct request_queue *q, char *page) |
172 | { | |
0034af03 | 173 | |
18f922d0 A |
174 | return sprintf(page, "%llu\n", |
175 | (unsigned long long)q->limits.max_hw_discard_sectors << 9); | |
0034af03 JA |
176 | } |
177 | ||
86b37281 MP |
178 | static ssize_t queue_discard_max_show(struct request_queue *q, char *page) |
179 | { | |
a934a00a MP |
180 | return sprintf(page, "%llu\n", |
181 | (unsigned long long)q->limits.max_discard_sectors << 9); | |
86b37281 MP |
182 | } |
183 | ||
0034af03 JA |
184 | static ssize_t queue_discard_max_store(struct request_queue *q, |
185 | const char *page, size_t count) | |
186 | { | |
187 | unsigned long max_discard; | |
188 | ssize_t ret = queue_var_store(&max_discard, page, count); | |
189 | ||
190 | if (ret < 0) | |
191 | return ret; | |
192 | ||
193 | if (max_discard & (q->limits.discard_granularity - 1)) | |
194 | return -EINVAL; | |
195 | ||
196 | max_discard >>= 9; | |
197 | if (max_discard > UINT_MAX) | |
198 | return -EINVAL; | |
199 | ||
200 | if (max_discard > q->limits.max_hw_discard_sectors) | |
201 | max_discard = q->limits.max_hw_discard_sectors; | |
202 | ||
203 | q->limits.max_discard_sectors = max_discard; | |
204 | return ret; | |
205 | } | |
206 | ||
98262f27 MP |
207 | static ssize_t queue_discard_zeroes_data_show(struct request_queue *q, char *page) |
208 | { | |
48920ff2 | 209 | return queue_var_show(0, page); |
98262f27 MP |
210 | } |
211 | ||
4363ac7c MP |
212 | static ssize_t queue_write_same_max_show(struct request_queue *q, char *page) |
213 | { | |
214 | return sprintf(page, "%llu\n", | |
215 | (unsigned long long)q->limits.max_write_same_sectors << 9); | |
216 | } | |
217 | ||
a6f0788e CK |
218 | static ssize_t queue_write_zeroes_max_show(struct request_queue *q, char *page) |
219 | { | |
220 | return sprintf(page, "%llu\n", | |
221 | (unsigned long long)q->limits.max_write_zeroes_sectors << 9); | |
222 | } | |
4363ac7c | 223 | |
8324aa91 JA |
224 | static ssize_t |
225 | queue_max_sectors_store(struct request_queue *q, const char *page, size_t count) | |
226 | { | |
227 | unsigned long max_sectors_kb, | |
ae03bf63 | 228 | max_hw_sectors_kb = queue_max_hw_sectors(q) >> 1, |
09cbfeaf | 229 | page_kb = 1 << (PAGE_SHIFT - 10); |
8324aa91 JA |
230 | ssize_t ret = queue_var_store(&max_sectors_kb, page, count); |
231 | ||
b1f3b64d DR |
232 | if (ret < 0) |
233 | return ret; | |
234 | ||
ca369d51 MP |
235 | max_hw_sectors_kb = min_not_zero(max_hw_sectors_kb, (unsigned long) |
236 | q->limits.max_dev_sectors >> 1); | |
237 | ||
8324aa91 JA |
238 | if (max_sectors_kb > max_hw_sectors_kb || max_sectors_kb < page_kb) |
239 | return -EINVAL; | |
7c239517 | 240 | |
8324aa91 | 241 | spin_lock_irq(q->queue_lock); |
c295fc05 | 242 | q->limits.max_sectors = max_sectors_kb << 1; |
dc3b17cc | 243 | q->backing_dev_info->io_pages = max_sectors_kb >> (PAGE_SHIFT - 10); |
8324aa91 JA |
244 | spin_unlock_irq(q->queue_lock); |
245 | ||
246 | return ret; | |
247 | } | |
248 | ||
249 | static ssize_t queue_max_hw_sectors_show(struct request_queue *q, char *page) | |
250 | { | |
ae03bf63 | 251 | int max_hw_sectors_kb = queue_max_hw_sectors(q) >> 1; |
8324aa91 JA |
252 | |
253 | return queue_var_show(max_hw_sectors_kb, (page)); | |
254 | } | |
255 | ||
956bcb7c JA |
256 | #define QUEUE_SYSFS_BIT_FNS(name, flag, neg) \ |
257 | static ssize_t \ | |
258 | queue_show_##name(struct request_queue *q, char *page) \ | |
259 | { \ | |
260 | int bit; \ | |
261 | bit = test_bit(QUEUE_FLAG_##flag, &q->queue_flags); \ | |
262 | return queue_var_show(neg ? !bit : bit, page); \ | |
263 | } \ | |
264 | static ssize_t \ | |
265 | queue_store_##name(struct request_queue *q, const char *page, size_t count) \ | |
266 | { \ | |
267 | unsigned long val; \ | |
268 | ssize_t ret; \ | |
269 | ret = queue_var_store(&val, page, count); \ | |
c678ef52 AB |
270 | if (ret < 0) \ |
271 | return ret; \ | |
956bcb7c JA |
272 | if (neg) \ |
273 | val = !val; \ | |
274 | \ | |
956bcb7c | 275 | if (val) \ |
8814ce8a | 276 | blk_queue_flag_set(QUEUE_FLAG_##flag, q); \ |
956bcb7c | 277 | else \ |
8814ce8a | 278 | blk_queue_flag_clear(QUEUE_FLAG_##flag, q); \ |
956bcb7c | 279 | return ret; \ |
1308835f BZ |
280 | } |
281 | ||
956bcb7c JA |
282 | QUEUE_SYSFS_BIT_FNS(nonrot, NONROT, 1); |
283 | QUEUE_SYSFS_BIT_FNS(random, ADD_RANDOM, 0); | |
284 | QUEUE_SYSFS_BIT_FNS(iostats, IO_STAT, 0); | |
285 | #undef QUEUE_SYSFS_BIT_FNS | |
1308835f | 286 | |
797476b8 DLM |
287 | static ssize_t queue_zoned_show(struct request_queue *q, char *page) |
288 | { | |
289 | switch (blk_queue_zoned_model(q)) { | |
290 | case BLK_ZONED_HA: | |
291 | return sprintf(page, "host-aware\n"); | |
292 | case BLK_ZONED_HM: | |
293 | return sprintf(page, "host-managed\n"); | |
294 | default: | |
295 | return sprintf(page, "none\n"); | |
296 | } | |
297 | } | |
298 | ||
965b652e DLM |
299 | static ssize_t queue_nr_zones_show(struct request_queue *q, char *page) |
300 | { | |
301 | return queue_var_show(blk_queue_nr_zones(q), page); | |
302 | } | |
303 | ||
ac9fafa1 AB |
304 | static ssize_t queue_nomerges_show(struct request_queue *q, char *page) |
305 | { | |
488991e2 AB |
306 | return queue_var_show((blk_queue_nomerges(q) << 1) | |
307 | blk_queue_noxmerges(q), page); | |
ac9fafa1 AB |
308 | } |
309 | ||
310 | static ssize_t queue_nomerges_store(struct request_queue *q, const char *page, | |
311 | size_t count) | |
312 | { | |
313 | unsigned long nm; | |
314 | ssize_t ret = queue_var_store(&nm, page, count); | |
315 | ||
b1f3b64d DR |
316 | if (ret < 0) |
317 | return ret; | |
318 | ||
bf0f9702 | 319 | spin_lock_irq(q->queue_lock); |
488991e2 AB |
320 | queue_flag_clear(QUEUE_FLAG_NOMERGES, q); |
321 | queue_flag_clear(QUEUE_FLAG_NOXMERGES, q); | |
322 | if (nm == 2) | |
bf0f9702 | 323 | queue_flag_set(QUEUE_FLAG_NOMERGES, q); |
488991e2 AB |
324 | else if (nm) |
325 | queue_flag_set(QUEUE_FLAG_NOXMERGES, q); | |
bf0f9702 | 326 | spin_unlock_irq(q->queue_lock); |
1308835f | 327 | |
ac9fafa1 AB |
328 | return ret; |
329 | } | |
330 | ||
c7c22e4d JA |
331 | static ssize_t queue_rq_affinity_show(struct request_queue *q, char *page) |
332 | { | |
9cb308ce | 333 | bool set = test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags); |
5757a6d7 | 334 | bool force = test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags); |
c7c22e4d | 335 | |
5757a6d7 | 336 | return queue_var_show(set << force, page); |
c7c22e4d JA |
337 | } |
338 | ||
339 | static ssize_t | |
340 | queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count) | |
341 | { | |
342 | ssize_t ret = -EINVAL; | |
0a06ff06 | 343 | #ifdef CONFIG_SMP |
c7c22e4d JA |
344 | unsigned long val; |
345 | ||
346 | ret = queue_var_store(&val, page, count); | |
b1f3b64d DR |
347 | if (ret < 0) |
348 | return ret; | |
349 | ||
c7c22e4d | 350 | spin_lock_irq(q->queue_lock); |
e8037d49 | 351 | if (val == 2) { |
c7c22e4d | 352 | queue_flag_set(QUEUE_FLAG_SAME_COMP, q); |
e8037d49 ES |
353 | queue_flag_set(QUEUE_FLAG_SAME_FORCE, q); |
354 | } else if (val == 1) { | |
355 | queue_flag_set(QUEUE_FLAG_SAME_COMP, q); | |
356 | queue_flag_clear(QUEUE_FLAG_SAME_FORCE, q); | |
357 | } else if (val == 0) { | |
5757a6d7 DW |
358 | queue_flag_clear(QUEUE_FLAG_SAME_COMP, q); |
359 | queue_flag_clear(QUEUE_FLAG_SAME_FORCE, q); | |
360 | } | |
c7c22e4d JA |
361 | spin_unlock_irq(q->queue_lock); |
362 | #endif | |
363 | return ret; | |
364 | } | |
8324aa91 | 365 | |
06426adf JA |
366 | static ssize_t queue_poll_delay_show(struct request_queue *q, char *page) |
367 | { | |
64f1c21e JA |
368 | int val; |
369 | ||
370 | if (q->poll_nsec == -1) | |
371 | val = -1; | |
372 | else | |
373 | val = q->poll_nsec / 1000; | |
374 | ||
375 | return sprintf(page, "%d\n", val); | |
06426adf JA |
376 | } |
377 | ||
378 | static ssize_t queue_poll_delay_store(struct request_queue *q, const char *page, | |
379 | size_t count) | |
380 | { | |
64f1c21e | 381 | int err, val; |
06426adf JA |
382 | |
383 | if (!q->mq_ops || !q->mq_ops->poll) | |
384 | return -EINVAL; | |
385 | ||
64f1c21e JA |
386 | err = kstrtoint(page, 10, &val); |
387 | if (err < 0) | |
388 | return err; | |
06426adf | 389 | |
64f1c21e JA |
390 | if (val == -1) |
391 | q->poll_nsec = -1; | |
392 | else | |
393 | q->poll_nsec = val * 1000; | |
394 | ||
395 | return count; | |
06426adf JA |
396 | } |
397 | ||
05229bee JA |
398 | static ssize_t queue_poll_show(struct request_queue *q, char *page) |
399 | { | |
400 | return queue_var_show(test_bit(QUEUE_FLAG_POLL, &q->queue_flags), page); | |
401 | } | |
402 | ||
403 | static ssize_t queue_poll_store(struct request_queue *q, const char *page, | |
404 | size_t count) | |
405 | { | |
406 | unsigned long poll_on; | |
407 | ssize_t ret; | |
408 | ||
409 | if (!q->mq_ops || !q->mq_ops->poll) | |
410 | return -EINVAL; | |
411 | ||
412 | ret = queue_var_store(&poll_on, page, count); | |
413 | if (ret < 0) | |
414 | return ret; | |
415 | ||
05229bee | 416 | if (poll_on) |
8814ce8a | 417 | blk_queue_flag_set(QUEUE_FLAG_POLL, q); |
05229bee | 418 | else |
8814ce8a | 419 | blk_queue_flag_clear(QUEUE_FLAG_POLL, q); |
05229bee JA |
420 | |
421 | return ret; | |
422 | } | |
423 | ||
87760e5e JA |
424 | static ssize_t queue_wb_lat_show(struct request_queue *q, char *page) |
425 | { | |
a7905043 | 426 | if (!wbt_rq_qos(q)) |
87760e5e JA |
427 | return -EINVAL; |
428 | ||
a7905043 | 429 | return sprintf(page, "%llu\n", div_u64(wbt_get_min_lat(q), 1000)); |
87760e5e JA |
430 | } |
431 | ||
432 | static ssize_t queue_wb_lat_store(struct request_queue *q, const char *page, | |
433 | size_t count) | |
434 | { | |
a7905043 | 435 | struct rq_qos *rqos; |
87760e5e | 436 | ssize_t ret; |
80e091d1 | 437 | s64 val; |
87760e5e | 438 | |
87760e5e JA |
439 | ret = queue_var_store64(&val, page); |
440 | if (ret < 0) | |
441 | return ret; | |
d62118b6 JA |
442 | if (val < -1) |
443 | return -EINVAL; | |
444 | ||
a7905043 JB |
445 | rqos = wbt_rq_qos(q); |
446 | if (!rqos) { | |
d62118b6 JA |
447 | ret = wbt_init(q); |
448 | if (ret) | |
449 | return ret; | |
d62118b6 | 450 | } |
87760e5e | 451 | |
80e091d1 | 452 | if (val == -1) |
a7905043 | 453 | val = wbt_default_latency_nsec(q); |
80e091d1 | 454 | else if (val >= 0) |
a7905043 | 455 | val *= 1000ULL; |
d62118b6 | 456 | |
c125311d JA |
457 | /* |
458 | * Ensure that the queue is idled, in case the latency update | |
459 | * ends up either enabling or disabling wbt completely. We can't | |
460 | * have IO inflight if that happens. | |
461 | */ | |
a1ce35fa JA |
462 | blk_mq_freeze_queue(q); |
463 | blk_mq_quiesce_queue(q); | |
80e091d1 | 464 | |
c125311d | 465 | wbt_set_min_lat(q, val); |
a7905043 | 466 | wbt_update_limits(q); |
c125311d | 467 | |
a1ce35fa JA |
468 | blk_mq_unquiesce_queue(q); |
469 | blk_mq_unfreeze_queue(q); | |
c125311d | 470 | |
87760e5e JA |
471 | return count; |
472 | } | |
473 | ||
93e9d8e8 JA |
474 | static ssize_t queue_wc_show(struct request_queue *q, char *page) |
475 | { | |
476 | if (test_bit(QUEUE_FLAG_WC, &q->queue_flags)) | |
477 | return sprintf(page, "write back\n"); | |
478 | ||
479 | return sprintf(page, "write through\n"); | |
480 | } | |
481 | ||
482 | static ssize_t queue_wc_store(struct request_queue *q, const char *page, | |
483 | size_t count) | |
484 | { | |
485 | int set = -1; | |
486 | ||
487 | if (!strncmp(page, "write back", 10)) | |
488 | set = 1; | |
489 | else if (!strncmp(page, "write through", 13) || | |
490 | !strncmp(page, "none", 4)) | |
491 | set = 0; | |
492 | ||
493 | if (set == -1) | |
494 | return -EINVAL; | |
495 | ||
93e9d8e8 | 496 | if (set) |
8814ce8a | 497 | blk_queue_flag_set(QUEUE_FLAG_WC, q); |
93e9d8e8 | 498 | else |
8814ce8a | 499 | blk_queue_flag_clear(QUEUE_FLAG_WC, q); |
93e9d8e8 JA |
500 | |
501 | return count; | |
502 | } | |
503 | ||
6fcefbe5 KO |
504 | static ssize_t queue_fua_show(struct request_queue *q, char *page) |
505 | { | |
506 | return sprintf(page, "%u\n", test_bit(QUEUE_FLAG_FUA, &q->queue_flags)); | |
507 | } | |
508 | ||
ea6ca600 YK |
509 | static ssize_t queue_dax_show(struct request_queue *q, char *page) |
510 | { | |
511 | return queue_var_show(blk_queue_dax(q), page); | |
512 | } | |
513 | ||
8324aa91 | 514 | static struct queue_sysfs_entry queue_requests_entry = { |
5657a819 | 515 | .attr = {.name = "nr_requests", .mode = 0644 }, |
8324aa91 JA |
516 | .show = queue_requests_show, |
517 | .store = queue_requests_store, | |
518 | }; | |
519 | ||
520 | static struct queue_sysfs_entry queue_ra_entry = { | |
5657a819 | 521 | .attr = {.name = "read_ahead_kb", .mode = 0644 }, |
8324aa91 JA |
522 | .show = queue_ra_show, |
523 | .store = queue_ra_store, | |
524 | }; | |
525 | ||
526 | static struct queue_sysfs_entry queue_max_sectors_entry = { | |
5657a819 | 527 | .attr = {.name = "max_sectors_kb", .mode = 0644 }, |
8324aa91 JA |
528 | .show = queue_max_sectors_show, |
529 | .store = queue_max_sectors_store, | |
530 | }; | |
531 | ||
532 | static struct queue_sysfs_entry queue_max_hw_sectors_entry = { | |
5657a819 | 533 | .attr = {.name = "max_hw_sectors_kb", .mode = 0444 }, |
8324aa91 JA |
534 | .show = queue_max_hw_sectors_show, |
535 | }; | |
536 | ||
c77a5710 | 537 | static struct queue_sysfs_entry queue_max_segments_entry = { |
5657a819 | 538 | .attr = {.name = "max_segments", .mode = 0444 }, |
c77a5710 MP |
539 | .show = queue_max_segments_show, |
540 | }; | |
541 | ||
1e739730 | 542 | static struct queue_sysfs_entry queue_max_discard_segments_entry = { |
5657a819 | 543 | .attr = {.name = "max_discard_segments", .mode = 0444 }, |
1e739730 CH |
544 | .show = queue_max_discard_segments_show, |
545 | }; | |
546 | ||
13f05c8d | 547 | static struct queue_sysfs_entry queue_max_integrity_segments_entry = { |
5657a819 | 548 | .attr = {.name = "max_integrity_segments", .mode = 0444 }, |
13f05c8d MP |
549 | .show = queue_max_integrity_segments_show, |
550 | }; | |
551 | ||
c77a5710 | 552 | static struct queue_sysfs_entry queue_max_segment_size_entry = { |
5657a819 | 553 | .attr = {.name = "max_segment_size", .mode = 0444 }, |
c77a5710 MP |
554 | .show = queue_max_segment_size_show, |
555 | }; | |
556 | ||
8324aa91 | 557 | static struct queue_sysfs_entry queue_iosched_entry = { |
5657a819 | 558 | .attr = {.name = "scheduler", .mode = 0644 }, |
8324aa91 JA |
559 | .show = elv_iosched_show, |
560 | .store = elv_iosched_store, | |
561 | }; | |
562 | ||
e68b903c | 563 | static struct queue_sysfs_entry queue_hw_sector_size_entry = { |
5657a819 | 564 | .attr = {.name = "hw_sector_size", .mode = 0444 }, |
e1defc4f MP |
565 | .show = queue_logical_block_size_show, |
566 | }; | |
567 | ||
568 | static struct queue_sysfs_entry queue_logical_block_size_entry = { | |
5657a819 | 569 | .attr = {.name = "logical_block_size", .mode = 0444 }, |
e1defc4f | 570 | .show = queue_logical_block_size_show, |
e68b903c MP |
571 | }; |
572 | ||
c72758f3 | 573 | static struct queue_sysfs_entry queue_physical_block_size_entry = { |
5657a819 | 574 | .attr = {.name = "physical_block_size", .mode = 0444 }, |
c72758f3 MP |
575 | .show = queue_physical_block_size_show, |
576 | }; | |
577 | ||
87caf97c | 578 | static struct queue_sysfs_entry queue_chunk_sectors_entry = { |
5657a819 | 579 | .attr = {.name = "chunk_sectors", .mode = 0444 }, |
87caf97c HR |
580 | .show = queue_chunk_sectors_show, |
581 | }; | |
582 | ||
c72758f3 | 583 | static struct queue_sysfs_entry queue_io_min_entry = { |
5657a819 | 584 | .attr = {.name = "minimum_io_size", .mode = 0444 }, |
c72758f3 MP |
585 | .show = queue_io_min_show, |
586 | }; | |
587 | ||
588 | static struct queue_sysfs_entry queue_io_opt_entry = { | |
5657a819 | 589 | .attr = {.name = "optimal_io_size", .mode = 0444 }, |
c72758f3 | 590 | .show = queue_io_opt_show, |
e68b903c MP |
591 | }; |
592 | ||
86b37281 | 593 | static struct queue_sysfs_entry queue_discard_granularity_entry = { |
5657a819 | 594 | .attr = {.name = "discard_granularity", .mode = 0444 }, |
86b37281 MP |
595 | .show = queue_discard_granularity_show, |
596 | }; | |
597 | ||
0034af03 | 598 | static struct queue_sysfs_entry queue_discard_max_hw_entry = { |
5657a819 | 599 | .attr = {.name = "discard_max_hw_bytes", .mode = 0444 }, |
0034af03 JA |
600 | .show = queue_discard_max_hw_show, |
601 | }; | |
602 | ||
86b37281 | 603 | static struct queue_sysfs_entry queue_discard_max_entry = { |
5657a819 | 604 | .attr = {.name = "discard_max_bytes", .mode = 0644 }, |
86b37281 | 605 | .show = queue_discard_max_show, |
0034af03 | 606 | .store = queue_discard_max_store, |
86b37281 MP |
607 | }; |
608 | ||
98262f27 | 609 | static struct queue_sysfs_entry queue_discard_zeroes_data_entry = { |
5657a819 | 610 | .attr = {.name = "discard_zeroes_data", .mode = 0444 }, |
98262f27 MP |
611 | .show = queue_discard_zeroes_data_show, |
612 | }; | |
613 | ||
4363ac7c | 614 | static struct queue_sysfs_entry queue_write_same_max_entry = { |
5657a819 | 615 | .attr = {.name = "write_same_max_bytes", .mode = 0444 }, |
4363ac7c MP |
616 | .show = queue_write_same_max_show, |
617 | }; | |
618 | ||
a6f0788e | 619 | static struct queue_sysfs_entry queue_write_zeroes_max_entry = { |
5657a819 | 620 | .attr = {.name = "write_zeroes_max_bytes", .mode = 0444 }, |
a6f0788e CK |
621 | .show = queue_write_zeroes_max_show, |
622 | }; | |
623 | ||
1308835f | 624 | static struct queue_sysfs_entry queue_nonrot_entry = { |
5657a819 | 625 | .attr = {.name = "rotational", .mode = 0644 }, |
956bcb7c JA |
626 | .show = queue_show_nonrot, |
627 | .store = queue_store_nonrot, | |
1308835f BZ |
628 | }; |
629 | ||
797476b8 | 630 | static struct queue_sysfs_entry queue_zoned_entry = { |
5657a819 | 631 | .attr = {.name = "zoned", .mode = 0444 }, |
797476b8 DLM |
632 | .show = queue_zoned_show, |
633 | }; | |
634 | ||
965b652e DLM |
635 | static struct queue_sysfs_entry queue_nr_zones_entry = { |
636 | .attr = {.name = "nr_zones", .mode = 0444 }, | |
637 | .show = queue_nr_zones_show, | |
638 | }; | |
639 | ||
ac9fafa1 | 640 | static struct queue_sysfs_entry queue_nomerges_entry = { |
5657a819 | 641 | .attr = {.name = "nomerges", .mode = 0644 }, |
ac9fafa1 AB |
642 | .show = queue_nomerges_show, |
643 | .store = queue_nomerges_store, | |
644 | }; | |
645 | ||
c7c22e4d | 646 | static struct queue_sysfs_entry queue_rq_affinity_entry = { |
5657a819 | 647 | .attr = {.name = "rq_affinity", .mode = 0644 }, |
c7c22e4d JA |
648 | .show = queue_rq_affinity_show, |
649 | .store = queue_rq_affinity_store, | |
650 | }; | |
651 | ||
bc58ba94 | 652 | static struct queue_sysfs_entry queue_iostats_entry = { |
5657a819 | 653 | .attr = {.name = "iostats", .mode = 0644 }, |
956bcb7c JA |
654 | .show = queue_show_iostats, |
655 | .store = queue_store_iostats, | |
bc58ba94 JA |
656 | }; |
657 | ||
e2e1a148 | 658 | static struct queue_sysfs_entry queue_random_entry = { |
5657a819 | 659 | .attr = {.name = "add_random", .mode = 0644 }, |
956bcb7c JA |
660 | .show = queue_show_random, |
661 | .store = queue_store_random, | |
e2e1a148 JA |
662 | }; |
663 | ||
05229bee | 664 | static struct queue_sysfs_entry queue_poll_entry = { |
5657a819 | 665 | .attr = {.name = "io_poll", .mode = 0644 }, |
05229bee JA |
666 | .show = queue_poll_show, |
667 | .store = queue_poll_store, | |
668 | }; | |
669 | ||
06426adf | 670 | static struct queue_sysfs_entry queue_poll_delay_entry = { |
5657a819 | 671 | .attr = {.name = "io_poll_delay", .mode = 0644 }, |
06426adf JA |
672 | .show = queue_poll_delay_show, |
673 | .store = queue_poll_delay_store, | |
674 | }; | |
675 | ||
93e9d8e8 | 676 | static struct queue_sysfs_entry queue_wc_entry = { |
5657a819 | 677 | .attr = {.name = "write_cache", .mode = 0644 }, |
93e9d8e8 JA |
678 | .show = queue_wc_show, |
679 | .store = queue_wc_store, | |
680 | }; | |
681 | ||
6fcefbe5 | 682 | static struct queue_sysfs_entry queue_fua_entry = { |
5657a819 | 683 | .attr = {.name = "fua", .mode = 0444 }, |
6fcefbe5 KO |
684 | .show = queue_fua_show, |
685 | }; | |
686 | ||
ea6ca600 | 687 | static struct queue_sysfs_entry queue_dax_entry = { |
5657a819 | 688 | .attr = {.name = "dax", .mode = 0444 }, |
ea6ca600 YK |
689 | .show = queue_dax_show, |
690 | }; | |
691 | ||
87760e5e | 692 | static struct queue_sysfs_entry queue_wb_lat_entry = { |
5657a819 | 693 | .attr = {.name = "wbt_lat_usec", .mode = 0644 }, |
87760e5e JA |
694 | .show = queue_wb_lat_show, |
695 | .store = queue_wb_lat_store, | |
696 | }; | |
697 | ||
297e3d85 SL |
698 | #ifdef CONFIG_BLK_DEV_THROTTLING_LOW |
699 | static struct queue_sysfs_entry throtl_sample_time_entry = { | |
5657a819 | 700 | .attr = {.name = "throttle_sample_time", .mode = 0644 }, |
297e3d85 SL |
701 | .show = blk_throtl_sample_time_show, |
702 | .store = blk_throtl_sample_time_store, | |
703 | }; | |
704 | #endif | |
705 | ||
8324aa91 JA |
706 | static struct attribute *default_attrs[] = { |
707 | &queue_requests_entry.attr, | |
708 | &queue_ra_entry.attr, | |
709 | &queue_max_hw_sectors_entry.attr, | |
710 | &queue_max_sectors_entry.attr, | |
c77a5710 | 711 | &queue_max_segments_entry.attr, |
1e739730 | 712 | &queue_max_discard_segments_entry.attr, |
13f05c8d | 713 | &queue_max_integrity_segments_entry.attr, |
c77a5710 | 714 | &queue_max_segment_size_entry.attr, |
8324aa91 | 715 | &queue_iosched_entry.attr, |
e68b903c | 716 | &queue_hw_sector_size_entry.attr, |
e1defc4f | 717 | &queue_logical_block_size_entry.attr, |
c72758f3 | 718 | &queue_physical_block_size_entry.attr, |
87caf97c | 719 | &queue_chunk_sectors_entry.attr, |
c72758f3 MP |
720 | &queue_io_min_entry.attr, |
721 | &queue_io_opt_entry.attr, | |
86b37281 MP |
722 | &queue_discard_granularity_entry.attr, |
723 | &queue_discard_max_entry.attr, | |
0034af03 | 724 | &queue_discard_max_hw_entry.attr, |
98262f27 | 725 | &queue_discard_zeroes_data_entry.attr, |
4363ac7c | 726 | &queue_write_same_max_entry.attr, |
a6f0788e | 727 | &queue_write_zeroes_max_entry.attr, |
1308835f | 728 | &queue_nonrot_entry.attr, |
797476b8 | 729 | &queue_zoned_entry.attr, |
965b652e | 730 | &queue_nr_zones_entry.attr, |
ac9fafa1 | 731 | &queue_nomerges_entry.attr, |
c7c22e4d | 732 | &queue_rq_affinity_entry.attr, |
bc58ba94 | 733 | &queue_iostats_entry.attr, |
e2e1a148 | 734 | &queue_random_entry.attr, |
05229bee | 735 | &queue_poll_entry.attr, |
93e9d8e8 | 736 | &queue_wc_entry.attr, |
6fcefbe5 | 737 | &queue_fua_entry.attr, |
ea6ca600 | 738 | &queue_dax_entry.attr, |
87760e5e | 739 | &queue_wb_lat_entry.attr, |
06426adf | 740 | &queue_poll_delay_entry.attr, |
297e3d85 SL |
741 | #ifdef CONFIG_BLK_DEV_THROTTLING_LOW |
742 | &throtl_sample_time_entry.attr, | |
743 | #endif | |
8324aa91 JA |
744 | NULL, |
745 | }; | |
746 | ||
747 | #define to_queue(atr) container_of((atr), struct queue_sysfs_entry, attr) | |
748 | ||
749 | static ssize_t | |
750 | queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page) | |
751 | { | |
752 | struct queue_sysfs_entry *entry = to_queue(attr); | |
753 | struct request_queue *q = | |
754 | container_of(kobj, struct request_queue, kobj); | |
755 | ssize_t res; | |
756 | ||
757 | if (!entry->show) | |
758 | return -EIO; | |
759 | mutex_lock(&q->sysfs_lock); | |
3f3299d5 | 760 | if (blk_queue_dying(q)) { |
8324aa91 JA |
761 | mutex_unlock(&q->sysfs_lock); |
762 | return -ENOENT; | |
763 | } | |
764 | res = entry->show(q, page); | |
765 | mutex_unlock(&q->sysfs_lock); | |
766 | return res; | |
767 | } | |
768 | ||
769 | static ssize_t | |
770 | queue_attr_store(struct kobject *kobj, struct attribute *attr, | |
771 | const char *page, size_t length) | |
772 | { | |
773 | struct queue_sysfs_entry *entry = to_queue(attr); | |
6728cb0e | 774 | struct request_queue *q; |
8324aa91 JA |
775 | ssize_t res; |
776 | ||
777 | if (!entry->store) | |
778 | return -EIO; | |
6728cb0e JA |
779 | |
780 | q = container_of(kobj, struct request_queue, kobj); | |
8324aa91 | 781 | mutex_lock(&q->sysfs_lock); |
3f3299d5 | 782 | if (blk_queue_dying(q)) { |
8324aa91 JA |
783 | mutex_unlock(&q->sysfs_lock); |
784 | return -ENOENT; | |
785 | } | |
786 | res = entry->store(q, page, length); | |
787 | mutex_unlock(&q->sysfs_lock); | |
788 | return res; | |
789 | } | |
790 | ||
548bc8e1 TH |
791 | static void blk_free_queue_rcu(struct rcu_head *rcu_head) |
792 | { | |
793 | struct request_queue *q = container_of(rcu_head, struct request_queue, | |
794 | rcu_head); | |
795 | kmem_cache_free(blk_requestq_cachep, q); | |
796 | } | |
797 | ||
8324aa91 | 798 | /** |
dc9edc44 BVA |
799 | * __blk_release_queue - release a request queue when it is no longer needed |
800 | * @work: pointer to the release_work member of the request queue to be released | |
8324aa91 JA |
801 | * |
802 | * Description: | |
dc9edc44 BVA |
803 | * blk_release_queue is the counterpart of blk_init_queue(). It should be |
804 | * called when a request queue is being released; typically when a block | |
805 | * device is being de-registered. Its primary task it to free the queue | |
806 | * itself. | |
8324aa91 | 807 | * |
dc9edc44 | 808 | * Notes: |
45a9c9d9 BVA |
809 | * The low level driver must have finished any outstanding requests first |
810 | * via blk_cleanup_queue(). | |
dc9edc44 BVA |
811 | * |
812 | * Although blk_release_queue() may be called with preemption disabled, | |
813 | * __blk_release_queue() may sleep. | |
814 | */ | |
815 | static void __blk_release_queue(struct work_struct *work) | |
8324aa91 | 816 | { |
dc9edc44 | 817 | struct request_queue *q = container_of(work, typeof(*q), release_work); |
8324aa91 | 818 | |
34dbad5d OS |
819 | if (test_bit(QUEUE_FLAG_POLL_STATS, &q->queue_flags)) |
820 | blk_stat_remove_callback(q, q->poll_cb); | |
821 | blk_stat_free_callback(q->poll_cb); | |
777eb1bf | 822 | |
24ecc358 BVA |
823 | if (!blk_queue_dead(q)) { |
824 | /* | |
825 | * Last reference was dropped without having called | |
826 | * blk_cleanup_queue(). | |
827 | */ | |
828 | WARN_ONCE(blk_queue_init_done(q), | |
829 | "request queue %p has been registered but blk_cleanup_queue() has not been called for that queue\n", | |
830 | q); | |
831 | blk_exit_queue(q); | |
832 | } | |
833 | ||
b86d865c | 834 | WARN(blk_queue_root_blkg(q), |
24ecc358 BVA |
835 | "request queue %p is being released but it has not yet been removed from the blkcg controller\n", |
836 | q); | |
837 | ||
34dbad5d OS |
838 | blk_free_queue_stats(q->stats); |
839 | ||
bf505456 DLM |
840 | blk_queue_free_zone_bitmaps(q); |
841 | ||
a1ce35fa | 842 | if (q->mq_ops) |
e09aae7e | 843 | blk_mq_release(q); |
18741986 | 844 | |
8324aa91 JA |
845 | blk_trace_shutdown(q); |
846 | ||
62ebce16 OS |
847 | if (q->mq_ops) |
848 | blk_mq_debugfs_unregister(q); | |
849 | ||
338aa96d | 850 | bioset_exit(&q->bio_split); |
54efd50b | 851 | |
a73f730d | 852 | ida_simple_remove(&blk_queue_ida, q->id); |
548bc8e1 | 853 | call_rcu(&q->rcu_head, blk_free_queue_rcu); |
8324aa91 JA |
854 | } |
855 | ||
dc9edc44 BVA |
856 | static void blk_release_queue(struct kobject *kobj) |
857 | { | |
858 | struct request_queue *q = | |
859 | container_of(kobj, struct request_queue, kobj); | |
860 | ||
861 | INIT_WORK(&q->release_work, __blk_release_queue); | |
862 | schedule_work(&q->release_work); | |
863 | } | |
864 | ||
52cf25d0 | 865 | static const struct sysfs_ops queue_sysfs_ops = { |
8324aa91 JA |
866 | .show = queue_attr_show, |
867 | .store = queue_attr_store, | |
868 | }; | |
869 | ||
870 | struct kobj_type blk_queue_ktype = { | |
871 | .sysfs_ops = &queue_sysfs_ops, | |
872 | .default_attrs = default_attrs, | |
873 | .release = blk_release_queue, | |
874 | }; | |
875 | ||
2c2086af BVA |
876 | /** |
877 | * blk_register_queue - register a block layer queue with sysfs | |
878 | * @disk: Disk of which the request queue should be registered with sysfs. | |
879 | */ | |
8324aa91 JA |
880 | int blk_register_queue(struct gendisk *disk) |
881 | { | |
882 | int ret; | |
1d54ad6d | 883 | struct device *dev = disk_to_dev(disk); |
8324aa91 JA |
884 | struct request_queue *q = disk->queue; |
885 | ||
fb199746 | 886 | if (WARN_ON(!q)) |
8324aa91 JA |
887 | return -ENXIO; |
888 | ||
334335d2 OS |
889 | WARN_ONCE(test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags), |
890 | "%s is registering an already registered queue\n", | |
891 | kobject_name(&dev->kobj)); | |
892 | queue_flag_set_unlocked(QUEUE_FLAG_REGISTERED, q); | |
893 | ||
749fefe6 | 894 | /* |
17497acb TH |
895 | * SCSI probing may synchronously create and destroy a lot of |
896 | * request_queues for non-existent devices. Shutting down a fully | |
897 | * functional queue takes measureable wallclock time as RCU grace | |
898 | * periods are involved. To avoid excessive latency in these | |
899 | * cases, a request_queue starts out in a degraded mode which is | |
900 | * faster to shut down and is made fully functional here as | |
901 | * request_queues for non-existent devices never get registered. | |
749fefe6 | 902 | */ |
df35c7c9 AS |
903 | if (!blk_queue_init_done(q)) { |
904 | queue_flag_set_unlocked(QUEUE_FLAG_INIT_DONE, q); | |
3ef28e83 | 905 | percpu_ref_switch_to_percpu(&q->q_usage_counter); |
df35c7c9 | 906 | } |
749fefe6 | 907 | |
1d54ad6d LZ |
908 | ret = blk_trace_init_sysfs(dev); |
909 | if (ret) | |
910 | return ret; | |
911 | ||
b410aff2 TE |
912 | /* Prevent changes through sysfs until registration is completed. */ |
913 | mutex_lock(&q->sysfs_lock); | |
914 | ||
c9059598 | 915 | ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue"); |
ed5302d3 LY |
916 | if (ret < 0) { |
917 | blk_trace_remove_sysfs(dev); | |
b410aff2 | 918 | goto unlock; |
ed5302d3 | 919 | } |
8324aa91 | 920 | |
a8ecdd71 | 921 | if (q->mq_ops) { |
2d0364c8 | 922 | __blk_mq_register_dev(dev, q); |
a8ecdd71 BVA |
923 | blk_mq_debugfs_register(q); |
924 | } | |
9c1051aa | 925 | |
8324aa91 JA |
926 | kobject_uevent(&q->kobj, KOBJ_ADD); |
927 | ||
8330cdb0 | 928 | wbt_enable_default(q); |
87760e5e | 929 | |
d61fcfa4 SL |
930 | blk_throtl_register_queue(q); |
931 | ||
a1ce35fa | 932 | if ((q->mq_ops && q->elevator)) { |
80c6b157 OS |
933 | ret = elv_register_queue(q); |
934 | if (ret) { | |
2c2086af | 935 | mutex_unlock(&q->sysfs_lock); |
80c6b157 OS |
936 | kobject_uevent(&q->kobj, KOBJ_REMOVE); |
937 | kobject_del(&q->kobj); | |
938 | blk_trace_remove_sysfs(dev); | |
939 | kobject_put(&dev->kobj); | |
2c2086af | 940 | return ret; |
80c6b157 | 941 | } |
8324aa91 | 942 | } |
b410aff2 TE |
943 | ret = 0; |
944 | unlock: | |
945 | mutex_unlock(&q->sysfs_lock); | |
946 | return ret; | |
8324aa91 | 947 | } |
fa70d2e2 | 948 | EXPORT_SYMBOL_GPL(blk_register_queue); |
8324aa91 | 949 | |
2c2086af BVA |
950 | /** |
951 | * blk_unregister_queue - counterpart of blk_register_queue() | |
952 | * @disk: Disk of which the request queue should be unregistered from sysfs. | |
953 | * | |
954 | * Note: the caller is responsible for guaranteeing that this function is called | |
955 | * after blk_register_queue() has finished. | |
956 | */ | |
8324aa91 JA |
957 | void blk_unregister_queue(struct gendisk *disk) |
958 | { | |
959 | struct request_queue *q = disk->queue; | |
960 | ||
fb199746 AM |
961 | if (WARN_ON(!q)) |
962 | return; | |
963 | ||
fa70d2e2 MS |
964 | /* Return early if disk->queue was never registered. */ |
965 | if (!test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags)) | |
966 | return; | |
967 | ||
667257e8 | 968 | /* |
2c2086af BVA |
969 | * Since sysfs_remove_dir() prevents adding new directory entries |
970 | * before removal of existing entries starts, protect against | |
971 | * concurrent elv_iosched_store() calls. | |
667257e8 | 972 | */ |
e9a823fb | 973 | mutex_lock(&q->sysfs_lock); |
334335d2 | 974 | |
8814ce8a | 975 | blk_queue_flag_clear(QUEUE_FLAG_REGISTERED, q); |
02ba8893 | 976 | |
2c2086af BVA |
977 | /* |
978 | * Remove the sysfs attributes before unregistering the queue data | |
979 | * structures that can be modified through sysfs. | |
980 | */ | |
320ae51f | 981 | if (q->mq_ops) |
b21d5b30 | 982 | blk_mq_unregister_dev(disk_to_dev(disk), q); |
2c2086af | 983 | mutex_unlock(&q->sysfs_lock); |
8324aa91 | 984 | |
48c0d4d4 ZK |
985 | kobject_uevent(&q->kobj, KOBJ_REMOVE); |
986 | kobject_del(&q->kobj); | |
987 | blk_trace_remove_sysfs(disk_to_dev(disk)); | |
667257e8 | 988 | |
2c2086af | 989 | mutex_lock(&q->sysfs_lock); |
a1ce35fa | 990 | if (q->mq_ops && q->elevator) |
2c2086af | 991 | elv_unregister_queue(q); |
667257e8 | 992 | mutex_unlock(&q->sysfs_lock); |
2c2086af BVA |
993 | |
994 | kobject_put(&disk_to_dev(disk)->kobj); | |
8324aa91 | 995 | } |