drivers/md/persistent-data/dm-space-map-disk.c
Source file repositories/reference/linux-study-clean/drivers/md/persistent-data/dm-space-map-disk.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/persistent-data/dm-space-map-disk.c- Extension
.c- Size
- 6268 bytes
- Lines
- 282
- 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.
- 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-space-map-common.hdm-space-map-disk.hdm-space-map.hdm-transaction-manager.hlinux/list.hlinux/slab.hlinux/export.hlinux/device-mapper.h
Detected Declarations
struct sm_diskfunction sm_disk_destroyfunction sm_disk_extendfunction sm_disk_get_nr_blocksfunction sm_disk_get_nr_freefunction sm_disk_get_countfunction sm_disk_count_is_more_than_onefunction sm_disk_set_countfunction sm_disk_inc_blocksfunction sm_disk_dec_blocksfunction sm_disk_new_blockfunction sm_disk_commitfunction sm_disk_root_sizefunction sm_disk_copy_rootexport dm_sm_disk_createexport dm_sm_disk_open
Annotated Snippet
struct sm_disk {
struct dm_space_map sm;
struct ll_disk ll;
struct ll_disk old_ll;
dm_block_t begin;
dm_block_t nr_allocated_this_transaction;
};
static void sm_disk_destroy(struct dm_space_map *sm)
{
struct sm_disk *smd = container_of(sm, struct sm_disk, sm);
kfree(smd);
}
static int sm_disk_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
{
struct sm_disk *smd = container_of(sm, struct sm_disk, sm);
return sm_ll_extend(&smd->ll, extra_blocks);
}
static int sm_disk_get_nr_blocks(struct dm_space_map *sm, dm_block_t *count)
{
struct sm_disk *smd = container_of(sm, struct sm_disk, sm);
*count = smd->old_ll.nr_blocks;
return 0;
}
static int sm_disk_get_nr_free(struct dm_space_map *sm, dm_block_t *count)
{
struct sm_disk *smd = container_of(sm, struct sm_disk, sm);
*count = (smd->old_ll.nr_blocks - smd->old_ll.nr_allocated) - smd->nr_allocated_this_transaction;
return 0;
}
static int sm_disk_get_count(struct dm_space_map *sm, dm_block_t b,
uint32_t *result)
{
struct sm_disk *smd = container_of(sm, struct sm_disk, sm);
return sm_ll_lookup(&smd->ll, b, result);
}
static int sm_disk_count_is_more_than_one(struct dm_space_map *sm, dm_block_t b,
int *result)
{
int r;
uint32_t count;
r = sm_disk_get_count(sm, b, &count);
if (r)
return r;
*result = count > 1;
return 0;
}
static int sm_disk_set_count(struct dm_space_map *sm, dm_block_t b,
uint32_t count)
{
int r;
int32_t nr_allocations;
struct sm_disk *smd = container_of(sm, struct sm_disk, sm);
r = sm_ll_insert(&smd->ll, b, count, &nr_allocations);
if (!r)
smd->nr_allocated_this_transaction += nr_allocations;
return r;
}
static int sm_disk_inc_blocks(struct dm_space_map *sm, dm_block_t b, dm_block_t e)
{
int r;
int32_t nr_allocations;
struct sm_disk *smd = container_of(sm, struct sm_disk, sm);
r = sm_ll_inc(&smd->ll, b, e, &nr_allocations);
if (!r)
smd->nr_allocated_this_transaction += nr_allocations;
return r;
Annotation
- Immediate include surface: `dm-space-map-common.h`, `dm-space-map-disk.h`, `dm-space-map.h`, `dm-transaction-manager.h`, `linux/list.h`, `linux/slab.h`, `linux/export.h`, `linux/device-mapper.h`.
- Detected declarations: `struct sm_disk`, `function sm_disk_destroy`, `function sm_disk_extend`, `function sm_disk_get_nr_blocks`, `function sm_disk_get_nr_free`, `function sm_disk_get_count`, `function sm_disk_count_is_more_than_one`, `function sm_disk_set_count`, `function sm_disk_inc_blocks`, `function sm_disk_dec_blocks`.
- 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.