block/blk.h
Source file repositories/reference/linux-study-clean/block/blk.h
File Facts
- System
- Linux kernel
- Corpus path
block/blk.h- Extension
.h- Size
- 24854 bytes
- Lines
- 814
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bio-integrity.hlinux/blk-crypto.hlinux/part_stat.hlinux/lockdep.hlinux/memblock.hlinux/sched/sysctl.hlinux/timekeeping.hxen/xen.hblk-crypto-internal.h
Detected Declarations
struct elv_change_ctxstruct blk_flush_queueenum bio_merge_statusfunction blk_try_enter_queuefunction bio_queue_enterfunction blk_wait_iofunction biovec_phys_mergeablefunction iteratorfunction __bvec_gap_to_prevfunction bvec_gap_to_prevfunction rq_mergeablefunction blk_discard_mergablefunction blk_rq_get_max_segmentsfunction blk_queue_get_max_sectorsfunction bio_integrity_endiofunction integrity_req_gap_back_mergefunction integrity_req_gap_front_mergefunction blk_integrity_merge_rqfunction blk_integrity_merge_biofunction integrity_req_gap_back_mergefunction integrity_req_gap_front_mergefunction blk_flush_integrityfunction bio_integrity_freefunction bio_may_need_splitfunction get_max_segment_sizefunction req_set_nomergefunction bdev_inc_in_flightfunction bdev_dec_in_flightfunction ioc_clear_queuefunction bio_zone_write_pluggingfunction blk_req_bio_is_zone_appendfunction blk_zone_bio_endiofunction blk_zone_finish_requestfunction disk_init_zone_resourcesfunction blk_req_bio_is_zone_appendfunction blk_zone_write_plug_bio_mergedfunction blkdev_zone_mgmt_ioctlfunction should_fail_requestfunction abc54d634334function req_ref_put_and_testfunction req_ref_setfunction req_ref_readfunction blk_time_get_nsfunction ktime_get_nsfunction blk_time_getfunction blk_freeze_acquire_lockfunction blk_unfreeze_release_lockfunction blk_freeze_acquire_lock
Annotated Snippet
struct blk_flush_queue {
spinlock_t mq_flush_lock;
unsigned int flush_pending_idx:1;
unsigned int flush_running_idx:1;
blk_status_t rq_status;
unsigned long flush_pending_since;
struct list_head flush_queue[2];
unsigned long flush_data_in_flight;
struct request *flush_rq;
struct rcu_head rcu_head;
};
bool is_flush_rq(struct request *req);
struct blk_flush_queue *blk_alloc_flush_queue(int node, int cmd_size,
gfp_t flags);
void blk_free_flush_queue(struct blk_flush_queue *q);
const char *blk_status_to_str(blk_status_t status);
const char *blk_status_to_tag(blk_status_t status);
blk_status_t tag_to_blk_status(const char *tag);
enum req_op str_to_blk_op(const char *op);
bool __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic);
bool blk_queue_start_drain(struct request_queue *q);
bool __blk_freeze_queue_start(struct request_queue *q,
struct task_struct *owner);
int __bio_queue_enter(struct request_queue *q, struct bio *bio);
void submit_bio_noacct_nocheck(struct bio *bio, bool split);
int bio_submit_or_kill(struct bio *bio, unsigned int flags);
static inline bool blk_try_enter_queue(struct request_queue *q, bool pm)
{
rcu_read_lock();
if (!percpu_ref_tryget_live_rcu(&q->q_usage_counter))
goto fail;
/*
* The code that increments the pm_only counter must ensure that the
* counter is globally visible before the queue is unfrozen.
*/
if (blk_queue_pm_only(q) &&
(!pm || queue_rpm_status(q) == RPM_SUSPENDED))
goto fail_put;
rcu_read_unlock();
return true;
fail_put:
blk_queue_exit(q);
fail:
rcu_read_unlock();
return false;
}
static inline int bio_queue_enter(struct bio *bio)
{
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
if (blk_try_enter_queue(q, false)) {
rwsem_acquire_read(&q->io_lockdep_map, 0, 0, _RET_IP_);
rwsem_release(&q->io_lockdep_map, _RET_IP_);
return 0;
}
return __bio_queue_enter(q, bio);
}
static inline void blk_wait_io(struct completion *done)
{
/* Prevent hang_check timer from firing at us during very long I/O */
unsigned long timeout = sysctl_hung_task_timeout_secs * HZ / 2;
if (timeout)
while (!wait_for_completion_io_timeout(done, timeout))
;
else
wait_for_completion_io(done);
}
struct block_device *blkdev_get_no_open(dev_t dev, bool autoload);
void blkdev_put_no_open(struct block_device *bdev);
bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv,
struct page *page, unsigned len, unsigned offset);
static inline bool biovec_phys_mergeable(struct request_queue *q,
struct bio_vec *vec1, struct bio_vec *vec2)
{
unsigned long mask = queue_segment_boundary(q);
phys_addr_t addr1 = bvec_phys(vec1);
Annotation
- Immediate include surface: `linux/bio-integrity.h`, `linux/blk-crypto.h`, `linux/part_stat.h`, `linux/lockdep.h`, `linux/memblock.h`, `linux/sched/sysctl.h`, `linux/timekeeping.h`, `xen/xen.h`.
- Detected declarations: `struct elv_change_ctx`, `struct blk_flush_queue`, `enum bio_merge_status`, `function blk_try_enter_queue`, `function bio_queue_enter`, `function blk_wait_io`, `function biovec_phys_mergeable`, `function iterator`, `function __bvec_gap_to_prev`, `function bvec_gap_to_prev`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.