drivers/md/dm-zoned-metadata.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-zoned-metadata.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-zoned-metadata.c- Extension
.c- Size
- 72530 bytes
- Lines
- 3002
- 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.hlinux/crc32.hlinux/sched/mm.h
Detected Declarations
struct dmz_superstruct dmz_mapstruct dmz_mblockstruct dmz_sbstruct dmz_metadatafunction dmz_dev_zone_idfunction dmz_start_sectfunction dmz_start_blockfunction dmz_zone_nr_blocksfunction dmz_zone_nr_sectorsfunction dmz_zone_nr_sectors_shiftfunction dmz_nr_zonesfunction dmz_nr_chunksfunction dmz_nr_rnd_zonesfunction dmz_nr_unmap_rnd_zonesfunction dmz_nr_cache_zonesfunction dmz_nr_unmap_cache_zonesfunction dmz_nr_seq_zonesfunction dmz_nr_unmap_seq_zonesfunction dmz_check_devfunction dmz_dev_is_dyingfunction dmz_lock_mapfunction dmz_unlock_mapfunction managementfunction dmz_unlock_metadatafunction dmz_lock_flushfunction dmz_unlock_flushfunction dmz_free_mblockfunction dmz_insert_mblockfunction dmz_mblock_bio_end_iofunction dmz_shrink_mblock_cachefunction dmz_mblock_shrinker_countfunction dmz_mblock_shrinker_scanfunction dmz_release_mblockfunction dmz_dirty_mblockfunction dmz_write_mblockfunction dmz_rdwr_blockfunction dmz_write_sbfunction dmz_write_dirty_mblocksfunction dmz_log_dirty_mblocksfunction dmz_flush_metadatafunction dmz_check_sbfunction dmz_read_sbfunction dmz_lookup_secondary_sbfunction dmz_get_sbfunction dmz_recover_mblocksfunction dmz_load_sbfunction dmz_init_zone
Annotated Snippet
struct dmz_super {
/* Magic number */
__le32 magic; /* 4 */
/* Metadata version number */
__le32 version; /* 8 */
/* Generation number */
__le64 gen; /* 16 */
/* This block number */
__le64 sb_block; /* 24 */
/* The number of metadata blocks, including this super block */
__le32 nr_meta_blocks; /* 28 */
/* The number of sequential zones reserved for reclaim */
__le32 nr_reserved_seq; /* 32 */
/* The number of entries in the mapping table */
__le32 nr_chunks; /* 36 */
/* The number of blocks used for the chunk mapping table */
__le32 nr_map_blocks; /* 40 */
/* The number of blocks used for the block bitmaps */
__le32 nr_bitmap_blocks; /* 44 */
/* Checksum */
__le32 crc; /* 48 */
/* DM-Zoned label */
u8 dmz_label[32]; /* 80 */
/* DM-Zoned UUID */
u8 dmz_uuid[16]; /* 96 */
/* Device UUID */
u8 dev_uuid[16]; /* 112 */
/* Padding to full 512B sector */
u8 reserved[400]; /* 512 */
};
/*
* Chunk mapping entry: entries are indexed by chunk number
* and give the zone ID (dzone_id) mapping the chunk on disk.
* This zone may be sequential or random. If it is a sequential
* zone, a second zone (bzone_id) used as a write buffer may
* also be specified. This second zone will always be a randomly
* writeable zone.
*/
struct dmz_map {
__le32 dzone_id;
__le32 bzone_id;
};
/*
* Chunk mapping table metadata: 512 8-bytes entries per 4KB block.
*/
#define DMZ_MAP_ENTRIES (DMZ_BLOCK_SIZE / sizeof(struct dmz_map))
#define DMZ_MAP_ENTRIES_SHIFT (ilog2(DMZ_MAP_ENTRIES))
#define DMZ_MAP_ENTRIES_MASK (DMZ_MAP_ENTRIES - 1)
#define DMZ_MAP_UNMAPPED UINT_MAX
/*
* Meta data block descriptor (for cached metadata blocks).
*/
struct dmz_mblock {
struct rb_node node;
struct list_head link;
sector_t no;
unsigned int ref;
unsigned long state;
struct page *page;
void *data;
};
/*
* Metadata block state flags.
*/
enum {
DMZ_META_DIRTY,
DMZ_META_READING,
DMZ_META_WRITING,
DMZ_META_ERROR,
};
/*
* Super block information (one per metadata set).
Annotation
- Immediate include surface: `dm-zoned.h`, `linux/module.h`, `linux/crc32.h`, `linux/sched/mm.h`.
- Detected declarations: `struct dmz_super`, `struct dmz_map`, `struct dmz_mblock`, `struct dmz_sb`, `struct dmz_metadata`, `function dmz_dev_zone_id`, `function dmz_start_sect`, `function dmz_start_block`, `function dmz_zone_nr_blocks`, `function dmz_zone_nr_sectors`.
- 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.