drivers/md/dm-vdo/flush.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/flush.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/flush.c- Extension
.c- Size
- 17442 bytes
- Lines
- 556
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
flush.hlinux/mempool.hlinux/spinlock.hlogger.hmemory-alloc.hpermassert.hadmin-state.hcompletion.hio-submitter.hlogical-zone.hslab-depot.htypes.hvdo.h
Detected Declarations
struct flusherfunction assert_on_flusher_threadfunction as_flusherfunction completion_as_vdo_flushfunction vdo_waiter_as_flushfunction free_flushfunction vdo_make_flusherfunction vdo_free_flusherfunction vdo_get_flusher_thread_idfunction finish_notificationfunction flush_packer_callbackfunction increment_generationfunction notify_flushfunction flush_vdofunction check_for_drain_completefunction vdo_complete_flushesfunction vdo_dump_flusherfunction initialize_flushfunction launch_flushfunction vdo_launch_flushfunction release_flushfunction vdo_complete_flush_callbackfunction select_bio_queuefunction vdo_complete_flushfunction initiate_drainfunction vdo_drain_flusherfunction vdo_resume_flusher
Annotated Snippet
struct flusher {
struct vdo_completion completion;
/* The vdo to which this flusher belongs */
struct vdo *vdo;
/* The administrative state of the flusher */
struct admin_state state;
/* The current flush generation of the vdo */
sequence_number_t flush_generation;
/* The first unacknowledged flush generation */
sequence_number_t first_unacknowledged_generation;
/* The queue of flush requests waiting to notify other threads */
struct vdo_wait_queue notifiers;
/* The queue of flush requests waiting for VIOs to complete */
struct vdo_wait_queue pending_flushes;
/* The flush generation for which notifications are being sent */
sequence_number_t notify_generation;
/* The logical zone to notify next */
struct logical_zone *logical_zone_to_notify;
/* The ID of the thread on which flush requests should be made */
thread_id_t thread_id;
/* The pool of flush requests */
mempool_t *flush_pool;
/* Bios waiting for a flush request to become available */
struct bio_list waiting_flush_bios;
/* The lock to protect the previous fields */
spinlock_t lock;
/* The rotor for selecting the bio queue for submitting flush bios */
zone_count_t bio_queue_rotor;
/* The number of flushes submitted to the current bio queue */
int flush_count;
};
/**
* assert_on_flusher_thread() - Check that we are on the flusher thread.
* @flusher: The flusher.
* @caller: The function which is asserting.
*/
static inline void assert_on_flusher_thread(struct flusher *flusher, const char *caller)
{
VDO_ASSERT_LOG_ONLY((vdo_get_callback_thread_id() == flusher->thread_id),
"%s() called from flusher thread", caller);
}
/**
* as_flusher() - Convert a generic vdo_completion to a flusher.
* @completion: The completion to convert.
*
* Return: The completion as a flusher.
*/
static struct flusher *as_flusher(struct vdo_completion *completion)
{
vdo_assert_completion_type(completion, VDO_FLUSH_NOTIFICATION_COMPLETION);
return container_of(completion, struct flusher, completion);
}
/**
* completion_as_vdo_flush() - Convert a generic vdo_completion to a vdo_flush.
* @completion: The completion to convert.
*
* Return: The completion as a vdo_flush.
*/
static inline struct vdo_flush *completion_as_vdo_flush(struct vdo_completion *completion)
{
vdo_assert_completion_type(completion, VDO_FLUSH_COMPLETION);
return container_of(completion, struct vdo_flush, completion);
}
/**
* vdo_waiter_as_flush() - Convert a vdo_flush's generic wait queue entry back to the vdo_flush.
* @waiter: The wait queue entry to convert.
*
* Return: The wait queue entry as a vdo_flush.
*/
static struct vdo_flush *vdo_waiter_as_flush(struct vdo_waiter *waiter)
{
return container_of(waiter, struct vdo_flush, waiter);
}
static void *allocate_flush(gfp_t gfp_mask, void *pool_data)
{
struct vdo_flush *flush = NULL;
if ((gfp_mask & GFP_NOWAIT) == GFP_NOWAIT) {
flush = vdo_allocate_memory_nowait(sizeof(struct vdo_flush), __func__);
} else {
int result = vdo_allocate(1, __func__, &flush);
if (result != VDO_SUCCESS)
vdo_log_error_strerror(result, "failed to allocate spare flush");
}
Annotation
- Immediate include surface: `flush.h`, `linux/mempool.h`, `linux/spinlock.h`, `logger.h`, `memory-alloc.h`, `permassert.h`, `admin-state.h`, `completion.h`.
- Detected declarations: `struct flusher`, `function assert_on_flusher_thread`, `function as_flusher`, `function completion_as_vdo_flush`, `function vdo_waiter_as_flush`, `function free_flush`, `function vdo_make_flusher`, `function vdo_free_flusher`, `function vdo_get_flusher_thread_id`, `function finish_notification`.
- 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.