drivers/md/dm-zoned-target.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-zoned-target.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-zoned-target.c- Extension
.c- Size
- 28452 bytes
- Lines
- 1161
- Domain
- Driver Families
- Bucket
- drivers/md
- 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
dm-zoned.hlinux/module.h
Detected Declarations
struct dmz_bioctxstruct dm_chunk_workstruct dmz_targetfunction intervalsfunction dmz_clone_endiofunction dmz_submit_biofunction dmz_handle_read_zerofunction dmz_handle_readfunction dmz_handle_direct_writefunction dmz_handle_buffered_writefunction dmz_handle_writefunction dmz_handle_discardfunction dmz_handle_biofunction dmz_get_chunk_workfunction dmz_put_chunk_workfunction dmz_chunk_workfunction dmz_flush_workfunction dmz_queue_chunk_workfunction dmz_bdev_is_dyingfunction dmz_bdev_is_dyingfunction dmz_mapfunction dmz_get_zoned_devicefunction dmz_put_zoned_devicesfunction dmz_fixup_devicesfunction dmz_ctrfunction dmz_dtrfunction dmz_io_hintsfunction dmz_prepare_ioctlfunction dmz_suspendfunction dmz_resumefunction dmz_iterate_devicesfunction dmz_statusfunction dmz_message
Annotated Snippet
struct dmz_bioctx {
struct dmz_dev *dev;
struct dm_zone *zone;
struct bio *bio;
refcount_t ref;
};
/*
* Chunk work descriptor.
*/
struct dm_chunk_work {
struct work_struct work;
refcount_t refcount;
struct dmz_target *target;
unsigned int chunk;
struct bio_list bio_list;
};
/*
* Target descriptor.
*/
struct dmz_target {
struct dm_dev **ddev;
unsigned int nr_ddevs;
unsigned int flags;
/* Zoned block device information */
struct dmz_dev *dev;
/* For metadata handling */
struct dmz_metadata *metadata;
/* For chunk work */
struct radix_tree_root chunk_rxtree;
struct workqueue_struct *chunk_wq;
struct mutex chunk_lock;
/* For cloned BIOs to zones */
struct bio_set bio_set;
/* For flush */
spinlock_t flush_lock;
struct bio_list flush_list;
struct delayed_work flush_work;
struct workqueue_struct *flush_wq;
};
/*
* Flush intervals (seconds).
*/
#define DMZ_FLUSH_PERIOD (10 * HZ)
/*
* Target BIO completion.
*/
static inline void dmz_bio_endio(struct bio *bio, blk_status_t status)
{
struct dmz_bioctx *bioctx =
dm_per_bio_data(bio, sizeof(struct dmz_bioctx));
if (status != BLK_STS_OK && bio->bi_status == BLK_STS_OK)
bio->bi_status = status;
if (bioctx->dev && bio->bi_status != BLK_STS_OK)
bioctx->dev->flags |= DMZ_CHECK_BDEV;
if (refcount_dec_and_test(&bioctx->ref)) {
struct dm_zone *zone = bioctx->zone;
if (zone) {
if (bio->bi_status != BLK_STS_OK &&
bio_op(bio) == REQ_OP_WRITE &&
dmz_is_seq(zone))
set_bit(DMZ_SEQ_WRITE_ERR, &zone->flags);
dmz_deactivate_zone(zone);
}
bio_endio(bio);
}
}
/*
* Completion callback for an internally cloned target BIO. This terminates the
* target BIO when there are no more references to its context.
*/
static void dmz_clone_endio(struct bio *clone)
{
struct dmz_bioctx *bioctx = clone->bi_private;
blk_status_t status = clone->bi_status;
bio_put(clone);
Annotation
- Immediate include surface: `dm-zoned.h`, `linux/module.h`.
- Detected declarations: `struct dmz_bioctx`, `struct dm_chunk_work`, `struct dmz_target`, `function intervals`, `function dmz_clone_endio`, `function dmz_submit_bio`, `function dmz_handle_read_zero`, `function dmz_handle_read`, `function dmz_handle_direct_write`, `function dmz_handle_buffered_write`.
- Atlas domain: Driver Families / drivers/md.
- 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.