drivers/md/dm-log-writes.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-log-writes.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-log-writes.c- Extension
.c- Size
- 24515 bytes
- Lines
- 948
- 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
linux/device-mapper.hlinux/module.hlinux/init.hlinux/blkdev.hlinux/bio.hlinux/dax.hlinux/slab.hlinux/kthread.hlinux/freezer.hlinux/uio.h
Detected Declarations
struct log_write_superstruct log_write_entrystruct log_writes_cstruct pending_blockstruct per_bio_datafunction bio_to_dev_sectorsfunction dev_to_bio_sectorsfunction put_pending_blockfunction put_io_blockfunction log_end_iofunction log_end_superfunction free_pending_blockfunction write_metadatafunction write_inline_datafunction log_one_blockfunction log_superfunction logdev_last_sectorfunction log_writes_kthreadfunction log_writes_ctrfunction log_markfunction log_writes_dtrfunction normal_map_biofunction log_writes_mapfunction normal_end_iofunction log_writes_statusfunction log_writes_prepare_ioctlfunction log_writes_iterate_devicesfunction log_writes_messagefunction log_writes_io_hintsfunction log_writes_dax_direct_accessfunction log_writes_dax_zero_page_rangefunction log_writes_dax_recovery_write
Annotated Snippet
struct log_write_super {
__le64 magic;
__le64 version;
__le64 nr_entries;
__le32 sectorsize;
};
/*
* sector - the sector we wrote.
* nr_sectors - the number of sectors we wrote.
* flags - flags for this log entry.
* data_len - the size of the data in this log entry, this is for private log
* entry stuff, the MARK data provided by userspace for example.
*/
struct log_write_entry {
__le64 sector;
__le64 nr_sectors;
__le64 flags;
__le64 data_len;
};
struct log_writes_c {
struct dm_dev *dev;
struct dm_dev *logdev;
u64 logged_entries;
u32 sectorsize;
u32 sectorshift;
atomic_t io_blocks;
atomic_t pending_blocks;
sector_t next_sector;
sector_t end_sector;
bool logging_enabled;
bool device_supports_discard;
spinlock_t blocks_lock;
struct list_head unflushed_blocks;
struct list_head logging_blocks;
wait_queue_head_t wait;
struct task_struct *log_kthread;
struct completion super_done;
};
struct pending_block {
int vec_cnt;
u64 flags;
sector_t sector;
sector_t nr_sectors;
char *data;
u32 datalen;
struct list_head list;
struct bio_vec vecs[];
};
struct per_bio_data {
struct pending_block *block;
};
static inline sector_t bio_to_dev_sectors(struct log_writes_c *lc,
sector_t sectors)
{
return sectors >> (lc->sectorshift - SECTOR_SHIFT);
}
static inline sector_t dev_to_bio_sectors(struct log_writes_c *lc,
sector_t sectors)
{
return sectors << (lc->sectorshift - SECTOR_SHIFT);
}
static void put_pending_block(struct log_writes_c *lc)
{
if (atomic_dec_and_test(&lc->pending_blocks)) {
smp_mb__after_atomic();
if (waitqueue_active(&lc->wait))
wake_up(&lc->wait);
}
}
static void put_io_block(struct log_writes_c *lc)
{
if (atomic_dec_and_test(&lc->io_blocks)) {
smp_mb__after_atomic();
if (waitqueue_active(&lc->wait))
wake_up(&lc->wait);
}
}
static void log_end_io(struct bio *bio)
{
struct log_writes_c *lc = bio->bi_private;
Annotation
- Immediate include surface: `linux/device-mapper.h`, `linux/module.h`, `linux/init.h`, `linux/blkdev.h`, `linux/bio.h`, `linux/dax.h`, `linux/slab.h`, `linux/kthread.h`.
- Detected declarations: `struct log_write_super`, `struct log_write_entry`, `struct log_writes_c`, `struct pending_block`, `struct per_bio_data`, `function bio_to_dev_sectors`, `function dev_to_bio_sectors`, `function put_pending_block`, `function put_io_block`, `function log_end_io`.
- 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.