drivers/md/dm-vdo/packer.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/packer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/packer.c- Extension
.c- Size
- 24493 bytes
- Lines
- 776
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
packer.hlinux/atomic.hlinux/blkdev.hlogger.hmemory-alloc.hpermassert.hstring-utils.hadmin-state.hcompletion.hconstants.hdata-vio.hdedupe.hencodings.hio-submitter.hphysical-zone.hstatus-codes.hvdo.hvio.h
Detected Declarations
function vdo_get_compressed_block_fragmentfunction assert_on_packer_threadfunction insert_in_sorted_listfunction list_for_each_entryfunction make_binfunction vdo_make_packerfunction vdo_free_packerfunction list_for_each_entry_safefunction get_packer_from_data_viofunction vdo_get_packer_statisticsfunction abort_packingfunction release_compressed_write_waiterfunction finish_compressed_writefunction handle_compressed_write_errorfunction add_to_binfunction remove_from_binfunction initialize_compressed_blockfunction pack_fragmentfunction compressed_write_end_iofunction write_binfunction add_data_vio_to_packer_binfunction select_binfunction list_for_each_entryfunction vdo_attempt_packingfunction check_for_drain_completefunction write_all_non_empty_binsfunction vdo_flush_packerfunction vdo_remove_lock_holder_from_packerfunction vdo_increment_packer_flush_generationfunction initiate_drainfunction vdo_drain_packerfunction vdo_resume_packerfunction dump_packer_binfunction vdo_dump_packer
Annotated Snippet
if (active_bin->free_space > bin->free_space) {
list_move_tail(&bin->list, &active_bin->list);
return;
}
list_move_tail(&bin->list, &packer->bins);
}
/**
* make_bin() - Allocate a bin and put it into the packer's list.
* @packer: The packer.
*/
static int __must_check make_bin(struct packer *packer)
{
struct packer_bin *bin;
int result;
result = vdo_allocate_extended(VDO_MAX_COMPRESSION_SLOTS, incoming, __func__, &bin);
if (result != VDO_SUCCESS)
return result;
bin->free_space = VDO_COMPRESSED_BLOCK_DATA_SIZE;
INIT_LIST_HEAD(&bin->list);
list_add_tail(&bin->list, &packer->bins);
return VDO_SUCCESS;
}
/**
* vdo_make_packer() - Make a new block packer.
*
* @vdo: The vdo to which this packer belongs.
* @bin_count: The number of partial bins to keep in memory.
* @packer_ptr: A pointer to hold the new packer.
*
* Return: VDO_SUCCESS or an error
*/
int vdo_make_packer(struct vdo *vdo, block_count_t bin_count, struct packer **packer_ptr)
{
struct packer *packer;
block_count_t i;
int result;
result = vdo_allocate(1, __func__, &packer);
if (result != VDO_SUCCESS)
return result;
packer->thread_id = vdo->thread_config.packer_thread;
packer->size = bin_count;
INIT_LIST_HEAD(&packer->bins);
vdo_set_admin_state_code(&packer->state, VDO_ADMIN_STATE_NORMAL_OPERATION);
for (i = 0; i < bin_count; i++) {
result = make_bin(packer);
if (result != VDO_SUCCESS) {
vdo_free_packer(packer);
return result;
}
}
/*
* The canceled bin can hold up to half the number of user vios. Every canceled vio in the
* bin must have a canceler for which it is waiting, and any canceler will only have
* canceled one lock holder at a time.
*/
result = vdo_allocate_extended(MAXIMUM_VDO_USER_VIOS / 2, incoming, __func__,
&packer->canceled_bin);
if (result != VDO_SUCCESS) {
vdo_free_packer(packer);
return result;
}
result = vdo_make_default_thread(vdo, packer->thread_id);
if (result != VDO_SUCCESS) {
vdo_free_packer(packer);
return result;
}
*packer_ptr = packer;
return VDO_SUCCESS;
}
/**
* vdo_free_packer() - Free a block packer.
* @packer: The packer to free.
*/
void vdo_free_packer(struct packer *packer)
{
struct packer_bin *bin, *tmp;
if (packer == NULL)
Annotation
- Immediate include surface: `packer.h`, `linux/atomic.h`, `linux/blkdev.h`, `logger.h`, `memory-alloc.h`, `permassert.h`, `string-utils.h`, `admin-state.h`.
- Detected declarations: `function vdo_get_compressed_block_fragment`, `function assert_on_packer_thread`, `function insert_in_sorted_list`, `function list_for_each_entry`, `function make_bin`, `function vdo_make_packer`, `function vdo_free_packer`, `function list_for_each_entry_safe`, `function get_packer_from_data_vio`, `function vdo_get_packer_statistics`.
- 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.