block/blk-core.c
Source file repositories/reference/linux-study-clean/block/blk-core.c
File Facts
- System
- Linux kernel
- Corpus path
block/blk-core.c- Extension
.c- Size
- 36831 bytes
- Lines
- 1337
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/bio.hlinux/blkdev.hlinux/blk-pm.hlinux/blk-integrity.hlinux/highmem.hlinux/mm.hlinux/pagemap.hlinux/kernel_stat.hlinux/string.hlinux/init.hlinux/completion.hlinux/slab.hlinux/swap.hlinux/writeback.hlinux/task_io_accounting_ops.hlinux/fault-inject.hlinux/list_sort.hlinux/delay.hlinux/ratelimit.hlinux/pm_runtime.hlinux/t10-pi.hlinux/debugfs.hlinux/bpf.hlinux/part_stat.hlinux/sched/sysctl.hlinux/blk-crypto.htrace/events/block.hblk.hblk-mq-sched.hblk-pm.h
Detected Declarations
function blk_queue_flag_setfunction blk_queue_flag_clearfunction str_to_blk_opfunction errno_to_blk_statusfunction blk_status_to_errnofunction tag_to_blk_statusfunction blkcg_exit_queuefunction blk_set_pm_onlyfunction blk_clear_pm_onlyfunction blk_free_queue_rcufunction blk_free_queuefunction blk_put_queuefunction blk_queue_start_drainfunction blk_queue_enterfunction __bio_queue_enterfunction blk_queue_exitfunction blk_queue_usage_counter_releasefunction blk_rq_timed_out_timerfunction blk_timeout_workfunction blk_get_queuefunction setup_fail_make_requestfunction should_fail_requestfunction fail_make_request_debugfsfunction bio_check_rofunction should_fail_biofunction bio_check_eodfunction blk_partition_remapfunction blk_check_zone_appendfunction __submit_biofunction __submit_bio_noacctfunction __submit_bio_noacct_mqfunction submit_bio_noacct_nocheckfunction blk_validate_atomic_write_op_sizefunction submit_biofunction bio_set_iopriofunction submit_biofunction bio_pollfunction iocb_bio_iopollfunction update_io_ticksfunction bdev_start_io_acctfunction bio_end_io_acctfunction bdev_end_io_acctfunction bio_end_io_acct_remappedfunction blk_queue_lld_busyfunction kblockd_schedule_workfunction kblockd_mod_delayed_work_onfunction blk_start_plug_nr_iosfunction blk_start_plug
Annotated Snippet
blk_mq_submit_bio(bio);
} else if (likely(bio_queue_enter(bio) == 0)) {
struct gendisk *disk = bio->bi_bdev->bd_disk;
if ((bio->bi_opf & REQ_POLLED) &&
!(disk->queue->limits.features & BLK_FEAT_POLL))
bio_endio_status(bio, BLK_STS_NOTSUPP);
else
disk->fops->submit_bio(bio);
blk_queue_exit(disk->queue);
}
blk_finish_plug(&plug);
}
/*
* The loop in this function may be a bit non-obvious, and so deserves some
* explanation:
*
* - Before entering the loop, bio->bi_next is NULL (as all callers ensure
* that), so we have a list with a single bio.
* - We pretend that we have just taken it off a longer list, so we assign
* bio_list to a pointer to the bio_list_on_stack, thus initialising the
* bio_list of new bios to be added. ->submit_bio() may indeed add some more
* bios through a recursive call to submit_bio_noacct. If it did, we find a
* non-NULL value in bio_list and re-enter the loop from the top.
* - In this case we really did just take the bio off the top of the list (no
* pretending) and so remove it from bio_list, and call into ->submit_bio()
* again.
*
* bio_list_on_stack[0] contains bios submitted by the current ->submit_bio.
* bio_list_on_stack[1] contains bios that were submitted before the current
* ->submit_bio(), but that haven't been processed yet.
*/
static void __submit_bio_noacct(struct bio *bio)
{
struct bio_list bio_list_on_stack[2];
BUG_ON(bio->bi_next);
bio_list_init(&bio_list_on_stack[0]);
current->bio_list = bio_list_on_stack;
do {
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
struct bio_list lower, same;
/*
* Create a fresh bio_list for all subordinate requests.
*/
bio_list_on_stack[1] = bio_list_on_stack[0];
bio_list_init(&bio_list_on_stack[0]);
__submit_bio(bio);
/*
* Sort new bios into those for a lower level and those for the
* same level.
*/
bio_list_init(&lower);
bio_list_init(&same);
while ((bio = bio_list_pop(&bio_list_on_stack[0])) != NULL)
if (q == bdev_get_queue(bio->bi_bdev))
bio_list_add(&same, bio);
else
bio_list_add(&lower, bio);
/*
* Now assemble so we handle the lowest level first.
*/
bio_list_merge(&bio_list_on_stack[0], &lower);
bio_list_merge(&bio_list_on_stack[0], &same);
bio_list_merge(&bio_list_on_stack[0], &bio_list_on_stack[1]);
} while ((bio = bio_list_pop(&bio_list_on_stack[0])));
current->bio_list = NULL;
}
static void __submit_bio_noacct_mq(struct bio *bio)
{
struct bio_list bio_list[2] = { };
current->bio_list = bio_list;
do {
__submit_bio(bio);
} while ((bio = bio_list_pop(&bio_list[0])));
current->bio_list = NULL;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/bio.h`, `linux/blkdev.h`, `linux/blk-pm.h`, `linux/blk-integrity.h`, `linux/highmem.h`, `linux/mm.h`.
- Detected declarations: `function blk_queue_flag_set`, `function blk_queue_flag_clear`, `function str_to_blk_op`, `function errno_to_blk_status`, `function blk_status_to_errno`, `function tag_to_blk_status`, `function blkcg_exit_queue`, `function blk_set_pm_only`, `function blk_clear_pm_only`, `function blk_free_queue_rcu`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.