]>
Commit | Line | Data |
---|---|---|
07e4fead OS |
1 | /* |
2 | * Copyright (C) 2017 Facebook | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public | |
6 | * License v2 as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
11 | * General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | |
15 | */ | |
16 | ||
17 | #include <linux/kernel.h> | |
18 | #include <linux/blkdev.h> | |
19 | #include <linux/debugfs.h> | |
20 | ||
21 | #include <linux/blk-mq.h> | |
18fbda91 | 22 | #include "blk.h" |
07e4fead | 23 | #include "blk-mq.h" |
d173a251 | 24 | #include "blk-mq-debugfs.h" |
d96b37c0 | 25 | #include "blk-mq-tag.h" |
07e4fead | 26 | |
91d68905 BVA |
27 | static int blk_flags_show(struct seq_file *m, const unsigned long flags, |
28 | const char *const *flag_name, int flag_name_count) | |
29 | { | |
30 | bool sep = false; | |
31 | int i; | |
32 | ||
33 | for (i = 0; i < sizeof(flags) * BITS_PER_BYTE; i++) { | |
34 | if (!(flags & BIT(i))) | |
35 | continue; | |
36 | if (sep) | |
bec03d6b | 37 | seq_puts(m, "|"); |
91d68905 BVA |
38 | sep = true; |
39 | if (i < flag_name_count && flag_name[i]) | |
40 | seq_puts(m, flag_name[i]); | |
41 | else | |
42 | seq_printf(m, "%d", i); | |
43 | } | |
91d68905 BVA |
44 | return 0; |
45 | } | |
46 | ||
1a435111 | 47 | #define QUEUE_FLAG_NAME(name) [QUEUE_FLAG_##name] = #name |
91d68905 | 48 | static const char *const blk_queue_flag_name[] = { |
1a435111 OS |
49 | QUEUE_FLAG_NAME(QUEUED), |
50 | QUEUE_FLAG_NAME(STOPPED), | |
51 | QUEUE_FLAG_NAME(SYNCFULL), | |
52 | QUEUE_FLAG_NAME(ASYNCFULL), | |
53 | QUEUE_FLAG_NAME(DYING), | |
54 | QUEUE_FLAG_NAME(BYPASS), | |
55 | QUEUE_FLAG_NAME(BIDI), | |
56 | QUEUE_FLAG_NAME(NOMERGES), | |
57 | QUEUE_FLAG_NAME(SAME_COMP), | |
58 | QUEUE_FLAG_NAME(FAIL_IO), | |
59 | QUEUE_FLAG_NAME(STACKABLE), | |
60 | QUEUE_FLAG_NAME(NONROT), | |
61 | QUEUE_FLAG_NAME(IO_STAT), | |
62 | QUEUE_FLAG_NAME(DISCARD), | |
63 | QUEUE_FLAG_NAME(NOXMERGES), | |
64 | QUEUE_FLAG_NAME(ADD_RANDOM), | |
65 | QUEUE_FLAG_NAME(SECERASE), | |
66 | QUEUE_FLAG_NAME(SAME_FORCE), | |
67 | QUEUE_FLAG_NAME(DEAD), | |
68 | QUEUE_FLAG_NAME(INIT_DONE), | |
69 | QUEUE_FLAG_NAME(NO_SG_MERGE), | |
70 | QUEUE_FLAG_NAME(POLL), | |
71 | QUEUE_FLAG_NAME(WC), | |
72 | QUEUE_FLAG_NAME(FUA), | |
73 | QUEUE_FLAG_NAME(FLUSH_NQ), | |
74 | QUEUE_FLAG_NAME(DAX), | |
75 | QUEUE_FLAG_NAME(STATS), | |
76 | QUEUE_FLAG_NAME(POLL_STATS), | |
77 | QUEUE_FLAG_NAME(REGISTERED), | |
22d53821 BVA |
78 | QUEUE_FLAG_NAME(SCSI_PASSTHROUGH), |
79 | QUEUE_FLAG_NAME(QUIESCED), | |
91d68905 | 80 | }; |
1a435111 | 81 | #undef QUEUE_FLAG_NAME |
91d68905 | 82 | |
f57de23a | 83 | static int queue_state_show(void *data, struct seq_file *m) |
91d68905 | 84 | { |
f57de23a | 85 | struct request_queue *q = data; |
91d68905 BVA |
86 | |
87 | blk_flags_show(m, q->queue_flags, blk_queue_flag_name, | |
88 | ARRAY_SIZE(blk_queue_flag_name)); | |
fd07dc81 | 89 | seq_puts(m, "\n"); |
91d68905 BVA |
90 | return 0; |
91 | } | |
92 | ||
f57de23a OS |
93 | static ssize_t queue_state_write(void *data, const char __user *buf, |
94 | size_t count, loff_t *ppos) | |
91d68905 | 95 | { |
f57de23a | 96 | struct request_queue *q = data; |
71b90511 | 97 | char opbuf[16] = { }, *op; |
91d68905 | 98 | |
18d4d7d0 BVA |
99 | /* |
100 | * The "state" attribute is removed after blk_cleanup_queue() has called | |
101 | * blk_mq_free_queue(). Return if QUEUE_FLAG_DEAD has been set to avoid | |
102 | * triggering a use-after-free. | |
103 | */ | |
104 | if (blk_queue_dead(q)) | |
105 | return -ENOENT; | |
106 | ||
71b90511 | 107 | if (count >= sizeof(opbuf)) { |
c7e4145a OS |
108 | pr_err("%s: operation too long\n", __func__); |
109 | goto inval; | |
110 | } | |
111 | ||
71b90511 | 112 | if (copy_from_user(opbuf, buf, count)) |
91d68905 | 113 | return -EFAULT; |
71b90511 | 114 | op = strstrip(opbuf); |
91d68905 BVA |
115 | if (strcmp(op, "run") == 0) { |
116 | blk_mq_run_hw_queues(q, true); | |
117 | } else if (strcmp(op, "start") == 0) { | |
118 | blk_mq_start_stopped_hw_queues(q, true); | |
edea55ab BVA |
119 | } else if (strcmp(op, "kick") == 0) { |
120 | blk_mq_kick_requeue_list(q); | |
91d68905 | 121 | } else { |
c7e4145a OS |
122 | pr_err("%s: unsupported operation '%s'\n", __func__, op); |
123 | inval: | |
edea55ab | 124 | pr_err("%s: use 'run', 'start' or 'kick'\n", __func__); |
91d68905 BVA |
125 | return -EINVAL; |
126 | } | |
c7e4145a | 127 | return count; |
91d68905 BVA |
128 | } |
129 | ||
34dbad5d OS |
130 | static void print_stat(struct seq_file *m, struct blk_rq_stat *stat) |
131 | { | |
132 | if (stat->nr_samples) { | |
133 | seq_printf(m, "samples=%d, mean=%lld, min=%llu, max=%llu", | |
134 | stat->nr_samples, stat->mean, stat->min, stat->max); | |
135 | } else { | |
136 | seq_puts(m, "samples=0"); | |
137 | } | |
138 | } | |
139 | ||
f793dfd3 JA |
140 | static int queue_write_hint_show(void *data, struct seq_file *m) |
141 | { | |
142 | struct request_queue *q = data; | |
143 | int i; | |
144 | ||
145 | for (i = 0; i < BLK_MAX_WRITE_HINTS; i++) | |
146 | seq_printf(m, "hint%d: %llu\n", i, q->write_hints[i]); | |
147 | ||
148 | return 0; | |
149 | } | |
150 | ||
151 | static ssize_t queue_write_hint_store(void *data, const char __user *buf, | |
152 | size_t count, loff_t *ppos) | |
153 | { | |
154 | struct request_queue *q = data; | |
155 | int i; | |
156 | ||
157 | for (i = 0; i < BLK_MAX_WRITE_HINTS; i++) | |
158 | q->write_hints[i] = 0; | |
159 | ||
160 | return count; | |
161 | } | |
162 | ||
f57de23a | 163 | static int queue_poll_stat_show(void *data, struct seq_file *m) |
34dbad5d | 164 | { |
f57de23a | 165 | struct request_queue *q = data; |
0206319f | 166 | int bucket; |
34dbad5d | 167 | |
0206319f SB |
168 | for (bucket = 0; bucket < BLK_MQ_POLL_STATS_BKTS/2; bucket++) { |
169 | seq_printf(m, "read (%d Bytes): ", 1 << (9+bucket)); | |
170 | print_stat(m, &q->poll_stat[2*bucket]); | |
171 | seq_puts(m, "\n"); | |
34dbad5d | 172 | |
0206319f SB |
173 | seq_printf(m, "write (%d Bytes): ", 1 << (9+bucket)); |
174 | print_stat(m, &q->poll_stat[2*bucket+1]); | |
175 | seq_puts(m, "\n"); | |
176 | } | |
34dbad5d OS |
177 | return 0; |
178 | } | |
179 | ||
1a435111 | 180 | #define HCTX_STATE_NAME(name) [BLK_MQ_S_##name] = #name |
f5c0b091 | 181 | static const char *const hctx_state_name[] = { |
1a435111 OS |
182 | HCTX_STATE_NAME(STOPPED), |
183 | HCTX_STATE_NAME(TAG_ACTIVE), | |
184 | HCTX_STATE_NAME(SCHED_RESTART), | |
185 | HCTX_STATE_NAME(TAG_WAITING), | |
186 | HCTX_STATE_NAME(START_ON_RUN), | |
f5c0b091 | 187 | }; |
1a435111 OS |
188 | #undef HCTX_STATE_NAME |
189 | ||
f57de23a | 190 | static int hctx_state_show(void *data, struct seq_file *m) |
9abb2ad2 | 191 | { |
f57de23a | 192 | struct blk_mq_hw_ctx *hctx = data; |
9abb2ad2 | 193 | |
f5c0b091 BVA |
194 | blk_flags_show(m, hctx->state, hctx_state_name, |
195 | ARRAY_SIZE(hctx_state_name)); | |
fd07dc81 | 196 | seq_puts(m, "\n"); |
9abb2ad2 OS |
197 | return 0; |
198 | } | |
199 | ||
1a435111 | 200 | #define BLK_TAG_ALLOC_NAME(name) [BLK_TAG_ALLOC_##name] = #name |
f5c0b091 | 201 | static const char *const alloc_policy_name[] = { |
1a435111 OS |
202 | BLK_TAG_ALLOC_NAME(FIFO), |
203 | BLK_TAG_ALLOC_NAME(RR), | |
f5c0b091 | 204 | }; |
1a435111 | 205 | #undef BLK_TAG_ALLOC_NAME |
f5c0b091 | 206 | |
1a435111 | 207 | #define HCTX_FLAG_NAME(name) [ilog2(BLK_MQ_F_##name)] = #name |
f5c0b091 | 208 | static const char *const hctx_flag_name[] = { |
1a435111 OS |
209 | HCTX_FLAG_NAME(SHOULD_MERGE), |
210 | HCTX_FLAG_NAME(TAG_SHARED), | |
211 | HCTX_FLAG_NAME(SG_MERGE), | |
212 | HCTX_FLAG_NAME(BLOCKING), | |
213 | HCTX_FLAG_NAME(NO_SCHED), | |
f5c0b091 | 214 | }; |
1a435111 | 215 | #undef HCTX_FLAG_NAME |
f5c0b091 | 216 | |
f57de23a | 217 | static int hctx_flags_show(void *data, struct seq_file *m) |
9abb2ad2 | 218 | { |
f57de23a | 219 | struct blk_mq_hw_ctx *hctx = data; |
f5c0b091 | 220 | const int alloc_policy = BLK_MQ_FLAG_TO_ALLOC_POLICY(hctx->flags); |
9abb2ad2 | 221 | |
f5c0b091 BVA |
222 | seq_puts(m, "alloc_policy="); |
223 | if (alloc_policy < ARRAY_SIZE(alloc_policy_name) && | |
224 | alloc_policy_name[alloc_policy]) | |
225 | seq_puts(m, alloc_policy_name[alloc_policy]); | |
226 | else | |
227 | seq_printf(m, "%d", alloc_policy); | |
228 | seq_puts(m, " "); | |
229 | blk_flags_show(m, | |
230 | hctx->flags ^ BLK_ALLOC_POLICY_TO_MQ_FLAG(alloc_policy), | |
231 | hctx_flag_name, ARRAY_SIZE(hctx_flag_name)); | |
fd07dc81 | 232 | seq_puts(m, "\n"); |
9abb2ad2 OS |
233 | return 0; |
234 | } | |
235 | ||
1a435111 | 236 | #define REQ_OP_NAME(name) [REQ_OP_##name] = #name |
8658dca8 | 237 | static const char *const op_name[] = { |
1a435111 OS |
238 | REQ_OP_NAME(READ), |
239 | REQ_OP_NAME(WRITE), | |
240 | REQ_OP_NAME(FLUSH), | |
241 | REQ_OP_NAME(DISCARD), | |
242 | REQ_OP_NAME(ZONE_REPORT), | |
243 | REQ_OP_NAME(SECURE_ERASE), | |
244 | REQ_OP_NAME(ZONE_RESET), | |
245 | REQ_OP_NAME(WRITE_SAME), | |
246 | REQ_OP_NAME(WRITE_ZEROES), | |
247 | REQ_OP_NAME(SCSI_IN), | |
248 | REQ_OP_NAME(SCSI_OUT), | |
249 | REQ_OP_NAME(DRV_IN), | |
250 | REQ_OP_NAME(DRV_OUT), | |
8658dca8 | 251 | }; |
1a435111 | 252 | #undef REQ_OP_NAME |
8658dca8 | 253 | |
1a435111 | 254 | #define CMD_FLAG_NAME(name) [__REQ_##name] = #name |
8658dca8 | 255 | static const char *const cmd_flag_name[] = { |
1a435111 OS |
256 | CMD_FLAG_NAME(FAILFAST_DEV), |
257 | CMD_FLAG_NAME(FAILFAST_TRANSPORT), | |
258 | CMD_FLAG_NAME(FAILFAST_DRIVER), | |
259 | CMD_FLAG_NAME(SYNC), | |
260 | CMD_FLAG_NAME(META), | |
261 | CMD_FLAG_NAME(PRIO), | |
262 | CMD_FLAG_NAME(NOMERGE), | |
263 | CMD_FLAG_NAME(IDLE), | |
264 | CMD_FLAG_NAME(INTEGRITY), | |
265 | CMD_FLAG_NAME(FUA), | |
266 | CMD_FLAG_NAME(PREFLUSH), | |
267 | CMD_FLAG_NAME(RAHEAD), | |
268 | CMD_FLAG_NAME(BACKGROUND), | |
269 | CMD_FLAG_NAME(NOUNMAP), | |
22d53821 | 270 | CMD_FLAG_NAME(NOWAIT), |
8658dca8 | 271 | }; |
1a435111 | 272 | #undef CMD_FLAG_NAME |
8658dca8 | 273 | |
1a435111 | 274 | #define RQF_NAME(name) [ilog2((__force u32)RQF_##name)] = #name |
8658dca8 | 275 | static const char *const rqf_name[] = { |
1a435111 OS |
276 | RQF_NAME(SORTED), |
277 | RQF_NAME(STARTED), | |
278 | RQF_NAME(QUEUED), | |
279 | RQF_NAME(SOFTBARRIER), | |
280 | RQF_NAME(FLUSH_SEQ), | |
281 | RQF_NAME(MIXED_MERGE), | |
282 | RQF_NAME(MQ_INFLIGHT), | |
283 | RQF_NAME(DONTPREP), | |
284 | RQF_NAME(PREEMPT), | |
285 | RQF_NAME(COPY_USER), | |
286 | RQF_NAME(FAILED), | |
287 | RQF_NAME(QUIET), | |
288 | RQF_NAME(ELVPRIV), | |
289 | RQF_NAME(IO_STAT), | |
290 | RQF_NAME(ALLOCED), | |
291 | RQF_NAME(PM), | |
292 | RQF_NAME(HASHED), | |
293 | RQF_NAME(STATS), | |
294 | RQF_NAME(SPECIAL_PAYLOAD), | |
8658dca8 | 295 | }; |
1a435111 | 296 | #undef RQF_NAME |
8658dca8 | 297 | |
c0cb1c6d BVA |
298 | #define RQAF_NAME(name) [REQ_ATOM_##name] = #name |
299 | static const char *const rqaf_name[] = { | |
300 | RQAF_NAME(COMPLETE), | |
301 | RQAF_NAME(STARTED), | |
302 | RQAF_NAME(POLL_SLEPT), | |
303 | }; | |
304 | #undef RQAF_NAME | |
305 | ||
daaadb3e | 306 | int __blk_mq_debugfs_rq_show(struct seq_file *m, struct request *rq) |
950cd7e9 | 307 | { |
2836ee4b | 308 | const struct blk_mq_ops *const mq_ops = rq->q->mq_ops; |
8658dca8 | 309 | const unsigned int op = rq->cmd_flags & REQ_OP_MASK; |
950cd7e9 | 310 | |
8658dca8 BVA |
311 | seq_printf(m, "%p {.op=", rq); |
312 | if (op < ARRAY_SIZE(op_name) && op_name[op]) | |
313 | seq_printf(m, "%s", op_name[op]); | |
314 | else | |
315 | seq_printf(m, "%d", op); | |
316 | seq_puts(m, ", .cmd_flags="); | |
317 | blk_flags_show(m, rq->cmd_flags & ~REQ_OP_MASK, cmd_flag_name, | |
318 | ARRAY_SIZE(cmd_flag_name)); | |
319 | seq_puts(m, ", .rq_flags="); | |
320 | blk_flags_show(m, (__force unsigned int)rq->rq_flags, rqf_name, | |
321 | ARRAY_SIZE(rqf_name)); | |
c0cb1c6d BVA |
322 | seq_puts(m, ", .atomic_flags="); |
323 | blk_flags_show(m, rq->atomic_flags, rqaf_name, ARRAY_SIZE(rqaf_name)); | |
2836ee4b | 324 | seq_printf(m, ", .tag=%d, .internal_tag=%d", rq->tag, |
8658dca8 | 325 | rq->internal_tag); |
2836ee4b BVA |
326 | if (mq_ops->show_rq) |
327 | mq_ops->show_rq(m, rq); | |
328 | seq_puts(m, "}\n"); | |
950cd7e9 OS |
329 | return 0; |
330 | } | |
daaadb3e OS |
331 | EXPORT_SYMBOL_GPL(__blk_mq_debugfs_rq_show); |
332 | ||
333 | int blk_mq_debugfs_rq_show(struct seq_file *m, void *v) | |
334 | { | |
335 | return __blk_mq_debugfs_rq_show(m, list_entry_rq(v)); | |
336 | } | |
16b738f6 | 337 | EXPORT_SYMBOL_GPL(blk_mq_debugfs_rq_show); |
950cd7e9 | 338 | |
8ef1a191 BVA |
339 | static void *queue_requeue_list_start(struct seq_file *m, loff_t *pos) |
340 | __acquires(&q->requeue_lock) | |
341 | { | |
342 | struct request_queue *q = m->private; | |
343 | ||
344 | spin_lock_irq(&q->requeue_lock); | |
345 | return seq_list_start(&q->requeue_list, *pos); | |
346 | } | |
347 | ||
348 | static void *queue_requeue_list_next(struct seq_file *m, void *v, loff_t *pos) | |
349 | { | |
350 | struct request_queue *q = m->private; | |
351 | ||
352 | return seq_list_next(v, &q->requeue_list, pos); | |
353 | } | |
354 | ||
355 | static void queue_requeue_list_stop(struct seq_file *m, void *v) | |
356 | __releases(&q->requeue_lock) | |
357 | { | |
358 | struct request_queue *q = m->private; | |
359 | ||
360 | spin_unlock_irq(&q->requeue_lock); | |
361 | } | |
362 | ||
363 | static const struct seq_operations queue_requeue_list_seq_ops = { | |
364 | .start = queue_requeue_list_start, | |
365 | .next = queue_requeue_list_next, | |
366 | .stop = queue_requeue_list_stop, | |
367 | .show = blk_mq_debugfs_rq_show, | |
368 | }; | |
369 | ||
950cd7e9 | 370 | static void *hctx_dispatch_start(struct seq_file *m, loff_t *pos) |
f3bcb0e6 | 371 | __acquires(&hctx->lock) |
950cd7e9 OS |
372 | { |
373 | struct blk_mq_hw_ctx *hctx = m->private; | |
374 | ||
375 | spin_lock(&hctx->lock); | |
376 | return seq_list_start(&hctx->dispatch, *pos); | |
377 | } | |
378 | ||
379 | static void *hctx_dispatch_next(struct seq_file *m, void *v, loff_t *pos) | |
380 | { | |
381 | struct blk_mq_hw_ctx *hctx = m->private; | |
382 | ||
383 | return seq_list_next(v, &hctx->dispatch, pos); | |
384 | } | |
385 | ||
386 | static void hctx_dispatch_stop(struct seq_file *m, void *v) | |
f3bcb0e6 | 387 | __releases(&hctx->lock) |
950cd7e9 OS |
388 | { |
389 | struct blk_mq_hw_ctx *hctx = m->private; | |
390 | ||
391 | spin_unlock(&hctx->lock); | |
392 | } | |
393 | ||
394 | static const struct seq_operations hctx_dispatch_seq_ops = { | |
395 | .start = hctx_dispatch_start, | |
396 | .next = hctx_dispatch_next, | |
397 | .stop = hctx_dispatch_stop, | |
398 | .show = blk_mq_debugfs_rq_show, | |
399 | }; | |
400 | ||
2720bab5 BVA |
401 | struct show_busy_params { |
402 | struct seq_file *m; | |
403 | struct blk_mq_hw_ctx *hctx; | |
404 | }; | |
405 | ||
406 | /* | |
407 | * Note: the state of a request may change while this function is in progress, | |
408 | * e.g. due to a concurrent blk_mq_finish_request() call. | |
409 | */ | |
410 | static void hctx_show_busy_rq(struct request *rq, void *data, bool reserved) | |
411 | { | |
412 | const struct show_busy_params *params = data; | |
413 | ||
414 | if (blk_mq_map_queue(rq->q, rq->mq_ctx->cpu) == params->hctx && | |
415 | test_bit(REQ_ATOM_STARTED, &rq->atomic_flags)) | |
416 | __blk_mq_debugfs_rq_show(params->m, | |
417 | list_entry_rq(&rq->queuelist)); | |
418 | } | |
419 | ||
420 | static int hctx_busy_show(void *data, struct seq_file *m) | |
421 | { | |
422 | struct blk_mq_hw_ctx *hctx = data; | |
423 | struct show_busy_params params = { .m = m, .hctx = hctx }; | |
424 | ||
425 | blk_mq_tagset_busy_iter(hctx->queue->tag_set, hctx_show_busy_rq, | |
426 | ¶ms); | |
427 | ||
428 | return 0; | |
429 | } | |
430 | ||
f57de23a | 431 | static int hctx_ctx_map_show(void *data, struct seq_file *m) |
0bfa5288 | 432 | { |
f57de23a | 433 | struct blk_mq_hw_ctx *hctx = data; |
0bfa5288 OS |
434 | |
435 | sbitmap_bitmap_show(&hctx->ctx_map, m); | |
436 | return 0; | |
437 | } | |
438 | ||
d96b37c0 OS |
439 | static void blk_mq_debugfs_tags_show(struct seq_file *m, |
440 | struct blk_mq_tags *tags) | |
441 | { | |
442 | seq_printf(m, "nr_tags=%u\n", tags->nr_tags); | |
443 | seq_printf(m, "nr_reserved_tags=%u\n", tags->nr_reserved_tags); | |
444 | seq_printf(m, "active_queues=%d\n", | |
445 | atomic_read(&tags->active_queues)); | |
446 | ||
447 | seq_puts(m, "\nbitmap_tags:\n"); | |
448 | sbitmap_queue_show(&tags->bitmap_tags, m); | |
449 | ||
450 | if (tags->nr_reserved_tags) { | |
451 | seq_puts(m, "\nbreserved_tags:\n"); | |
452 | sbitmap_queue_show(&tags->breserved_tags, m); | |
453 | } | |
454 | } | |
455 | ||
f57de23a | 456 | static int hctx_tags_show(void *data, struct seq_file *m) |
d96b37c0 | 457 | { |
f57de23a | 458 | struct blk_mq_hw_ctx *hctx = data; |
d96b37c0 | 459 | struct request_queue *q = hctx->queue; |
8c0f14ea | 460 | int res; |
d96b37c0 | 461 | |
8c0f14ea BVA |
462 | res = mutex_lock_interruptible(&q->sysfs_lock); |
463 | if (res) | |
464 | goto out; | |
d96b37c0 OS |
465 | if (hctx->tags) |
466 | blk_mq_debugfs_tags_show(m, hctx->tags); | |
467 | mutex_unlock(&q->sysfs_lock); | |
468 | ||
8c0f14ea BVA |
469 | out: |
470 | return res; | |
d96b37c0 OS |
471 | } |
472 | ||
f57de23a | 473 | static int hctx_tags_bitmap_show(void *data, struct seq_file *m) |
d7e3621a | 474 | { |
f57de23a | 475 | struct blk_mq_hw_ctx *hctx = data; |
d7e3621a | 476 | struct request_queue *q = hctx->queue; |
8c0f14ea | 477 | int res; |
d7e3621a | 478 | |
8c0f14ea BVA |
479 | res = mutex_lock_interruptible(&q->sysfs_lock); |
480 | if (res) | |
481 | goto out; | |
d7e3621a OS |
482 | if (hctx->tags) |
483 | sbitmap_bitmap_show(&hctx->tags->bitmap_tags.sb, m); | |
484 | mutex_unlock(&q->sysfs_lock); | |
8c0f14ea BVA |
485 | |
486 | out: | |
487 | return res; | |
d7e3621a OS |
488 | } |
489 | ||
f57de23a | 490 | static int hctx_sched_tags_show(void *data, struct seq_file *m) |
d96b37c0 | 491 | { |
f57de23a | 492 | struct blk_mq_hw_ctx *hctx = data; |
d96b37c0 | 493 | struct request_queue *q = hctx->queue; |
8c0f14ea | 494 | int res; |
d96b37c0 | 495 | |
8c0f14ea BVA |
496 | res = mutex_lock_interruptible(&q->sysfs_lock); |
497 | if (res) | |
498 | goto out; | |
d96b37c0 OS |
499 | if (hctx->sched_tags) |
500 | blk_mq_debugfs_tags_show(m, hctx->sched_tags); | |
501 | mutex_unlock(&q->sysfs_lock); | |
502 | ||
8c0f14ea BVA |
503 | out: |
504 | return res; | |
d96b37c0 OS |
505 | } |
506 | ||
f57de23a | 507 | static int hctx_sched_tags_bitmap_show(void *data, struct seq_file *m) |
d7e3621a | 508 | { |
f57de23a | 509 | struct blk_mq_hw_ctx *hctx = data; |
d7e3621a | 510 | struct request_queue *q = hctx->queue; |
8c0f14ea | 511 | int res; |
d7e3621a | 512 | |
8c0f14ea BVA |
513 | res = mutex_lock_interruptible(&q->sysfs_lock); |
514 | if (res) | |
515 | goto out; | |
d7e3621a OS |
516 | if (hctx->sched_tags) |
517 | sbitmap_bitmap_show(&hctx->sched_tags->bitmap_tags.sb, m); | |
518 | mutex_unlock(&q->sysfs_lock); | |
8c0f14ea BVA |
519 | |
520 | out: | |
521 | return res; | |
d7e3621a OS |
522 | } |
523 | ||
f57de23a | 524 | static int hctx_io_poll_show(void *data, struct seq_file *m) |
be215473 | 525 | { |
f57de23a | 526 | struct blk_mq_hw_ctx *hctx = data; |
be215473 OS |
527 | |
528 | seq_printf(m, "considered=%lu\n", hctx->poll_considered); | |
529 | seq_printf(m, "invoked=%lu\n", hctx->poll_invoked); | |
530 | seq_printf(m, "success=%lu\n", hctx->poll_success); | |
531 | return 0; | |
532 | } | |
533 | ||
f57de23a | 534 | static ssize_t hctx_io_poll_write(void *data, const char __user *buf, |
be215473 OS |
535 | size_t count, loff_t *ppos) |
536 | { | |
f57de23a | 537 | struct blk_mq_hw_ctx *hctx = data; |
be215473 OS |
538 | |
539 | hctx->poll_considered = hctx->poll_invoked = hctx->poll_success = 0; | |
540 | return count; | |
541 | } | |
542 | ||
f57de23a | 543 | static int hctx_dispatched_show(void *data, struct seq_file *m) |
be215473 | 544 | { |
f57de23a | 545 | struct blk_mq_hw_ctx *hctx = data; |
be215473 OS |
546 | int i; |
547 | ||
548 | seq_printf(m, "%8u\t%lu\n", 0U, hctx->dispatched[0]); | |
549 | ||
550 | for (i = 1; i < BLK_MQ_MAX_DISPATCH_ORDER - 1; i++) { | |
551 | unsigned int d = 1U << (i - 1); | |
552 | ||
553 | seq_printf(m, "%8u\t%lu\n", d, hctx->dispatched[i]); | |
554 | } | |
555 | ||
556 | seq_printf(m, "%8u+\t%lu\n", 1U << (i - 1), hctx->dispatched[i]); | |
557 | return 0; | |
558 | } | |
559 | ||
f57de23a | 560 | static ssize_t hctx_dispatched_write(void *data, const char __user *buf, |
be215473 OS |
561 | size_t count, loff_t *ppos) |
562 | { | |
f57de23a | 563 | struct blk_mq_hw_ctx *hctx = data; |
be215473 OS |
564 | int i; |
565 | ||
566 | for (i = 0; i < BLK_MQ_MAX_DISPATCH_ORDER; i++) | |
567 | hctx->dispatched[i] = 0; | |
568 | return count; | |
569 | } | |
570 | ||
f57de23a | 571 | static int hctx_queued_show(void *data, struct seq_file *m) |
4a46f05e | 572 | { |
f57de23a | 573 | struct blk_mq_hw_ctx *hctx = data; |
4a46f05e OS |
574 | |
575 | seq_printf(m, "%lu\n", hctx->queued); | |
576 | return 0; | |
577 | } | |
578 | ||
f57de23a | 579 | static ssize_t hctx_queued_write(void *data, const char __user *buf, |
4a46f05e OS |
580 | size_t count, loff_t *ppos) |
581 | { | |
f57de23a | 582 | struct blk_mq_hw_ctx *hctx = data; |
4a46f05e OS |
583 | |
584 | hctx->queued = 0; | |
585 | return count; | |
586 | } | |
587 | ||
f57de23a | 588 | static int hctx_run_show(void *data, struct seq_file *m) |
4a46f05e | 589 | { |
f57de23a | 590 | struct blk_mq_hw_ctx *hctx = data; |
4a46f05e OS |
591 | |
592 | seq_printf(m, "%lu\n", hctx->run); | |
593 | return 0; | |
594 | } | |
595 | ||
f57de23a OS |
596 | static ssize_t hctx_run_write(void *data, const char __user *buf, size_t count, |
597 | loff_t *ppos) | |
4a46f05e | 598 | { |
f57de23a | 599 | struct blk_mq_hw_ctx *hctx = data; |
4a46f05e OS |
600 | |
601 | hctx->run = 0; | |
602 | return count; | |
603 | } | |
604 | ||
f57de23a | 605 | static int hctx_active_show(void *data, struct seq_file *m) |
4a46f05e | 606 | { |
f57de23a | 607 | struct blk_mq_hw_ctx *hctx = data; |
4a46f05e OS |
608 | |
609 | seq_printf(m, "%d\n", atomic_read(&hctx->nr_active)); | |
610 | return 0; | |
611 | } | |
612 | ||
950cd7e9 | 613 | static void *ctx_rq_list_start(struct seq_file *m, loff_t *pos) |
f3bcb0e6 | 614 | __acquires(&ctx->lock) |
950cd7e9 OS |
615 | { |
616 | struct blk_mq_ctx *ctx = m->private; | |
617 | ||
618 | spin_lock(&ctx->lock); | |
619 | return seq_list_start(&ctx->rq_list, *pos); | |
620 | } | |
621 | ||
622 | static void *ctx_rq_list_next(struct seq_file *m, void *v, loff_t *pos) | |
623 | { | |
624 | struct blk_mq_ctx *ctx = m->private; | |
625 | ||
626 | return seq_list_next(v, &ctx->rq_list, pos); | |
627 | } | |
628 | ||
629 | static void ctx_rq_list_stop(struct seq_file *m, void *v) | |
f3bcb0e6 | 630 | __releases(&ctx->lock) |
950cd7e9 OS |
631 | { |
632 | struct blk_mq_ctx *ctx = m->private; | |
633 | ||
634 | spin_unlock(&ctx->lock); | |
635 | } | |
636 | ||
637 | static const struct seq_operations ctx_rq_list_seq_ops = { | |
638 | .start = ctx_rq_list_start, | |
639 | .next = ctx_rq_list_next, | |
640 | .stop = ctx_rq_list_stop, | |
641 | .show = blk_mq_debugfs_rq_show, | |
642 | }; | |
f57de23a | 643 | static int ctx_dispatched_show(void *data, struct seq_file *m) |
4a46f05e | 644 | { |
f57de23a | 645 | struct blk_mq_ctx *ctx = data; |
4a46f05e OS |
646 | |
647 | seq_printf(m, "%lu %lu\n", ctx->rq_dispatched[1], ctx->rq_dispatched[0]); | |
648 | return 0; | |
649 | } | |
650 | ||
f57de23a | 651 | static ssize_t ctx_dispatched_write(void *data, const char __user *buf, |
4a46f05e OS |
652 | size_t count, loff_t *ppos) |
653 | { | |
f57de23a | 654 | struct blk_mq_ctx *ctx = data; |
4a46f05e OS |
655 | |
656 | ctx->rq_dispatched[0] = ctx->rq_dispatched[1] = 0; | |
657 | return count; | |
658 | } | |
659 | ||
f57de23a | 660 | static int ctx_merged_show(void *data, struct seq_file *m) |
4a46f05e | 661 | { |
f57de23a | 662 | struct blk_mq_ctx *ctx = data; |
4a46f05e OS |
663 | |
664 | seq_printf(m, "%lu\n", ctx->rq_merged); | |
665 | return 0; | |
666 | } | |
667 | ||
f57de23a OS |
668 | static ssize_t ctx_merged_write(void *data, const char __user *buf, |
669 | size_t count, loff_t *ppos) | |
4a46f05e | 670 | { |
f57de23a | 671 | struct blk_mq_ctx *ctx = data; |
4a46f05e OS |
672 | |
673 | ctx->rq_merged = 0; | |
674 | return count; | |
675 | } | |
676 | ||
f57de23a | 677 | static int ctx_completed_show(void *data, struct seq_file *m) |
4a46f05e | 678 | { |
f57de23a | 679 | struct blk_mq_ctx *ctx = data; |
4a46f05e OS |
680 | |
681 | seq_printf(m, "%lu %lu\n", ctx->rq_completed[1], ctx->rq_completed[0]); | |
682 | return 0; | |
683 | } | |
684 | ||
f57de23a OS |
685 | static ssize_t ctx_completed_write(void *data, const char __user *buf, |
686 | size_t count, loff_t *ppos) | |
4a46f05e | 687 | { |
f57de23a OS |
688 | struct blk_mq_ctx *ctx = data; |
689 | ||
690 | ctx->rq_completed[0] = ctx->rq_completed[1] = 0; | |
691 | return count; | |
4a46f05e OS |
692 | } |
693 | ||
f57de23a OS |
694 | static int blk_mq_debugfs_show(struct seq_file *m, void *v) |
695 | { | |
696 | const struct blk_mq_debugfs_attr *attr = m->private; | |
697 | void *data = d_inode(m->file->f_path.dentry->d_parent)->i_private; | |
698 | ||
699 | return attr->show(data, m); | |
700 | } | |
701 | ||
702 | static ssize_t blk_mq_debugfs_write(struct file *file, const char __user *buf, | |
703 | size_t count, loff_t *ppos) | |
4a46f05e OS |
704 | { |
705 | struct seq_file *m = file->private_data; | |
f57de23a OS |
706 | const struct blk_mq_debugfs_attr *attr = m->private; |
707 | void *data = d_inode(file->f_path.dentry->d_parent)->i_private; | |
4a46f05e | 708 | |
f57de23a OS |
709 | if (!attr->write) |
710 | return -EPERM; | |
711 | ||
712 | return attr->write(data, buf, count, ppos); | |
713 | } | |
714 | ||
715 | static int blk_mq_debugfs_open(struct inode *inode, struct file *file) | |
716 | { | |
717 | const struct blk_mq_debugfs_attr *attr = inode->i_private; | |
718 | void *data = d_inode(file->f_path.dentry->d_parent)->i_private; | |
719 | struct seq_file *m; | |
720 | int ret; | |
721 | ||
722 | if (attr->seq_ops) { | |
723 | ret = seq_open(file, attr->seq_ops); | |
724 | if (!ret) { | |
725 | m = file->private_data; | |
726 | m->private = data; | |
727 | } | |
728 | return ret; | |
729 | } | |
730 | ||
731 | if (WARN_ON_ONCE(!attr->show)) | |
732 | return -EPERM; | |
733 | ||
734 | return single_open(file, blk_mq_debugfs_show, inode->i_private); | |
4a46f05e OS |
735 | } |
736 | ||
f57de23a OS |
737 | static int blk_mq_debugfs_release(struct inode *inode, struct file *file) |
738 | { | |
739 | const struct blk_mq_debugfs_attr *attr = inode->i_private; | |
740 | ||
741 | if (attr->show) | |
742 | return single_release(inode, file); | |
743 | else | |
744 | return seq_release(inode, file); | |
745 | } | |
746 | ||
747 | const struct file_operations blk_mq_debugfs_fops = { | |
748 | .open = blk_mq_debugfs_open, | |
4a46f05e | 749 | .read = seq_read, |
f57de23a | 750 | .write = blk_mq_debugfs_write, |
4a46f05e | 751 | .llseek = seq_lseek, |
f57de23a | 752 | .release = blk_mq_debugfs_release, |
4a46f05e OS |
753 | }; |
754 | ||
34dbad5d | 755 | static const struct blk_mq_debugfs_attr blk_mq_debugfs_queue_attrs[] = { |
f57de23a | 756 | {"poll_stat", 0400, queue_poll_stat_show}, |
8ef1a191 | 757 | {"requeue_list", 0400, .seq_ops = &queue_requeue_list_seq_ops}, |
f57de23a | 758 | {"state", 0600, queue_state_show, queue_state_write}, |
f793dfd3 | 759 | {"write_hints", 0600, queue_write_hint_show, queue_write_hint_store}, |
34dbad5d OS |
760 | {}, |
761 | }; | |
762 | ||
07e4fead | 763 | static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_attrs[] = { |
f57de23a OS |
764 | {"state", 0400, hctx_state_show}, |
765 | {"flags", 0400, hctx_flags_show}, | |
766 | {"dispatch", 0400, .seq_ops = &hctx_dispatch_seq_ops}, | |
2720bab5 | 767 | {"busy", 0400, hctx_busy_show}, |
f57de23a OS |
768 | {"ctx_map", 0400, hctx_ctx_map_show}, |
769 | {"tags", 0400, hctx_tags_show}, | |
770 | {"tags_bitmap", 0400, hctx_tags_bitmap_show}, | |
771 | {"sched_tags", 0400, hctx_sched_tags_show}, | |
772 | {"sched_tags_bitmap", 0400, hctx_sched_tags_bitmap_show}, | |
773 | {"io_poll", 0600, hctx_io_poll_show, hctx_io_poll_write}, | |
774 | {"dispatched", 0600, hctx_dispatched_show, hctx_dispatched_write}, | |
775 | {"queued", 0600, hctx_queued_show, hctx_queued_write}, | |
776 | {"run", 0600, hctx_run_show, hctx_run_write}, | |
777 | {"active", 0400, hctx_active_show}, | |
72f2f8f6 | 778 | {}, |
07e4fead OS |
779 | }; |
780 | ||
781 | static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = { | |
f57de23a OS |
782 | {"rq_list", 0400, .seq_ops = &ctx_rq_list_seq_ops}, |
783 | {"dispatched", 0600, ctx_dispatched_show, ctx_dispatched_write}, | |
784 | {"merged", 0600, ctx_merged_show, ctx_merged_write}, | |
785 | {"completed", 0600, ctx_completed_show, ctx_completed_write}, | |
72f2f8f6 | 786 | {}, |
07e4fead OS |
787 | }; |
788 | ||
9c1051aa OS |
789 | static bool debugfs_create_files(struct dentry *parent, void *data, |
790 | const struct blk_mq_debugfs_attr *attr) | |
791 | { | |
792 | d_inode(parent)->i_private = data; | |
793 | ||
794 | for (; attr->name; attr++) { | |
795 | if (!debugfs_create_file(attr->name, attr->mode, parent, | |
796 | (void *)attr, &blk_mq_debugfs_fops)) | |
797 | return false; | |
798 | } | |
799 | return true; | |
800 | } | |
801 | ||
4c9e4019 | 802 | int blk_mq_debugfs_register(struct request_queue *q) |
07e4fead | 803 | { |
9c1051aa OS |
804 | struct blk_mq_hw_ctx *hctx; |
805 | int i; | |
806 | ||
18fbda91 | 807 | if (!blk_debugfs_root) |
07e4fead OS |
808 | return -ENOENT; |
809 | ||
4c9e4019 BVA |
810 | q->debugfs_dir = debugfs_create_dir(kobject_name(q->kobj.parent), |
811 | blk_debugfs_root); | |
07e4fead | 812 | if (!q->debugfs_dir) |
9c1051aa | 813 | return -ENOMEM; |
07e4fead | 814 | |
9c1051aa OS |
815 | if (!debugfs_create_files(q->debugfs_dir, q, |
816 | blk_mq_debugfs_queue_attrs)) | |
07e4fead OS |
817 | goto err; |
818 | ||
9c1051aa OS |
819 | /* |
820 | * blk_mq_init_hctx() attempted to do this already, but q->debugfs_dir | |
821 | * didn't exist yet (because we don't know what to name the directory | |
822 | * until the queue is registered to a gendisk). | |
823 | */ | |
824 | queue_for_each_hw_ctx(q, hctx, i) { | |
825 | if (!hctx->debugfs_dir && blk_mq_debugfs_register_hctx(q, hctx)) | |
826 | goto err; | |
d332ce09 OS |
827 | if (q->elevator && !hctx->sched_debugfs_dir && |
828 | blk_mq_debugfs_register_sched_hctx(q, hctx)) | |
829 | goto err; | |
9c1051aa OS |
830 | } |
831 | ||
07e4fead OS |
832 | return 0; |
833 | ||
834 | err: | |
835 | blk_mq_debugfs_unregister(q); | |
836 | return -ENOMEM; | |
837 | } | |
838 | ||
839 | void blk_mq_debugfs_unregister(struct request_queue *q) | |
840 | { | |
841 | debugfs_remove_recursive(q->debugfs_dir); | |
d332ce09 | 842 | q->sched_debugfs_dir = NULL; |
07e4fead OS |
843 | q->debugfs_dir = NULL; |
844 | } | |
845 | ||
9c1051aa OS |
846 | static int blk_mq_debugfs_register_ctx(struct blk_mq_hw_ctx *hctx, |
847 | struct blk_mq_ctx *ctx) | |
07e4fead OS |
848 | { |
849 | struct dentry *ctx_dir; | |
850 | char name[20]; | |
07e4fead OS |
851 | |
852 | snprintf(name, sizeof(name), "cpu%u", ctx->cpu); | |
9c1051aa | 853 | ctx_dir = debugfs_create_dir(name, hctx->debugfs_dir); |
07e4fead OS |
854 | if (!ctx_dir) |
855 | return -ENOMEM; | |
856 | ||
72f2f8f6 BVA |
857 | if (!debugfs_create_files(ctx_dir, ctx, blk_mq_debugfs_ctx_attrs)) |
858 | return -ENOMEM; | |
07e4fead OS |
859 | |
860 | return 0; | |
861 | } | |
862 | ||
9c1051aa OS |
863 | int blk_mq_debugfs_register_hctx(struct request_queue *q, |
864 | struct blk_mq_hw_ctx *hctx) | |
07e4fead OS |
865 | { |
866 | struct blk_mq_ctx *ctx; | |
07e4fead OS |
867 | char name[20]; |
868 | int i; | |
869 | ||
9c1051aa OS |
870 | if (!q->debugfs_dir) |
871 | return -ENOENT; | |
872 | ||
88aabbd7 | 873 | snprintf(name, sizeof(name), "hctx%u", hctx->queue_num); |
9c1051aa OS |
874 | hctx->debugfs_dir = debugfs_create_dir(name, q->debugfs_dir); |
875 | if (!hctx->debugfs_dir) | |
07e4fead OS |
876 | return -ENOMEM; |
877 | ||
9c1051aa OS |
878 | if (!debugfs_create_files(hctx->debugfs_dir, hctx, |
879 | blk_mq_debugfs_hctx_attrs)) | |
880 | goto err; | |
07e4fead OS |
881 | |
882 | hctx_for_each_ctx(hctx, ctx, i) { | |
9c1051aa OS |
883 | if (blk_mq_debugfs_register_ctx(hctx, ctx)) |
884 | goto err; | |
07e4fead OS |
885 | } |
886 | ||
887 | return 0; | |
9c1051aa OS |
888 | |
889 | err: | |
890 | blk_mq_debugfs_unregister_hctx(hctx); | |
891 | return -ENOMEM; | |
892 | } | |
893 | ||
894 | void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx) | |
895 | { | |
896 | debugfs_remove_recursive(hctx->debugfs_dir); | |
d332ce09 | 897 | hctx->sched_debugfs_dir = NULL; |
9c1051aa | 898 | hctx->debugfs_dir = NULL; |
07e4fead OS |
899 | } |
900 | ||
9c1051aa | 901 | int blk_mq_debugfs_register_hctxs(struct request_queue *q) |
07e4fead OS |
902 | { |
903 | struct blk_mq_hw_ctx *hctx; | |
904 | int i; | |
905 | ||
07e4fead OS |
906 | queue_for_each_hw_ctx(q, hctx, i) { |
907 | if (blk_mq_debugfs_register_hctx(q, hctx)) | |
9c1051aa | 908 | return -ENOMEM; |
07e4fead OS |
909 | } |
910 | ||
911 | return 0; | |
07e4fead OS |
912 | } |
913 | ||
9c1051aa | 914 | void blk_mq_debugfs_unregister_hctxs(struct request_queue *q) |
07e4fead | 915 | { |
9c1051aa OS |
916 | struct blk_mq_hw_ctx *hctx; |
917 | int i; | |
918 | ||
919 | queue_for_each_hw_ctx(q, hctx, i) | |
920 | blk_mq_debugfs_unregister_hctx(hctx); | |
07e4fead | 921 | } |
d332ce09 OS |
922 | |
923 | int blk_mq_debugfs_register_sched(struct request_queue *q) | |
924 | { | |
925 | struct elevator_type *e = q->elevator->type; | |
926 | ||
927 | if (!q->debugfs_dir) | |
928 | return -ENOENT; | |
929 | ||
930 | if (!e->queue_debugfs_attrs) | |
931 | return 0; | |
932 | ||
933 | q->sched_debugfs_dir = debugfs_create_dir("sched", q->debugfs_dir); | |
934 | if (!q->sched_debugfs_dir) | |
935 | return -ENOMEM; | |
936 | ||
937 | if (!debugfs_create_files(q->sched_debugfs_dir, q, | |
938 | e->queue_debugfs_attrs)) | |
939 | goto err; | |
940 | ||
941 | return 0; | |
942 | ||
943 | err: | |
944 | blk_mq_debugfs_unregister_sched(q); | |
945 | return -ENOMEM; | |
946 | } | |
947 | ||
948 | void blk_mq_debugfs_unregister_sched(struct request_queue *q) | |
949 | { | |
950 | debugfs_remove_recursive(q->sched_debugfs_dir); | |
951 | q->sched_debugfs_dir = NULL; | |
952 | } | |
953 | ||
954 | int blk_mq_debugfs_register_sched_hctx(struct request_queue *q, | |
955 | struct blk_mq_hw_ctx *hctx) | |
956 | { | |
957 | struct elevator_type *e = q->elevator->type; | |
958 | ||
959 | if (!hctx->debugfs_dir) | |
960 | return -ENOENT; | |
961 | ||
962 | if (!e->hctx_debugfs_attrs) | |
963 | return 0; | |
964 | ||
965 | hctx->sched_debugfs_dir = debugfs_create_dir("sched", | |
966 | hctx->debugfs_dir); | |
967 | if (!hctx->sched_debugfs_dir) | |
968 | return -ENOMEM; | |
969 | ||
970 | if (!debugfs_create_files(hctx->sched_debugfs_dir, hctx, | |
971 | e->hctx_debugfs_attrs)) | |
972 | return -ENOMEM; | |
973 | ||
974 | return 0; | |
975 | } | |
976 | ||
977 | void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx) | |
978 | { | |
979 | debugfs_remove_recursive(hctx->sched_debugfs_dir); | |
980 | hctx->sched_debugfs_dir = NULL; | |
981 | } |