drivers/md/dm-zone.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-zone.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-zone.c- Extension
.c- Size
- 13928 bytes
- Lines
- 522
- Domain
- Driver Families
- Bucket
- drivers/md
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/blkdev.hlinux/mm.hlinux/sched/mm.hlinux/slab.hlinux/bitmap.hdm-core.h
Detected Declarations
struct dm_device_zone_countstruct dm_zone_resource_limitsfunction Copyrightfunction dm_report_zonesfunction dm_report_zones_cbfunction dm_report_zonesfunction dm_is_zone_writefunction blk_revalidate_disk_zonesfunction device_not_zone_append_capablefunction dm_table_supports_zone_appendfunction dm_device_count_zones_cbfunction dm_device_count_zonesfunction device_get_zone_resource_limitsfunction dm_set_zones_restrictionsfunction dm_finalize_zone_settingsfunction clone_endiofunction bio_opfunction dm_zone_need_reset_cbfunction dm_zone_get_reset_bitmapexport dm_report_zones
Annotated Snippet
struct dm_device_zone_count {
sector_t start;
sector_t len;
unsigned int total_nr_seq_zones;
unsigned int target_nr_seq_zones;
};
/*
* Count the total number of and the number of mapped sequential zones of a
* target zoned device.
*/
static int dm_device_count_zones_cb(struct blk_zone *zone,
unsigned int idx, void *data)
{
struct dm_device_zone_count *zc = data;
if (zone->type != BLK_ZONE_TYPE_CONVENTIONAL) {
zc->total_nr_seq_zones++;
if (zone->start >= zc->start &&
zone->start < zc->start + zc->len)
zc->target_nr_seq_zones++;
}
return 0;
}
static int dm_device_count_zones(struct dm_dev *dev,
struct dm_device_zone_count *zc)
{
int ret;
ret = blkdev_report_zones(dev->bdev, 0, BLK_ALL_ZONES,
dm_device_count_zones_cb, zc);
if (ret < 0)
return ret;
if (!ret)
return -EIO;
return 0;
}
struct dm_zone_resource_limits {
unsigned int mapped_nr_seq_zones;
struct queue_limits *lim;
bool reliable_limits;
};
static int device_get_zone_resource_limits(struct dm_target *ti,
struct dm_dev *dev, sector_t start,
sector_t len, void *data)
{
struct dm_zone_resource_limits *zlim = data;
struct gendisk *disk = dev->bdev->bd_disk;
unsigned int max_open_zones, max_active_zones;
int ret;
struct dm_device_zone_count zc = {
.start = start,
.len = len,
};
/*
* If the target is not the whole device, the device zone resources may
* be shared between different targets. Check this by counting the
* number of mapped sequential zones: if this number is smaller than the
* total number of sequential zones of the target device, then resource
* sharing may happen and the zone limits will not be reliable.
*/
ret = dm_device_count_zones(dev, &zc);
if (ret) {
DMERR("Count %s zones failed %d", disk->disk_name, ret);
return ret;
}
/*
* If the target does not map any sequential zones, then we do not need
* any zone resource limits.
*/
if (!zc.target_nr_seq_zones)
return 0;
/*
* If the target does not map all sequential zones, the limits
* will not be reliable and we cannot use REQ_OP_ZONE_RESET_ALL.
*/
if (zc.target_nr_seq_zones < zc.total_nr_seq_zones) {
zlim->reliable_limits = false;
ti->zone_reset_all_supported = false;
}
/*
* If the target maps less sequential zones than the limit values, then
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/mm.h`, `linux/sched/mm.h`, `linux/slab.h`, `linux/bitmap.h`, `dm-core.h`.
- Detected declarations: `struct dm_device_zone_count`, `struct dm_zone_resource_limits`, `function Copyright`, `function dm_report_zones`, `function dm_report_zones_cb`, `function dm_report_zones`, `function dm_is_zone_write`, `function blk_revalidate_disk_zones`, `function device_not_zone_append_capable`, `function dm_table_supports_zone_append`.
- Atlas domain: Driver Families / drivers/md.
- Implementation status: integration implementation candidate.
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.