drivers/md/dm-era-target.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-era-target.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-era-target.c- Extension
.c- Size
- 39370 bytes
- Lines
- 1762
- 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.hpersistent-data/dm-transaction-manager.hpersistent-data/dm-bitset.hpersistent-data/dm-space-map.hlinux/dm-io.hlinux/dm-kcopyd.hlinux/init.hlinux/mempool.hlinux/module.hlinux/slab.hlinux/vmalloc.h
Detected Declarations
struct writeset_metadatastruct writesetstruct writeset_diskstruct superblock_diskstruct era_metadatastruct digeststruct metadata_statsstruct erastruct rpcfunction writeset_freefunction setup_on_disk_bitsetfunction bitset_sizefunction writeset_allocfunction writeset_initfunction writeset_markedfunction writeset_marked_on_diskfunction writeset_test_and_setfunction sb_prepare_for_writefunction check_metadata_versionfunction sb_checkfunction superblock_read_lockfunction superblock_lock_zerofunction superblock_lockfunction superblock_all_zeroesfunction ws_packfunction ws_unpackfunction ws_incfunction ws_decfunction ws_eqfunction setup_writeset_tree_infofunction setup_era_array_infofunction setup_infosfunction create_fresh_metadatafunction save_sm_rootfunction copy_sm_rootfunction commitfunction write_superblockfunction format_metadatafunction open_metadatafunction open_or_format_metadatafunction create_persistent_data_objectsfunction destroy_persistent_data_objectsfunction swap_writesetfunction metadata_digest_remove_writesetfunction metadata_digest_transcribe_writesetfunction metadata_digest_lookup_writesetfunction metadata_digest_startfunction metadata_close
Annotated Snippet
struct writeset_metadata {
uint32_t nr_bits;
dm_block_t root;
};
struct writeset {
struct writeset_metadata md;
/*
* An in core copy of the bits to save constantly doing look ups on
* disk.
*/
unsigned long *bits;
};
/*
* This does not free off the on disk bitset as this will normally be done
* after digesting into the era array.
*/
static void writeset_free(struct writeset *ws)
{
vfree(ws->bits);
ws->bits = NULL;
}
static int setup_on_disk_bitset(struct dm_disk_bitset *info,
unsigned int nr_bits, dm_block_t *root)
{
int r;
r = dm_bitset_empty(info, root);
if (r)
return r;
return dm_bitset_resize(info, *root, 0, nr_bits, false, root);
}
static size_t bitset_size(unsigned int nr_bits)
{
return sizeof(unsigned long) * dm_div_up(nr_bits, BITS_PER_LONG);
}
/*
* Allocates memory for the in core bitset.
*/
static int writeset_alloc(struct writeset *ws, dm_block_t nr_blocks)
{
ws->bits = vzalloc(bitset_size(nr_blocks));
if (!ws->bits) {
DMERR("%s: couldn't allocate in memory bitset", __func__);
return -ENOMEM;
}
return 0;
}
/*
* Wipes the in-core bitset, and creates a new on disk bitset.
*/
static int writeset_init(struct dm_disk_bitset *info, struct writeset *ws,
dm_block_t nr_blocks)
{
int r;
memset(ws->bits, 0, bitset_size(nr_blocks));
ws->md.nr_bits = nr_blocks;
r = setup_on_disk_bitset(info, ws->md.nr_bits, &ws->md.root);
if (r) {
DMERR("%s: setup_on_disk_bitset failed", __func__);
return r;
}
return 0;
}
static bool writeset_marked(struct writeset *ws, dm_block_t block)
{
return test_bit(block, ws->bits);
}
static int writeset_marked_on_disk(struct dm_disk_bitset *info,
struct writeset_metadata *m, dm_block_t block,
bool *result)
{
int r;
dm_block_t old = m->root;
/*
* The bitset was flushed when it was archived, so we know there'll
Annotation
- Immediate include surface: `dm.h`, `persistent-data/dm-transaction-manager.h`, `persistent-data/dm-bitset.h`, `persistent-data/dm-space-map.h`, `linux/dm-io.h`, `linux/dm-kcopyd.h`, `linux/init.h`, `linux/mempool.h`.
- Detected declarations: `struct writeset_metadata`, `struct writeset`, `struct writeset_disk`, `struct superblock_disk`, `struct era_metadata`, `struct digest`, `struct metadata_stats`, `struct era`, `struct rpc`, `function writeset_free`.
- 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.