drivers/block/drbd/drbd_worker.c
Source file repositories/reference/linux-study-clean/drivers/block/drbd/drbd_worker.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/block/drbd/drbd_worker.c- Extension
.c- Size
- 65438 bytes
- Lines
- 2224
- Domain
- Driver Families
- Bucket
- drivers/block
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- 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/module.hlinux/drbd.hlinux/sched/signal.hlinux/wait.hlinux/mm.hlinux/memcontrol.hlinux/mm_inline.hlinux/slab.hlinux/random.hlinux/string.hlinux/scatterlist.hlinux/part_stat.hdrbd_int.hdrbd_protocol.hdrbd_req.h
Detected Declarations
function drbd_md_endiofunction drbd_endio_read_sec_finalfunction drbd_endio_write_sec_finalfunction drbd_peer_request_endiofunction drbd_panic_after_delayed_completion_of_aborted_requestfunction drbd_request_endiofunction panicfunction drbd_csum_eefunction drbd_csum_biofunction bio_for_each_segmentfunction w_e_send_csumfunction read_for_csumfunction w_resync_timerfunction resync_timer_fnfunction fifo_setfunction fifo_pushfunction fifo_add_valfunction drbd_rs_controllerfunction drbd_rs_number_requestsfunction make_resync_requestfunction make_ov_requestfunction w_ov_finishedfunction w_resync_finishedfunction ping_peerfunction drbd_resync_finishedfunction thefunction idr_for_each_entryfunction w_e_end_data_reqfunction all_zerofunction page_chain_for_eachfunction w_e_end_rsdata_reqfunction w_e_end_csum_rs_reqfunction w_e_end_ov_reqfunction drbd_ov_out_of_sync_foundfunction w_e_end_ov_replyfunction drbd_send_barrierfunction pd_send_unplug_remotefunction w_send_write_hintfunction re_init_if_first_writefunction maybe_send_barrierfunction w_send_out_of_syncfunction w_send_dblockfunction w_send_read_reqfunction w_restart_disk_iofunction _drbd_may_sync_nowfunction drbd_pause_afterfunction drbd_resume_nextfunction resume_next_sg
Annotated Snippet
switch (bio_op(bio)) {
case REQ_OP_WRITE_ZEROES:
case REQ_OP_DISCARD:
if (bio->bi_status == BLK_STS_NOTSUPP)
what = DISCARD_COMPLETED_NOTSUPP;
else
what = DISCARD_COMPLETED_WITH_ERROR;
break;
case REQ_OP_READ:
if (bio->bi_opf & REQ_RAHEAD)
what = READ_AHEAD_COMPLETED_WITH_ERROR;
else
what = READ_COMPLETED_WITH_ERROR;
break;
default:
what = WRITE_COMPLETED_WITH_ERROR;
break;
}
} else {
what = COMPLETED_OK;
}
req->private_bio = ERR_PTR(blk_status_to_errno(bio->bi_status));
bio_put(bio);
/* not req_mod(), we need irqsave here! */
spin_lock_irqsave(&device->resource->req_lock, flags);
__req_mod(req, what, NULL, &m);
spin_unlock_irqrestore(&device->resource->req_lock, flags);
put_ldev(device);
if (m.bio)
complete_master_bio(device, &m);
}
void drbd_csum_ee(struct crypto_shash *tfm, struct drbd_peer_request *peer_req, void *digest)
{
SHASH_DESC_ON_STACK(desc, tfm);
struct page *page = peer_req->pages;
struct page *tmp;
unsigned len;
void *src;
desc->tfm = tfm;
crypto_shash_init(desc);
src = kmap_atomic(page);
while ((tmp = page_chain_next(page))) {
/* all but the last page will be fully used */
crypto_shash_update(desc, src, PAGE_SIZE);
kunmap_atomic(src);
page = tmp;
src = kmap_atomic(page);
}
/* and now the last, possibly only partially used page */
len = peer_req->i.size & (PAGE_SIZE - 1);
crypto_shash_update(desc, src, len ?: PAGE_SIZE);
kunmap_atomic(src);
crypto_shash_final(desc, digest);
shash_desc_zero(desc);
}
void drbd_csum_bio(struct crypto_shash *tfm, struct bio *bio, void *digest)
{
SHASH_DESC_ON_STACK(desc, tfm);
struct bio_vec bvec;
struct bvec_iter iter;
desc->tfm = tfm;
crypto_shash_init(desc);
bio_for_each_segment(bvec, bio, iter) {
u8 *src;
src = bvec_kmap_local(&bvec);
crypto_shash_update(desc, src, bvec.bv_len);
kunmap_local(src);
}
crypto_shash_final(desc, digest);
shash_desc_zero(desc);
}
/* MAYBE merge common code with w_e_end_ov_req */
static int w_e_send_csum(struct drbd_work *w, int cancel)
{
struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w);
struct drbd_peer_device *peer_device = peer_req->peer_device;
Annotation
- Immediate include surface: `linux/module.h`, `linux/drbd.h`, `linux/sched/signal.h`, `linux/wait.h`, `linux/mm.h`, `linux/memcontrol.h`, `linux/mm_inline.h`, `linux/slab.h`.
- Detected declarations: `function drbd_md_endio`, `function drbd_endio_read_sec_final`, `function drbd_endio_write_sec_final`, `function drbd_peer_request_endio`, `function drbd_panic_after_delayed_completion_of_aborted_request`, `function drbd_request_endio`, `function panic`, `function drbd_csum_ee`, `function drbd_csum_bio`, `function bio_for_each_segment`.
- Atlas domain: Driver Families / drivers/block.
- Implementation status: source 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.