-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlinux-v5.9.patch
7413 lines (7003 loc) · 329 KB
/
linux-v5.9.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From d6daeb5f64790e2bf8f52c8f43e7883ae979ae4c Mon Sep 17 00:00:00 2001
From: Dongli Zhang <[email protected]>
Date: Mon, 14 Dec 2020 10:57:37 -0800
Subject: [PATCH 1/1] linux v5.9
Signed-off-by: Dongli Zhang <[email protected]>
---
block/bfq-iosched.c | 14 +
block/bio.c | 4 +
block/blk-cgroup-rwstat.c | 11 +
block/blk-cgroup.c | 87 ++++
block/blk-core.c | 300 ++++++++++++
block/blk-crypto-internal.h | 5 +
block/blk-iocost.c | 47 ++
block/blk-iolatency.c | 59 +++
block/blk-lib.c | 61 +++
block/blk-mq-cpumap.c | 25 +
block/blk-mq-debugfs.c | 3 +
block/blk-mq-sched.c | 34 ++
block/blk-mq-sched.h | 8 +
block/blk-mq-tag.c | 235 ++++++++++
block/blk-mq-tag.h | 40 ++
block/blk-mq-virtio.c | 5 +
block/blk-mq.c | 459 +++++++++++++++++++
block/blk-rq-qos.h | 4 +
block/blk-settings.c | 33 ++
block/blk-throttle.c | 94 ++++
block/bounce.c | 10 +
block/elevator.c | 6 +
drivers/md/dm-linear.c | 11 +
drivers/md/dm-table.c | 5 +
drivers/md/dm.c | 6 +
drivers/net/tap.c | 5 +
drivers/net/tun.c | 4 +
drivers/net/virtio_net.c | 48 ++
drivers/net/xen-netback/rx.c | 5 +
drivers/scsi/hosts.c | 25 +
drivers/scsi/scsi.c | 66 +++
drivers/scsi/scsi_common.c | 32 ++
drivers/scsi/scsi_debug.c | 17 +
drivers/scsi/scsi_debugfs.c | 7 +
drivers/scsi/scsi_devinfo.c | 7 +
drivers/scsi/scsi_dh.c | 35 ++
drivers/scsi/scsi_error.c | 6 +
drivers/scsi/scsi_ioctl.c | 11 +
drivers/scsi/scsi_lib.c | 104 +++++
drivers/scsi/scsi_lib_dma.c | 10 +
drivers/scsi/scsi_logging.c | 5 +
drivers/scsi/scsi_netlink.c | 4 +
drivers/scsi/scsi_pm.c | 14 +
drivers/scsi/scsi_scan.c | 222 +++++++++
drivers/scsi/scsi_sysfs.c | 15 +
drivers/scsi/scsi_trace.c | 14 +
drivers/scsi/scsicam.c | 5 +
drivers/scsi/sd.c | 38 ++
drivers/scsi/virtio_scsi.c | 400 ++++++++++++++++
drivers/target/loopback/tcm_loop.c | 33 ++
drivers/target/target_core_configfs.c | 28 ++
drivers/target/target_core_fabric_configfs.c | 3 +
drivers/target/target_core_file.c | 39 ++
drivers/target/target_core_hba.c | 25 +-
drivers/target/target_core_sbc.c | 6 +
drivers/target/target_core_transport.c | 48 ++
drivers/vhost/net.c | 62 +++
drivers/vhost/scsi.c | 129 ++++++
drivers/vhost/vhost.c | 264 +++++++++++
drivers/vhost/vhost.h | 38 ++
fs/eventfd.c | 11 +
include/linux/blk-cgroup.h | 8 +
include/linux/blk-mq.h | 39 ++
include/linux/blkdev.h | 16 +
include/linux/kernel.h | 10 +
include/linux/kvm_host.h | 11 +
include/linux/overflow.h | 9 +
include/linux/poll.h | 7 +
include/linux/sched.h | 17 +
include/scsi/scsi_device.h | 49 ++
include/scsi/scsi_host.h | 42 ++
include/uapi/linux/virtio_scsi.h | 7 +
kernel/locking/mutex.c | 13 +
kernel/panic.c | 9 +
kernel/sched/core.c | 16 +
kernel/sched/cputime.c | 8 +
kernel/sched/sched.h | 8 +
mm/slub.c | 10 +
net/core/dev.c | 17 +
net/ipv4/devinet.c | 13 +
net/packet/af_packet.c | 91 ++++
virt/kvm/kvm_main.c | 50 ++
82 files changed, 3800 insertions(+), 1 deletion(-)
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index fa98470df3f0..750660c538ee 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -132,6 +132,13 @@
#include "bfq-iosched.h"
#include "blk-wbt.h"
+/*
+ * 从block/bfq-iosched.c又分裂出了如下三个文件:
+ * create mode 100644 block/bfq-cgroup.c
+ * create mode 100644 block/bfq-iosched.h
+ * create mode 100644 block/bfq-wf2q.c
+ */
+
#define BFQ_BFQQ_FNS(name) \
void bfq_mark_bfqq_##name(struct bfq_queue *bfqq) \
{ \
@@ -6809,6 +6816,13 @@ static int __init bfq_init(void)
int ret;
#ifdef CONFIG_BFQ_GROUP_IOSCHED
+ /*
+ * 在以下调用blkcg_policy_register():
+ * - block/bfq-iosched.c|6812| <<bfq_init>> ret = blkcg_policy_register(&blkcg_policy_bfq);
+ * - block/blk-iocost.c|2528| <<ioc_init>> return blkcg_policy_register(&blkcg_policy_iocost);
+ * - block/blk-iolatency.c|1044| <<iolatency_init>> return blkcg_policy_register(&blkcg_policy_iolatency);
+ * - block/blk-throttle.c|2477| <<throtl_init>> return blkcg_policy_register(&blkcg_policy_throtl);
+ */
ret = blkcg_policy_register(&blkcg_policy_bfq);
if (ret)
return ret;
diff --git a/block/bio.c b/block/bio.c
index e865ea55b9f9..8ccd44620237 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -335,6 +335,10 @@ static void bio_chain_endio(struct bio *bio)
*
* The caller must not set bi_private or bi_end_io in @bio.
*/
+/*
+ * 核心思想是把bio->bi_private = parent
+ * bio->bi_end_io = bio_chain_endio
+ */
void bio_chain(struct bio *bio, struct bio *parent)
{
BUG_ON(bio->bi_private || bio->bi_end_io);
diff --git a/block/blk-cgroup-rwstat.c b/block/blk-cgroup-rwstat.c
index 85d5790ac49b..8468dacc5982 100644
--- a/block/blk-cgroup-rwstat.c
+++ b/block/blk-cgroup-rwstat.c
@@ -5,6 +5,17 @@
*/
#include "blk-cgroup-rwstat.h"
+/*
+ * called by:
+ * - block/bfq-cgroup.c|464| <<bfqg_stats_init>> if (blkg_rwstat_init(&stats->bytes, gfp) ||
+ * - block/bfq-cgroup.c|465| <<bfqg_stats_init>> blkg_rwstat_init(&stats->ios, gfp))
+ * - block/bfq-cgroup.c|469| <<bfqg_stats_init>> if (blkg_rwstat_init(&stats->merged, gfp) ||
+ * - block/bfq-cgroup.c|470| <<bfqg_stats_init>> blkg_rwstat_init(&stats->service_time, gfp) ||
+ * - block/bfq-cgroup.c|471| <<bfqg_stats_init>> blkg_rwstat_init(&stats->wait_time, gfp) ||
+ * - block/bfq-cgroup.c|472| <<bfqg_stats_init>> blkg_rwstat_init(&stats->queued, gfp) ||
+ * - block/blk-throttle.c|496| <<throtl_pd_alloc>> if (blkg_rwstat_init(&tg->stat_bytes, gfp))
+ * - block/blk-throttle.c|499| <<throtl_pd_alloc>> if (blkg_rwstat_init(&tg->stat_ios, gfp))
+ */
int blkg_rwstat_init(struct blkg_rwstat *rwstat, gfp_t gfp)
{
int i, ret;
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index c195365c9817..ed73f92b45a9 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -34,6 +34,14 @@
#define MAX_KEY_LEN 100
+/*
+ * 在以下调用blkcg_policy_register():
+ * - block/bfq-iosched.c|6812| <<bfq_init>> ret = blkcg_policy_register(&blkcg_policy_bfq);
+ * - block/blk-iocost.c|2528| <<ioc_init>> return blkcg_policy_register(&blkcg_policy_iocost);
+ * - block/blk-iolatency.c|1044| <<iolatency_init>> return blkcg_policy_register(&blkcg_policy_iolatency);
+ * - block/blk-throttle.c|2477| <<throtl_init>> return blkcg_policy_register(&blkcg_policy_throtl);
+ */
+
/*
* blkcg_pol_mutex protects blkcg_policy[] and policy [de]activation.
* blkcg_pol_register_mutex nests outside of it and synchronizes entire
@@ -219,6 +227,12 @@ EXPORT_SYMBOL_GPL(blkg_lookup_slowpath);
* If @new_blkg is %NULL, this function tries to allocate a new one as
* necessary using %GFP_NOWAIT. @new_blkg is always consumed on return.
*/
+/*
+ * called by:
+ * - block/blk-cgroup.c|354| <<blkg_lookup_create>> blkg = blkg_create(pos, q, NULL);
+ * - block/blk-cgroup.c|663| <<__acquires>> blkg = blkg_create(pos, q, new_blkg);
+ * - block/blk-cgroup.c|1145| <<blkcg_init_queue>> blkg = blkg_create(&blkcg_root, q, new_blkg);
+ */
static struct blkcg_gq *blkg_create(struct blkcg *blkcg,
struct request_queue *q,
struct blkcg_gq *new_blkg)
@@ -935,6 +949,9 @@ static struct cftype blkcg_files[] = {
{ } /* terminate */
};
+/*
+ * struct cgroup_subsys io_cgrp_subsys.legacy_cftypes = blkcg_legacy_files[]
+ */
static struct cftype blkcg_legacy_files[] = {
{
.name = "reset_stats",
@@ -1127,6 +1144,10 @@ static int blkcg_css_online(struct cgroup_subsys_state *css)
* RETURNS:
* 0 on success, -errno on failure.
*/
+/*
+ * called by:
+ * - block/blk-core.c|574| <<blk_alloc_queue>> if (blkcg_init_queue(q))
+ */
int blkcg_init_queue(struct request_queue *q)
{
struct blkcg_gq *new_blkg, *blkg;
@@ -1142,6 +1163,12 @@ int blkcg_init_queue(struct request_queue *q)
/* Make sure the root blkg exists. */
rcu_read_lock();
spin_lock_irq(&q->queue_lock);
+ /*
+ * called by:
+ * - block/blk-cgroup.c|354| <<blkg_lookup_create>> blkg = blkg_create(pos, q, NULL);
+ * - block/blk-cgroup.c|663| <<__acquires>> blkg = blkg_create(pos, q, new_blkg);
+ * - block/blk-cgroup.c|1145| <<blkcg_init_queue>> blkg = blkg_create(&blkcg_root, q, new_blkg);
+ */
blkg = blkg_create(&blkcg_root, q, new_blkg);
if (IS_ERR(blkg))
goto err_unlock;
@@ -1239,6 +1266,23 @@ static void blkcg_exit(struct task_struct *tsk)
tsk->throttle_queue = NULL;
}
+/*
+ * 在以下使用io_cgrp_subsys:
+ * - block/bfq-cgroup.c|512| <<bfq_cpd_init>> d->weight = cgroup_subsys_on_dfl(io_cgrp_subsys) ?
+ * - block/bfq-iosched.c|5499| <<bfq_insert_request>> if (!cgroup_subsys_on_dfl(io_cgrp_subsys) && rq->bio)
+ * - block/blk-cgroup.c|1472| <<blkcg_policy_register>> WARN_ON(cgroup_add_dfl_cftypes(&io_cgrp_subsys,
+ * - block/blk-cgroup.c|1475| <<blkcg_policy_register>> WARN_ON(cgroup_add_legacy_cftypes(&io_cgrp_subsys,
+ * - block/blk-cgroup.c|1919| <<blk_cgroup_bio_start>> if (cgroup_subsys_on_dfl(io_cgrp_subsys))
+ * - block/blk-throttle.c|302| <<tg_bps_limit>> if (cgroup_subsys_on_dfl(io_cgrp_subsys) && !blkg->parent)
+ * - block/blk-throttle.c|332| <<tg_iops_limit>> if (cgroup_subsys_on_dfl(io_cgrp_subsys) && !blkg->parent)
+ * - block/blk-throttle.c|555| <<throtl_pd_init>> if (cgroup_subsys_on_dfl(io_cgrp_subsys) && blkg->parent)
+ * - block/blk-throttle.c|1409| <<tg_conf_updated>> if (!cgroup_subsys_on_dfl(io_cgrp_subsys) || !blkg->parent ||
+ * - block/blk-throttle.c|2178| <<blk_throtl_bio>> if (!cgroup_subsys_on_dfl(io_cgrp_subsys)) {
+ * - include/linux/backing-dev.h|248| <<inode_cgwb_enabled>> cgroup_subsys_on_dfl(io_cgrp_subsys) &&
+ * - mm/backing-dev.c|442| <<cgwb_create>> blkcg_css = cgroup_get_e_css(memcg_css->cgroup, &io_cgrp_subsys);
+ * - mm/backing-dev.c|561| <<wb_get_lookup>> blkcg_css = cgroup_get_e_css(memcg_css->cgroup, &io_cgrp_subsys);
+ * - mm/page_io.c|289| <<bio_associate_blkg_from_page>> css = cgroup_e_css(page->mem_cgroup->css.cgroup, &io_cgrp_subsys);
+ */
struct cgroup_subsys io_cgrp_subsys = {
.css_alloc = blkcg_css_alloc,
.css_online = blkcg_css_online,
@@ -1415,6 +1459,13 @@ EXPORT_SYMBOL_GPL(blkcg_deactivate_policy);
* Register @pol with blkcg core. Might sleep and @pol may be modified on
* successful registration. Returns 0 on success and -errno on failure.
*/
+/*
+ * 在以下调用blkcg_policy_register():
+ * - block/bfq-iosched.c|6812| <<bfq_init>> ret = blkcg_policy_register(&blkcg_policy_bfq);
+ * - block/blk-iocost.c|2528| <<ioc_init>> return blkcg_policy_register(&blkcg_policy_iocost);
+ * - block/blk-iolatency.c|1044| <<iolatency_init>> return blkcg_policy_register(&blkcg_policy_iolatency);
+ * - block/blk-throttle.c|2477| <<throtl_init>> return blkcg_policy_register(&blkcg_policy_throtl);
+ */
int blkcg_policy_register(struct blkcg_policy *pol)
{
struct blkcg *blkcg;
@@ -1540,6 +1591,14 @@ bool __blkcg_punt_bio_submit(struct bio *bio)
return false;
spin_lock_bh(&blkg->async_bio_lock);
+ /*
+ * 在以下使用blkcg_gq->async_bios:
+ * - block/blk-cgroup.c|100| <<__blkg_release>> WARN_ON(!bio_list_empty(&blkg->async_bios));
+ * - block/blk-cgroup.c|133| <<blkg_async_bio_workfn>> bio_list_merge(&bios, &blkg->async_bios);
+ * - block/blk-cgroup.c|134| <<blkg_async_bio_workfn>> bio_list_init(&blkg->async_bios);
+ * - block/blk-cgroup.c|170| <<blkg_alloc>> bio_list_init(&blkg->async_bios);
+ * - block/blk-cgroup.c|1594| <<__blkcg_punt_bio_submit>> bio_list_add(&blkg->async_bios, bio);
+ */
bio_list_add(&blkg->async_bios, bio);
spin_unlock_bh(&blkg->async_bio_lock);
@@ -1862,6 +1921,34 @@ static int blk_cgroup_io_type(struct bio *bio)
return BLKG_IOSTAT_READ;
}
+/*
+ * [0] blk_cgroup_bio_start
+ * [0] submit_bio_checks
+ * [0] submit_bio_noacct
+ * [0] submit_bio
+ * [0] submit_bh_wbc.isra.57
+ * [0] ll_rw_block
+ * [0] jread
+ * [0] do_one_pass
+ * [0] jbd2_journal_recover
+ * [0] jbd2_journal_load
+ * [0] ext4_fill_super
+ * [0] mount_bdev
+ * [0] legacy_get_tree
+ * [0] vfs_get_tree
+ * [0] path_mount
+ * [0] init_mount
+ * [0] do_mount_root
+ * [0] mount_block_root
+ * [0] mount_root
+ * [0] prepare_namespace
+ * [0] kernel_init_freeable
+ * [0] kernel_init
+ * [0] ret_from_fork
+ *
+ * called by:
+ * - block/blk-core.c|1059| <<submit_bio_checks>> blk_cgroup_bio_start(bio);
+ */
void blk_cgroup_bio_start(struct bio *bio)
{
int rwd = blk_cgroup_io_type(bio), cpu;
diff --git a/block/blk-core.c b/block/blk-core.c
index 10c08ac50697..6b1e9c768128 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -64,11 +64,25 @@ DEFINE_IDA(blk_queue_ida);
/*
* For queue allocation
*/
+/*
+ * 在以下使用blk_requestq_cachep:
+ * - block/blk-core.c|564| <<blk_alloc_queue>> q = kmem_cache_alloc_node(blk_requestq_cachep,
+ * - block/blk-core.c|640| <<blk_alloc_queue>> kmem_cache_free(blk_requestq_cachep, q);
+ * - block/blk-core.c|1963| <<blk_dev_init>> blk_requestq_cachep = kmem_cache_create("request_queue",
+ * - block/blk-sysfs.c|872| <<blk_free_queue_rcu>> kmem_cache_free(blk_requestq_cachep, q);
+ */
struct kmem_cache *blk_requestq_cachep;
/*
* Controlling structure to kblockd
*/
+/*
+ * 在以下使用kblockd_workqueue:
+ * - block/blk-core.c|1816| <<kblockd_schedule_work>> return queue_work(kblockd_workqueue, work);
+ * - block/blk-core.c|1823| <<kblockd_mod_delayed_work_on>> return mod_delayed_work_on(cpu, kblockd_workqueue, dwork, delay);
+ * - block/blk-core.c|1965| <<blk_dev_init>> kblockd_workqueue = alloc_workqueue("kblockd",
+ * - block/blk-core.c|1967| <<blk_dev_init>> if (!kblockd_workqueue)
+ */
static struct workqueue_struct *kblockd_workqueue;
/**
@@ -107,6 +121,11 @@ bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q)
}
EXPORT_SYMBOL_GPL(blk_queue_flag_test_and_set);
+/*
+ * called by:
+ * - block/blk-flush.c|298| <<blk_kick_flush>> blk_rq_init(q, flush_rq);
+ * - drivers/scsi/scsi_error.c|2353| <<scsi_ioctl_reset>> blk_rq_init(NULL, rq);
+ */
void blk_rq_init(struct request_queue *q, struct request *rq)
{
memset(rq, 0, sizeof(*rq));
@@ -155,6 +174,13 @@ static const char *const blk_op_name[] = {
* string format. Useful in the debugging and tracing bio or request. For
* invalid REQ_OP_XXX it returns string "UNKNOWN".
*/
+/*
+ * called by:
+ * - block/blk-core.c|236| <<print_req_error>> blk_rq_pos(req), req_op(req), blk_op_str(req_op(req)),
+ * - block/blk-mq-debugfs.c|332| <<__blk_mq_debugfs_rq_show>> const char *op_str = blk_op_str(op);
+ * - drivers/block/null_blk_trace.h|51| <<__field>> blk_op_str(__entry->op),
+ * - include/trace/events/f2fs.h|81| <<show_bio_op>> #define show_bio_op(op) blk_op_str(op)
+ */
inline const char *blk_op_str(unsigned int op)
{
const char *op_str = "UNKNOWN";
@@ -213,6 +239,10 @@ int blk_status_to_errno(blk_status_t status)
}
EXPORT_SYMBOL_GPL(blk_status_to_errno);
+/*
+ * called by:
+ * - block/blk-core.c|1616| <<blk_update_request>> print_req_error(req, error, __func__);
+ */
static void print_req_error(struct request *req, blk_status_t status,
const char *caller)
{
@@ -259,6 +289,15 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
bio_endio(bio);
}
+/*
+ * called by:
+ * - block/blk-core.c|1670| <<blk_update_request>> blk_dump_rq_flags(req, "request botched");
+ * - drivers/block/ps3disk.c|190| <<ps3disk_do_request>> blk_dump_rq_flags(req, DEVICE_NAME " bad request");
+ * - drivers/ide/ide-cd.c|741| <<cdrom_newpc_intr>> blk_dump_rq_flags(rq, "cdrom_newpc_intr");
+ * - drivers/ide/ide-cd.c|887| <<ide_cd_do_request>> blk_dump_rq_flags(rq, "ide_cd_do_request");
+ * - drivers/ide/ide-floppy.c|240| <<ide_floppy_do_request>> blk_dump_rq_flags(rq, (rq->rq_disk
+ * - drivers/scsi/sr.c|452| <<sr_init_command>> blk_dump_rq_flags(rq, "Unknown sr command");
+ */
void blk_dump_rq_flags(struct request *rq, char *msg)
{
printk(KERN_INFO "%s: dev %s: flags=%llx\n", msg,
@@ -291,6 +330,13 @@ EXPORT_SYMBOL(blk_dump_rq_flags);
* and blkcg_exit_queue() to be called with queue lock initialized.
*
*/
+/*
+ * called by:
+ * - block/blk-core.c|413| <<blk_cleanup_queue>> blk_sync_queue(q);
+ * - drivers/md/md.c|6278| <<mddev_detach>> blk_sync_queue(mddev->queue);
+ * - drivers/nvme/host/core.c|4651| <<nvme_sync_queues>> blk_sync_queue(ns->queue);
+ * - drivers/nvme/host/core.c|4655| <<nvme_sync_queues>> blk_sync_queue(ctrl->admin_q);
+ */
void blk_sync_queue(struct request_queue *q)
{
del_timer_sync(&q->timeout);
@@ -302,12 +348,25 @@ EXPORT_SYMBOL(blk_sync_queue);
* blk_set_pm_only - increment pm_only counter
* @q: request queue pointer
*/
+/*
+ * called by:
+ * - block/blk-pm.c|76| <<blk_pre_runtime_suspend>> blk_set_pm_only(q);
+ * - drivers/scsi/scsi_lib.c|2520| <<scsi_device_quiesce>> blk_set_pm_only(q);
+ */
void blk_set_pm_only(struct request_queue *q)
{
atomic_inc(&q->pm_only);
}
EXPORT_SYMBOL_GPL(blk_set_pm_only);
+/*
+ * called by:
+ * - block/blk-pm.c|100| <<blk_pre_runtime_suspend>> blk_clear_pm_only(q);
+ * - block/blk-pm.c|134| <<blk_post_runtime_suspend>> blk_clear_pm_only(q);
+ * - block/blk-pm.c|219| <<blk_set_runtime_active>> blk_clear_pm_only(q);
+ * - drivers/scsi/scsi_lib.c|2537| <<scsi_device_quiesce>> blk_clear_pm_only(q);
+ * - drivers/scsi/scsi_lib.c|2562| <<scsi_device_resume>> blk_clear_pm_only(sdev->request_queue);
+ */
void blk_clear_pm_only(struct request_queue *q)
{
int pm_only;
@@ -335,6 +394,15 @@ void blk_put_queue(struct request_queue *q)
}
EXPORT_SYMBOL(blk_put_queue);
+/*
+ * called by:
+ * - block/blk-core.c|436| <<blk_cleanup_queue>> blk_set_queue_dying(q);
+ * - drivers/block/mtip32xx/mtip32xx.c|4217| <<mtip_pci_remove>> blk_set_queue_dying(dd->queue);
+ * - drivers/block/rbd.c|7268| <<do_rbd_remove>> blk_set_queue_dying(rbd_dev->disk->queue);
+ * - drivers/md/dm.c|2348| <<__dm_destroy>> blk_set_queue_dying(md->queue);
+ * - drivers/nvme/host/core.c|105| <<nvme_set_queue_dying>> blk_set_queue_dying(ns->queue);
+ * - drivers/nvme/host/multipath.c|691| <<nvme_mpath_remove_disk>> blk_set_queue_dying(head->disk->queue);
+ */
void blk_set_queue_dying(struct request_queue *q)
{
blk_queue_flag_set(QUEUE_FLAG_DYING, q);
@@ -350,6 +418,17 @@ void blk_set_queue_dying(struct request_queue *q)
blk_mq_wake_waiters(q);
/* Make blk_queue_enter() reexamine the DYING flag. */
+ /*
+ * 在以下使用request_queue->mq_freeze_wq:
+ * - block/blk-core.c|318| <<blk_clear_pm_only>> wake_up_all(&q->mq_freeze_wq);
+ * - block/blk-core.c|353| <<blk_set_queue_dying>> wake_up_all(&q->mq_freeze_wq);
+ * - block/blk-core.c|462| <<blk_queue_enter>> wait_event(q->mq_freeze_wq,
+ * - block/blk-core.c|512| <<blk_queue_usage_counter_release>> wake_up_all(&q->mq_freeze_wq);
+ * - block/blk-core.c|575| <<blk_alloc_queue>> init_waitqueue_head(&q->mq_freeze_wq);
+ * - block/blk-mq.c|157| <<blk_mq_freeze_queue_wait>> wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->q_usage_counter));
+ * - block/blk-mq.c|164| <<blk_mq_freeze_queue_wait_timeout>> return wait_event_timeout(q->mq_freeze_wq,
+ * - block/blk-mq.c|204| <<blk_mq_unfreeze_queue>> wake_up_all(&q->mq_freeze_wq);
+ */
wake_up_all(&q->mq_freeze_wq);
}
EXPORT_SYMBOL_GPL(blk_set_queue_dying);
@@ -363,6 +442,65 @@ EXPORT_SYMBOL_GPL(blk_set_queue_dying);
*
* Context: can sleep
*/
+/*
+ * 调用的例子:
+ * - block/blk-mq.c|3262| <<blk_mq_init_queue_data>> blk_cleanup_queue(uninit_q);
+ * - block/bsg-lib.c|331| <<bsg_remove_queue>> blk_cleanup_queue(q);
+ * - block/bsg-lib.c|408| <<bsg_setup_queue>> blk_cleanup_queue(q);
+ * - drivers/block/loop.c|2179| <<loop_add>> blk_cleanup_queue(lo->lo_queue);
+ * - drivers/block/loop.c|2193| <<loop_remove>> blk_cleanup_queue(lo->lo_queue);
+ * - drivers/block/nbd.c|228| <<nbd_dev_remove>> blk_cleanup_queue(q);
+ * - drivers/block/null_blk_main.c|1557| <<null_del_dev>> blk_cleanup_queue(nullb->q);
+ * - drivers/block/null_blk_main.c|1866| <<null_add_dev>> blk_cleanup_queue(nullb->q);
+ * - drivers/block/virtio_blk.c|914| <<virtblk_remove>> blk_cleanup_queue(vblk->disk->queue);
+ * - drivers/block/xen-blkfront.c|1219| <<xlvbd_release_gendisk>> blk_cleanup_queue(info->rq);
+ * - drivers/md/dm.c|1878| <<cleanup_mapped_device>> blk_cleanup_queue(md->queue);
+ * - drivers/md/md.c|5599| <<md_free>> blk_cleanup_queue(mddev->queue);
+ * - drivers/md/md.c|5716| <<md_alloc>> blk_cleanup_queue(mddev->queue);
+ * - drivers/nvdimm/blk.c|234| <<nd_blk_release_queue>> blk_cleanup_queue(q);
+ * - drivers/nvdimm/btt.c|1531| <<btt_blk_init>> blk_cleanup_queue(btt->btt_queue);
+ * - drivers/nvdimm/btt.c|1554| <<btt_blk_init>> blk_cleanup_queue(btt->btt_queue);
+ * - drivers/nvdimm/btt.c|1570| <<btt_blk_cleanup>> blk_cleanup_queue(btt->btt_queue);
+ * - drivers/nvdimm/pmem.c|341| <<pmem_pagemap_cleanup>> blk_cleanup_queue(q);
+ * - drivers/nvme/host/core.c|4009| <<nvme_alloc_ns>> blk_cleanup_queue(ns->queue);
+ * - drivers/nvme/host/core.c|4033| <<nvme_ns_remove>> blk_cleanup_queue(ns->queue);
+ * - drivers/nvme/host/fc.c|2359| <<nvme_fc_ctrl_free>> blk_cleanup_queue(ctrl->ctrl.connect_q);
+ * - drivers/nvme/host/fc.c|2369| <<nvme_fc_ctrl_free>> blk_cleanup_queue(ctrl->ctrl.admin_q);
+ * - drivers/nvme/host/fc.c|2370| <<nvme_fc_ctrl_free>> blk_cleanup_queue(ctrl->ctrl.fabrics_q);
+ * - drivers/nvme/host/fc.c|2831| <<nvme_fc_create_io_queues>> blk_cleanup_queue(ctrl->ctrl.connect_q);
+ * - drivers/nvme/host/fc.c|3568| <<nvme_fc_init_ctrl>> blk_cleanup_queue(ctrl->ctrl.admin_q);
+ * - drivers/nvme/host/fc.c|3570| <<nvme_fc_init_ctrl>> blk_cleanup_queue(ctrl->ctrl.fabrics_q);
+ * - drivers/nvme/host/multipath.c|402| <<nvme_mpath_alloc_disk>> blk_cleanup_queue(q);
+ * - drivers/nvme/host/multipath.c|695| <<nvme_mpath_remove_disk>> blk_cleanup_queue(head->disk->queue);
+ * - drivers/nvme/host/pci.c|1583| <<nvme_dev_remove_admin>> blk_cleanup_queue(dev->ctrl.admin_q);
+ * - drivers/nvme/host/rdma.c|833| <<nvme_rdma_destroy_admin_queue>> blk_cleanup_queue(ctrl->ctrl.admin_q);
+ * - drivers/nvme/host/rdma.c|834| <<nvme_rdma_destroy_admin_queue>> blk_cleanup_queue(ctrl->ctrl.fabrics_q);
+ * - drivers/nvme/host/rdma.c|924| <<nvme_rdma_configure_admin_queue>> blk_cleanup_queue(ctrl->ctrl.admin_q);
+ * - drivers/nvme/host/rdma.c|927| <<nvme_rdma_configure_admin_queue>> blk_cleanup_queue(ctrl->ctrl.fabrics_q);
+ * - drivers/nvme/host/rdma.c|946| <<nvme_rdma_destroy_io_queues>> blk_cleanup_queue(ctrl->ctrl.connect_q);
+ * - drivers/nvme/host/rdma.c|1001| <<nvme_rdma_configure_io_queues>> blk_cleanup_queue(ctrl->ctrl.connect_q);
+ * - drivers/nvme/host/tcp.c|1751| <<nvme_tcp_destroy_io_queues>> blk_cleanup_queue(ctrl->connect_q);
+ * - drivers/nvme/host/tcp.c|1806| <<nvme_tcp_configure_io_queues>> blk_cleanup_queue(ctrl->connect_q);
+ * - drivers/nvme/host/tcp.c|1819| <<nvme_tcp_destroy_admin_queue>> blk_cleanup_queue(ctrl->admin_q);
+ * - drivers/nvme/host/tcp.c|1820| <<nvme_tcp_destroy_admin_queue>> blk_cleanup_queue(ctrl->fabrics_q);
+ * - drivers/nvme/host/tcp.c|1874| <<nvme_tcp_configure_admin_queue>> blk_cleanup_queue(ctrl->admin_q);
+ * - drivers/nvme/host/tcp.c|1877| <<nvme_tcp_configure_admin_queue>> blk_cleanup_queue(ctrl->fabrics_q);
+ * - drivers/nvme/target/loop.c|256| <<nvme_loop_destroy_admin_queue>> blk_cleanup_queue(ctrl->ctrl.admin_q);
+ * - drivers/nvme/target/loop.c|257| <<nvme_loop_destroy_admin_queue>> blk_cleanup_queue(ctrl->ctrl.fabrics_q);
+ * - drivers/nvme/target/loop.c|273| <<nvme_loop_free_ctrl>> blk_cleanup_queue(ctrl->ctrl.connect_q);
+ * - drivers/nvme/target/loop.c|396| <<nvme_loop_configure_admin_queue>> blk_cleanup_queue(ctrl->ctrl.admin_q);
+ * - drivers/nvme/target/loop.c|398| <<nvme_loop_configure_admin_queue>> blk_cleanup_queue(ctrl->ctrl.fabrics_q);
+ * - drivers/nvme/target/loop.c|540| <<nvme_loop_create_io_queues>> blk_cleanup_queue(ctrl->ctrl.connect_q);
+ * - drivers/scsi/scsi_sysfs.c|1441| <<__scsi_remove_device>> blk_cleanup_queue(sdev->request_queue);
+ *
+ * blk_cleanup_queue - shutdown a request queue
+ * @q: request queue to shutdown
+ *
+ * Mark @q DYING, drain all pending requests, mark @q DEAD, destroy and
+ * put it. All future requests will be failed immediately with -ENODEV.
+ *
+ * Context: can sleep
+ */
void blk_cleanup_queue(struct request_queue *q)
{
/* cannot be called from atomic context */
@@ -392,6 +530,21 @@ void blk_cleanup_queue(struct request_queue *q)
/* @q won't process any more request, flush async actions */
del_timer_sync(&q->backing_dev_info->laptop_mode_wb_timer);
+ /*
+ * cancel any pending callbacks on a queue
+ *
+ * The block layer may perform asynchronous callback activity
+ * on a queue, such as calling the unplug function after a timeout.
+ * A block device may call blk_sync_queue to ensure that any
+ * such activity is cancelled, thus allowing it to release resources
+ * that the callbacks might use. The caller must already have made sure
+ * that its ->submit_bio will not re-add plugging prior to calling
+ * this function.
+ *
+ * This function does not cancel any asynchronous activity arising
+ * out of elevator or throttling code. That would require elevator_exit()
+ * and blkcg_exit_queue() to be called with queue lock initialized.
+ */
blk_sync_queue(q);
if (queue_is_mq(q))
@@ -422,6 +575,14 @@ EXPORT_SYMBOL(blk_cleanup_queue);
* @q: request queue pointer
* @flags: BLK_MQ_REQ_NOWAIT and/or BLK_MQ_REQ_PREEMPT
*/
+/*
+ * called by:
+ * - block/blk-core.c|551| <<bio_queue_enter>> ret = blk_queue_enter(q, nowait ? BLK_MQ_REQ_NOWAIT : 0);
+ * - block/blk-mq.c|554| <<blk_mq_alloc_request>> ret = blk_queue_enter(q, flags);
+ * - block/blk-mq.c|604| <<blk_mq_alloc_request_hctx>> ret = blk_queue_enter(q, flags);
+ * - fs/block_dev.c|696| <<bdev_read_page>> result = blk_queue_enter(bdev->bd_disk->queue, 0);
+ * - fs/block_dev.c|732| <<bdev_write_page>> result = blk_queue_enter(bdev->bd_disk->queue, 0);
+ */
int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags)
{
const bool pm = flags & BLK_MQ_REQ_PREEMPT;
@@ -459,6 +620,17 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags)
*/
smp_rmb();
+ /*
+ * 在以下使用request_queue->mq_freeze_wq:
+ * - block/blk-core.c|318| <<blk_clear_pm_only>> wake_up_all(&q->mq_freeze_wq);
+ * - block/blk-core.c|353| <<blk_set_queue_dying>> wake_up_all(&q->mq_freeze_wq);
+ * - block/blk-core.c|462| <<blk_queue_enter>> wait_event(q->mq_freeze_wq,
+ * - block/blk-core.c|512| <<blk_queue_usage_counter_release>> wake_up_all(&q->mq_freeze_wq);
+ * - block/blk-core.c|575| <<blk_alloc_queue>> init_waitqueue_head(&q->mq_freeze_wq);
+ * - block/blk-mq.c|157| <<blk_mq_freeze_queue_wait>> wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->q_usage_counter));
+ * - block/blk-mq.c|164| <<blk_mq_freeze_queue_wait_timeout>> return wait_event_timeout(q->mq_freeze_wq,
+ * - block/blk-mq.c|204| <<blk_mq_unfreeze_queue>> wake_up_all(&q->mq_freeze_wq);
+ */
wait_event(q->mq_freeze_wq,
(!q->mq_freeze_depth &&
(pm || (blk_pm_request_resume(q),
@@ -469,6 +641,11 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags)
}
}
+/*
+ * called by:
+ * - block/blk-core.c|1223| <<__submit_bio_noacct>> if (unlikely(bio_queue_enter(bio) != 0))
+ * - block/blk-core.c|1268| <<__submit_bio_noacct_mq>> if (unlikely(bio_queue_enter(bio) != 0))
+ */
static inline int bio_queue_enter(struct bio *bio)
{
struct request_queue *q = bio->bi_disk->queue;
@@ -486,6 +663,19 @@ static inline int bio_queue_enter(struct bio *bio)
return ret;
}
+/*
+ * called by:
+ * - block/blk-core.c|1089| <<__submit_bio>> blk_queue_exit(disk->queue);
+ * - block/blk-core.c|1175| <<__submit_bio_noacct_mq>> blk_queue_exit(disk->queue);
+ * - block/blk-mq-tag.c|453| <<blk_mq_queue_tag_busy_iter>> blk_queue_exit(q);
+ * - block/blk-mq.c|422| <<blk_mq_alloc_request>> blk_queue_exit(q);
+ * - block/blk-mq.c|481| <<blk_mq_alloc_request_hctx>> blk_queue_exit(q);
+ * - block/blk-mq.c|501| <<__blk_mq_free_request>> blk_queue_exit(q);
+ * - block/blk-mq.c|1012| <<blk_mq_timeout_work>> blk_queue_exit(q);
+ * - block/blk-mq.c|2264| <<blk_mq_submit_bio>> blk_queue_exit(q);
+ * - fs/block_dev.c|701| <<bdev_read_page>> blk_queue_exit(bdev->bd_disk->queue);
+ * - fs/block_dev.c|745| <<bdev_write_page>> blk_queue_exit(bdev->bd_disk->queue);
+ */
void blk_queue_exit(struct request_queue *q)
{
percpu_ref_put(&q->q_usage_counter);
@@ -496,6 +686,17 @@ static void blk_queue_usage_counter_release(struct percpu_ref *ref)
struct request_queue *q =
container_of(ref, struct request_queue, q_usage_counter);
+ /*
+ * 在以下使用request_queue->mq_freeze_wq:
+ * - block/blk-core.c|318| <<blk_clear_pm_only>> wake_up_all(&q->mq_freeze_wq);
+ * - block/blk-core.c|353| <<blk_set_queue_dying>> wake_up_all(&q->mq_freeze_wq);
+ * - block/blk-core.c|462| <<blk_queue_enter>> wait_event(q->mq_freeze_wq,
+ * - block/blk-core.c|512| <<blk_queue_usage_counter_release>> wake_up_all(&q->mq_freeze_wq);
+ * - block/blk-core.c|575| <<blk_alloc_queue>> init_waitqueue_head(&q->mq_freeze_wq);
+ * - block/blk-mq.c|157| <<blk_mq_freeze_queue_wait>> wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->q_usage_counter));
+ * - block/blk-mq.c|164| <<blk_mq_freeze_queue_wait_timeout>> return wait_event_timeout(q->mq_freeze_wq,
+ * - block/blk-mq.c|204| <<blk_mq_unfreeze_queue>> wake_up_all(&q->mq_freeze_wq);
+ */
wake_up_all(&q->mq_freeze_wq);
}
@@ -510,6 +711,30 @@ static void blk_timeout_work(struct work_struct *work)
{
}
+/*
+ * called by:
+ * - arch/m68k/emu/nfblock.c|122| <<nfhd_init_one>> dev->queue = blk_alloc_queue(NUMA_NO_NODE);
+ * - arch/xtensa/platforms/iss/simdisk.c|269| <<simdisk_setup>> dev->queue = blk_alloc_queue(NUMA_NO_NODE);
+ * - block/blk-mq.c|3251| <<blk_mq_init_queue_data>> uninit_q = blk_alloc_queue(set->numa_node);
+ * - drivers/block/brd.c|385| <<brd_alloc>> brd->brd_queue = blk_alloc_queue(NUMA_NO_NODE);
+ * - drivers/block/drbd/drbd_main.c|2749| <<drbd_create_device>> q = blk_alloc_queue(NUMA_NO_NODE);
+ * - drivers/block/null_blk_main.c|1812| <<null_add_dev>> nullb->q = blk_alloc_queue(dev->home_node);
+ * - drivers/block/pktcdvd.c|2753| <<pkt_setup_dev>> disk->queue = blk_alloc_queue(NUMA_NO_NODE);
+ * - drivers/block/ps3vram.c|739| <<ps3vram_probe>> queue = blk_alloc_queue(NUMA_NO_NODE);
+ * - drivers/block/rsxx/dev.c|239| <<rsxx_setup_dev>> card->queue = blk_alloc_queue(NUMA_NO_NODE);
+ * - drivers/block/umem.c|890| <<mm_pci_probe>> card->queue = blk_alloc_queue(NUMA_NO_NODE);
+ * - drivers/block/zram/zram_drv.c|1895| <<zram_add>> queue = blk_alloc_queue(NUMA_NO_NODE);
+ * - drivers/lightnvm/core.c|379| <<nvm_create_tgt>> tqueue = blk_alloc_queue(dev->q->node);
+ * - drivers/md/bcache/super.c|943| <<bcache_device_init>> q = blk_alloc_queue(NUMA_NO_NODE);
+ * - drivers/md/dm.c|1944| <<alloc_dev>> md->queue = blk_alloc_queue(numa_node_id);
+ * - drivers/md/md.c|5708| <<md_alloc>> mddev->queue = blk_alloc_queue(NUMA_NO_NODE);
+ * - drivers/nvdimm/blk.c|254| <<nsblk_attach_disk>> q = blk_alloc_queue(NUMA_NO_NODE);
+ * - drivers/nvdimm/btt.c|1525| <<btt_blk_init>> btt->btt_queue = blk_alloc_queue(NUMA_NO_NODE);
+ * - drivers/nvdimm/pmem.c|425| <<pmem_attach_disk>> q = blk_alloc_queue(dev_to_node(dev));
+ * - drivers/nvme/host/multipath.c|377| <<nvme_mpath_alloc_disk>> q = blk_alloc_queue(ctrl->numa_node);
+ * - drivers/s390/block/dcssblk.c|654| <<dcssblk_add_store>> dev_info->dcssblk_queue = blk_alloc_queue(NUMA_NO_NODE);
+ * - drivers/s390/block/xpram.c|347| <<xpram_setup_blkdev>> xpram_queues[i] = blk_alloc_queue(NUMA_NO_NODE);
+ */
struct request_queue *blk_alloc_queue(int node_id)
{
struct request_queue *q;
@@ -750,6 +975,10 @@ bool bio_attempt_discard_merge(struct request_queue *q, struct request *req,
*
* Caller must ensure !blk_queue_nomerges(q) beforehand.
*/
+/*
+ * called by:
+ * - block/blk-mq.c|2375| <<blk_mq_submit_bio>> blk_attempt_plug_merge(q, bio, nr_segs, &same_queue_rq))
+ */
bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
unsigned int nr_segs, struct request **same_queue_rq)
{
@@ -820,6 +1049,12 @@ static int __init setup_fail_make_request(char *str)
}
__setup("fail_make_request=", setup_fail_make_request);
+/*
+ * called by:
+ * - block/blk-core.c|1095| <<should_fail_bio>> if (should_fail_request(&bio->bi_disk->part0, bio->bi_iter.bi_size))
+ * - block/blk-core.c|1135| <<blk_partition_remap>> if (unlikely(should_fail_request(p, bio->bi_iter.bi_size)))
+ * - block/blk-core.c|1580| <<blk_insert_cloned_request>> should_fail_request(&rq->rq_disk->part0, blk_rq_bytes(rq)))
+ */
static bool should_fail_request(struct hd_struct *part, unsigned int bytes)
{
return part->make_it_fail && should_fail(&fail_make_request, bytes);
@@ -894,6 +1129,10 @@ static inline int bio_check_eod(struct bio *bio, sector_t maxsector)
/*
* Remap block n of partition p to block n+start(p) of the disk.
*/
+/*
+ * called by:
+ * - block/blk-core.c|1208| <<submit_bio_checks>> if (unlikely(blk_partition_remap(bio)))
+ */
static inline int blk_partition_remap(struct bio *bio)
{
struct hd_struct *p;
@@ -957,6 +1196,10 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
return BLK_STS_OK;
}
+/*
+ * called by:
+ * - block/blk-core.c|1423| <<submit_bio_noacct>> if (!submit_bio_checks(bio))
+ */
static noinline_for_stack bool submit_bio_checks(struct bio *bio)
{
struct request_queue *q = bio->bi_disk->queue;
@@ -1076,6 +1319,10 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)
return false;
}
+/*
+ * called by:
+ * - block/blk-core.c|1368| <<__submit_bio_noacct>> ret = __submit_bio(bio);
+ */
static blk_qc_t __submit_bio(struct bio *bio)
{
struct gendisk *disk = bio->bi_disk;
@@ -1109,6 +1356,10 @@ static blk_qc_t __submit_bio(struct bio *bio)
* bio_list_on_stack[1] contains bios that were submitted before the current
* ->submit_bio_bio, but that haven't been processed yet.
*/
+/*
+ * called by:
+ * - block/blk-core.c|1447| <<submit_bio_noacct>> return __submit_bio_noacct(bio);
+ */
static blk_qc_t __submit_bio_noacct(struct bio *bio)
{
struct bio_list bio_list_on_stack[2];
@@ -1268,6 +1519,12 @@ blk_qc_t submit_bio(struct bio *bio)
* the submitting cgroup IO-throttled, submission can be a significant
* part of overall IO time.
*/
+ /*
+ * 在以下使用BIO_WORKINGSET:
+ * - block/bio.c|920| <<__bio_add_page>> if (!bio_flagged(bio, BIO_WORKINGSET) && unlikely(PageWorkingset(page)))
+ * - block/bio.c|921| <<__bio_add_page>> bio_set_flag(bio, BIO_WORKINGSET);
+ * - block/blk-core.c|1505| <<submit_bio>> bio_flagged(bio, BIO_WORKINGSET))) {
+ */
if (unlikely(bio_op(bio) == REQ_OP_READ &&
bio_flagged(bio, BIO_WORKINGSET))) {
unsigned long pflags;
@@ -1499,6 +1756,10 @@ EXPORT_SYMBOL(disk_end_io_acct);
* Steal bios from a request and add them to a bio list.
* The request must not have been partially completed before.
*/
+/*
+ * called by:
+ * - drivers/nvme/host/multipath.c|87| <<nvme_failover_req>> blk_steal_bios(&ns->head->requeue_list, req);
+ */
void blk_steal_bios(struct bio_list *list, struct request *rq)
{
if (rq->bio) {
@@ -1542,6 +1803,13 @@ EXPORT_SYMBOL_GPL(blk_steal_bios);
* %false - this request doesn't have any more data
* %true - this request has more data
**/
+/*
+ * 调用的例子:
+ * - block/blk-mq.c|710| <<blk_mq_end_request>> if (blk_update_request(rq, error, blk_rq_bytes(rq)))
+ * - drivers/block/loop.c|486| <<lo_complete_rq>> blk_update_request(rq, BLK_STS_OK, cmd->ret);
+ * - drivers/md/dm-rq.c|120| <<end_clone_bio>> blk_update_request(tio->orig, BLK_STS_OK, tio->completed);
+ * - drivers/scsi/scsi_lib.c|566| <<scsi_end_request>> if (blk_update_request(req, error, bytes))
+ */
bool blk_update_request(struct request *req, blk_status_t error,
unsigned int nr_bytes)
{
@@ -1758,12 +2026,32 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
}
EXPORT_SYMBOL_GPL(blk_rq_prep_clone);
+/*
+ * called by:
+ * - block/blk-core.c|559| <<blk_rq_timed_out_timer>> kblockd_schedule_work(&q->timeout_work);
+ * - block/blk-timeout.c|87| <<blk_abort_request>> kblockd_schedule_work(&req->q->timeout_work);
+ * - drivers/ide/ide-io.c|907| <<ide_insert_request_head>> kblockd_schedule_work(&drive->rq_work);
+ * - drivers/ide/ide-probe.c|1183| <<drive_rq_insert_work>> kblockd_schedule_work(&drive->rq_work);
+ * - drivers/nvme/host/multipath.c|91| <<nvme_failover_req>> kblockd_schedule_work(&ns->head->requeue_work);
+ * - drivers/nvme/host/multipath.c|101| <<nvme_kick_requeue_lists>> kblockd_schedule_work(&ns->head->requeue_work);
+ * - drivers/nvme/host/multipath.c|142| <<nvme_mpath_clear_ctrl_paths>> kblockd_schedule_work(&ns->head->requeue_work);
+ * - drivers/nvme/host/multipath.c|430| <<nvme_mpath_set_live>> kblockd_schedule_work(&head->requeue_work);
+ * - drivers/nvme/host/multipath.c|693| <<nvme_mpath_remove_disk>> kblockd_schedule_work(&head->requeue_work);
+ * - drivers/nvme/host/nvme.h|673| <<nvme_mpath_check_last_path>> kblockd_schedule_work(&head->requeue_work);
+ * - drivers/scsi/scsi_lib.c|553| <<scsi_run_queue_async>> kblockd_schedule_work(&sdev->requeue_work);
+ */
int kblockd_schedule_work(struct work_struct *work)
{
return queue_work(kblockd_workqueue, work);
}
EXPORT_SYMBOL(kblockd_schedule_work);
+/*
+ * called by:
+ * - block/blk-mq.c|1051| <<blk_mq_kick_requeue_list>> kblockd_mod_delayed_work_on(WORK_CPU_UNBOUND, &q->requeue_work, 0);
+ * - block/blk-mq.c|1058| <<blk_mq_delay_kick_requeue_list>> kblockd_mod_delayed_work_on(WORK_CPU_UNBOUND, &q->requeue_work,
+ * - block/blk-mq.c|1839| <<__blk_mq_delay_run_hw_queue>> kblockd_mod_delayed_work_on(blk_mq_hctx_next_cpu(hctx), &hctx->run_work,
+ */
int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork,
unsigned long delay)
{
@@ -1888,6 +2176,14 @@ void blk_finish_plug(struct blk_plug *plug)
}
EXPORT_SYMBOL(blk_finish_plug);
+/*
+ * called by:
+ * - fs/block_dev.c|247| <<__blkdev_direct_IO_simple>> blk_io_schedule();
+ * - fs/block_dev.c|441| <<__blkdev_direct_IO>> blk_io_schedule();
+ * - fs/direct-io.c|503| <<dio_await_one>> blk_io_schedule();
+ * - fs/iomap/direct-io.c|572| <<iomap_dio_rw>> blk_io_schedule();
+ * - mm/page_io.c|444| <<swap_readpage>> blk_io_schedule();
+ */
void blk_io_schedule(void)
{
/* Prevent hang_check timer from firing at us during very long I/O */
@@ -1900,6 +2196,10 @@ void blk_io_schedule(void)
}
EXPORT_SYMBOL_GPL(blk_io_schedule);
+/*
+ * called by:
+ * - block/genhd.c|1229| <<genhd_device_init>> blk_dev_init();
+ */
int __init blk_dev_init(void)
{
BUILD_BUG_ON(REQ_OP_LAST >= (1 << REQ_OP_BITS));
diff --git a/block/blk-crypto-internal.h b/block/blk-crypto-internal.h
index d2b0f565d83c..146b6120d1af 100644
--- a/block/blk-crypto-internal.h
+++ b/block/blk-crypto-internal.h
@@ -128,6 +128,11 @@ static inline bool blk_crypto_bio_prep(struct bio **bio_ptr)
}
blk_status_t __blk_crypto_init_request(struct request *rq);
+/*
+ * called by:
+ * - block/blk-crypto-internal.h|165| <<blk_crypto_insert_cloned_request>> return blk_crypto_init_request(rq);
+ * - block/blk-mq.c|2400| <<blk_mq_submit_bio>> ret = blk_crypto_init_request(rq);
+ */
static inline blk_status_t blk_crypto_init_request(struct request *rq)
{
if (blk_crypto_rq_is_encrypted(rq))
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index d37b55db2409..298e72f08506 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -1718,6 +1718,9 @@ static u64 calc_size_vtime_cost(struct request *rq, struct ioc *ioc)
return cost;
}
+/*
+ * struct rq_qos_ops ioc_rqos_ops.throttle = ioc_rqos_throttle()
+ */
static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)
{
struct blkcg_gq *blkg = bio->bi_blkg;
@@ -1844,6 +1847,9 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)
finish_wait(&iocg->waitq, &wait.wait);
}
+/*
+ * struct rq_qos_ops ioc_rqos_ops.merge = ioc_rqos_merge()
+ */
static void ioc_rqos_merge(struct rq_qos *rqos, struct request *rq,
struct bio *bio)
{
@@ -1897,6 +1903,9 @@ static void ioc_rqos_merge(struct rq_qos *rqos, struct request *rq,
spin_unlock_irqrestore(&iocg->waitq.lock, flags);
}
+/*
+ * struct rq_qos_ops ioc_rqos_ops.done_bio = ioc_rqos_done_bio()
+ */
static void ioc_rqos_done_bio(struct rq_qos *rqos, struct bio *bio)
{
struct ioc_gq *iocg = blkg_to_iocg(bio->bi_blkg);
@@ -1905,6 +1914,9 @@ static void ioc_rqos_done_bio(struct rq_qos *rqos, struct bio *bio)
atomic64_add(bio->bi_iocost_cost, &iocg->done_vtime);
}
+/*
+ * struct rq_qos_ops ioc_rqos_ops.done = ioc_rqos_done()
+ */
static void ioc_rqos_done(struct rq_qos *rqos, struct request *rq)
{
struct ioc *ioc = rqos_to_ioc(rqos);
@@ -1940,6 +1952,9 @@ static void ioc_rqos_done(struct rq_qos *rqos, struct request *rq)
this_cpu_add(ioc->pcpu_stat->rq_wait_ns, rq_wait_ns);
}
+/*
+ * struct rq_qos_ops ioc_rqos_ops.queue_depth_changed = ioc_rqos_queue_depth_changed()
+ */
static void ioc_rqos_queue_depth_changed(struct rq_qos *rqos)
{
struct ioc *ioc = rqos_to_ioc(rqos);
@@ -1949,6 +1964,9 @@ static void ioc_rqos_queue_depth_changed(struct rq_qos *rqos)
spin_unlock_irq(&ioc->lock);
}
+/*
+ * struct rq_qos_ops ioc_rqos_ops.exit = ioc_rqos_exit()
+ */
static void ioc_rqos_exit(struct rq_qos *rqos)
{
struct ioc *ioc = rqos_to_ioc(rqos);
@@ -1964,6 +1982,10 @@ static void ioc_rqos_exit(struct rq_qos *rqos)
kfree(ioc);
}
+/*
+ * 在以下使用ioc_rqos_ops:
+ * - block/blk-iocost.c|1994| <<blk_iocost_init>> rqos->ops = &ioc_rqos_ops;
+ */
static struct rq_qos_ops ioc_rqos_ops = {
.throttle = ioc_rqos_throttle,
.merge = ioc_rqos_merge,
@@ -1973,6 +1995,11 @@ static struct rq_qos_ops ioc_rqos_ops = {
.exit = ioc_rqos_exit,
};
+/*
+ * called by:
+ * - block/blk-iocost.c|2262| <<ioc_qos_write>> ret = blk_iocost_init(disk->queue);
+ * - block/blk-iocost.c|2429| <<ioc_cost_model_write>> ret = blk_iocost_init(disk->queue);
+ */
static int blk_iocost_init(struct request_queue *q)
{
struct ioc *ioc;
@@ -2514,6 +2541,19 @@ static struct cftype ioc_files[] = {
{}
};
+/*
+ * 在以下使用blkcg_policy_iocost:
+ * - block/blk-iocost.c|639| <<blkg_to_iocg>> return pd_to_iocg(blkg_to_pd(blkg, &blkcg_policy_iocost));
+ * - block/blk-iocost.c|649| <<blkcg_to_iocc>> return container_of(blkcg_to_cpd(blkcg, &blkcg_policy_iocost),
+ * - block/blk-iocost.c|1956| <<ioc_rqos_exit>> blkcg_deactivate_policy(rqos->q, &blkcg_policy_iocost);
+ * - block/blk-iocost.c|2014| <<blk_iocost_init>> ret = blkcg_activate_policy(q, &blkcg_policy_iocost);
+ * - block/blk-iocost.c|2130| <<ioc_weight_show>> &blkcg_policy_iocost, seq_cft(sf)->private, false);
+ * - block/blk-iocost.c|2169| <<ioc_weight_write>> ret = blkg_conf_prep(blkcg, &blkcg_policy_iocost, buf, &ctx);
+ * - block/blk-iocost.c|2226| <<ioc_qos_show>> &blkcg_policy_iocost, seq_cft(sf)->private, false);
+ * - block/blk-iocost.c|2393| <<ioc_cost_model_show>> &blkcg_policy_iocost, seq_cft(sf)->private, false);
+ * - block/blk-iocost.c|2528| <<ioc_init>> return blkcg_policy_register(&blkcg_policy_iocost);
+ * - block/blk-iocost.c|2533| <<ioc_exit>> return blkcg_policy_unregister(&blkcg_policy_iocost);
+ */
static struct blkcg_policy blkcg_policy_iocost = {
.dfl_cftypes = ioc_files,
.cpd_alloc_fn = ioc_cpd_alloc,
@@ -2525,6 +2565,13 @@ static struct blkcg_policy blkcg_policy_iocost = {
static int __init ioc_init(void)
{
+ /*
+ * 在以下调用blkcg_policy_register():
+ * - block/bfq-iosched.c|6812| <<bfq_init>> ret = blkcg_policy_register(&blkcg_policy_bfq);
+ * - block/blk-iocost.c|2528| <<ioc_init>> return blkcg_policy_register(&blkcg_policy_iocost);
+ * - block/blk-iolatency.c|1044| <<iolatency_init>> return blkcg_policy_register(&blkcg_policy_iolatency);
+ * - block/blk-throttle.c|2477| <<throtl_init>> return blkcg_policy_register(&blkcg_policy_throtl);
+ */
return blkcg_policy_register(&blkcg_policy_iocost);
}
diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
index f90429cf4edf..3092e9a6d024 100644
--- a/block/blk-iolatency.c
+++ b/block/blk-iolatency.c
@@ -715,6 +715,10 @@ static void blkiolatency_timer_fn(struct timer_list *t)
rcu_read_unlock();
}
+/*
+ * called by:
+ * - block/blk-cgroup.c|1173| <<blkcg_init_queue>> ret = blk_iolatency_init(q);
+ */
int blk_iolatency_init(struct request_queue *q)
{
struct blk_iolatency *blkiolat;
@@ -935,6 +939,39 @@ static size_t iolatency_pd_stat(struct blkg_policy_data *pd, char *buf,
}
+/*
+ * [0] iolatency_pd_alloc
+ * [0] blkg_alloc
+ * [0] blkg_conf_prep
+ * [0] tg_set_conf.constprop.31
+ * [0] cgroup_file_write