drivers/md/dm-thin-metadata.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-thin-metadata.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-thin-metadata.c- Extension
.c- Size
- 49450 bytes
- Lines
- 2161
- 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.
- 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-thin-metadata.hpersistent-data/dm-btree.hpersistent-data/dm-space-map.hpersistent-data/dm-space-map-disk.hpersistent-data/dm-transaction-manager.hlinux/list.hlinux/device-mapper.hlinux/workqueue.h
Detected Declarations
struct thin_disk_superblockstruct disk_device_detailsstruct dm_pool_metadatastruct dm_thin_devicefunction sb_prepare_for_writefunction sb_checkfunction pack_block_timefunction unpack_block_timefunction with_runsfunction data_block_incfunction data_block_decfunction data_block_equalfunction subtree_incfunction subtree_decfunction subtree_equalfunction pmd_write_lock_in_corefunction pmd_write_lockfunction pmd_write_unlockfunction superblock_lock_zerofunction superblock_lockfunction __superblock_all_zeroesfunction __setup_btree_detailsfunction save_sm_rootsfunction copy_sm_rootsfunction __write_initial_superblockfunction __format_metadatafunction __check_incompat_featuresfunction __open_metadatafunction __open_or_format_metadatafunction __create_persistent_data_objectsfunction __destroy_persistent_data_objectsfunction __begin_transactionfunction __write_changed_detailsfunction list_for_each_entry_safefunction __commit_transactionfunction __set_metadata_reservefunction dm_pool_metadata_closefunction __open_devicefunction __close_devicefunction __create_thinfunction dm_pool_create_thinfunction __set_snapshot_detailsfunction __create_snapfunction dm_pool_create_snapfunction __delete_devicefunction dm_pool_delete_thin_devicefunction dm_pool_set_metadata_transaction_idfunction dm_pool_get_metadata_transaction_id
Annotated Snippet
struct thin_disk_superblock {
__le32 csum; /* Checksum of superblock except for this field. */
__le32 flags;
__le64 blocknr; /* This block number, dm_block_t. */
__u8 uuid[16];
__le64 magic;
__le32 version;
__le32 time;
__le64 trans_id;
/*
* Root held by userspace transactions.
*/
__le64 held_root;
__u8 data_space_map_root[SPACE_MAP_ROOT_SIZE];
__u8 metadata_space_map_root[SPACE_MAP_ROOT_SIZE];
/*
* 2-level btree mapping (dev_id, (dev block, time)) -> data block
*/
__le64 data_mapping_root;
/*
* Device detail root mapping dev_id -> device_details
*/
__le64 device_details_root;
__le32 data_block_size; /* In 512-byte sectors. */
__le32 metadata_block_size; /* In 512-byte sectors. */
__le64 metadata_nr_blocks;
__le32 compat_flags;
__le32 compat_ro_flags;
__le32 incompat_flags;
} __packed;
struct disk_device_details {
__le64 mapped_blocks;
__le64 transaction_id; /* When created. */
__le32 creation_time;
__le32 snapshotted_time;
} __packed;
struct dm_pool_metadata {
struct hlist_node hash;
struct block_device *bdev;
struct dm_block_manager *bm;
struct dm_space_map *metadata_sm;
struct dm_space_map *data_sm;
struct dm_transaction_manager *tm;
struct dm_transaction_manager *nb_tm;
/*
* Two-level btree.
* First level holds thin_dev_t.
* Second level holds mappings.
*/
struct dm_btree_info info;
/*
* Non-blocking version of the above.
*/
struct dm_btree_info nb_info;
/*
* Just the top level for deleting whole devices.
*/
struct dm_btree_info tl_info;
/*
* Just the bottom level for creating new devices.
*/
struct dm_btree_info bl_info;
/*
* Describes the device details btree.
*/
struct dm_btree_info details_info;
struct rw_semaphore root_lock;
uint32_t time;
dm_block_t root;
dm_block_t details_root;
struct list_head thin_devices;
uint64_t trans_id;
Annotation
- Immediate include surface: `dm-thin-metadata.h`, `persistent-data/dm-btree.h`, `persistent-data/dm-space-map.h`, `persistent-data/dm-space-map-disk.h`, `persistent-data/dm-transaction-manager.h`, `linux/list.h`, `linux/device-mapper.h`, `linux/workqueue.h`.
- Detected declarations: `struct thin_disk_superblock`, `struct disk_device_details`, `struct dm_pool_metadata`, `struct dm_thin_device`, `function sb_prepare_for_write`, `function sb_check`, `function pack_block_time`, `function unpack_block_time`, `function with_runs`, `function data_block_inc`.
- Atlas domain: Driver Families / drivers/md.
- Implementation status: source 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.