drivers/md/dm-pcache/cache.h
Source file repositories/reference/linux-study-clean/drivers/md/dm-pcache/cache.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-pcache/cache.h- Extension
.h- Size
- 18966 bytes
- Lines
- 636
- 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
segment.h
Detected Declarations
struct pcache_cache_pos_onmediastruct pcache_cache_seg_genstruct pcache_cache_seg_ctrlstruct pcache_cache_infostruct pcache_cache_posstruct pcache_cache_segmentstruct pcache_cache_subtreestruct pcache_cache_treestruct pcache_cache_keystruct pcache_cache_key_onmediastruct pcache_cache_kset_onmediastruct pcache_cachestruct dm_pcachestruct pcache_cache_optionsstruct pcache_cache_ctrlstruct pcache_cache_data_headstruct pcache_cache_ksetstruct pcache_cache_subtree_walk_ctxfunction pcache_cache_get_gc_percentfunction get_kset_idfunction cache_key_emptyfunction cache_key_cleanfunction cache_pos_copyfunction cache_seg_is_ctrl_segfunction cache_key_cutfrontfunction cache_key_cutbackfunction cache_key_deletefunction cache_data_crc_onfunction cache_mode_getfunction cache_mode_setfunction cache_key_data_crcfunction cache_kset_crcfunction get_kset_onmedia_sizefunction cache_seg_remainfunction GCfunction cache_key_lstartfunction cache_key_lendfunction cache_key_copyfunction cache_pos_onmedia_crcfunction cache_encode_key_tailfunction cache_decode_key_tailfunction cache_encode_dirty_tailfunction cache_decode_dirty_tail
Annotated Snippet
struct pcache_cache_pos_onmedia {
struct pcache_meta_header header;
__u32 cache_seg_id;
__u32 seg_off;
};
/* Offset and size definitions for cache segment control */
#define PCACHE_CACHE_SEG_CTRL_OFF (PCACHE_SEG_INFO_SIZE * PCACHE_META_INDEX_MAX)
#define PCACHE_CACHE_SEG_CTRL_SIZE (4 * PCACHE_KB)
struct pcache_cache_seg_gen {
struct pcache_meta_header header;
__u64 gen;
};
/* Control structure for cache segments */
struct pcache_cache_seg_ctrl {
struct pcache_cache_seg_gen gen[PCACHE_META_INDEX_MAX];
__u64 res[64];
};
#define PCACHE_CACHE_FLAGS_DATA_CRC BIT(0)
#define PCACHE_CACHE_FLAGS_INIT_DONE BIT(1)
#define PCACHE_CACHE_FLAGS_CACHE_MODE_MASK GENMASK(5, 2)
#define PCACHE_CACHE_MODE_WRITEBACK 0
#define PCACHE_CACHE_MODE_WRITETHROUGH 1
#define PCACHE_CACHE_MODE_WRITEAROUND 2
#define PCACHE_CACHE_MODE_WRITEONLY 3
#define PCACHE_CACHE_FLAGS_GC_PERCENT_MASK GENMASK(12, 6)
struct pcache_cache_info {
struct pcache_meta_header header;
__u32 seg_id;
__u32 n_segs;
__u32 flags;
__u32 reserved;
};
struct pcache_cache_pos {
struct pcache_cache_segment *cache_seg;
u32 seg_off;
};
struct pcache_cache_segment {
struct pcache_cache *cache;
u32 cache_seg_id; /* Index in cache->segments */
struct pcache_segment segment;
atomic_t refs;
struct pcache_segment_info cache_seg_info;
struct mutex info_lock;
u32 info_index;
spinlock_t gen_lock;
u64 gen;
u64 gen_seq;
u32 gen_index;
struct pcache_cache_seg_ctrl *cache_seg_ctrl;
};
/* rbtree for cache entries */
struct pcache_cache_subtree {
struct rb_root root;
spinlock_t tree_lock;
};
struct pcache_cache_tree {
struct pcache_cache *cache;
u32 n_subtrees;
mempool_t key_pool;
struct pcache_cache_subtree *subtrees;
};
extern struct kmem_cache *key_cache;
struct pcache_cache_key {
struct pcache_cache_tree *cache_tree;
struct pcache_cache_subtree *cache_subtree;
struct kref ref;
struct rb_node rb_node;
struct list_head list_node;
u64 off;
u32 len;
u32 flags;
struct pcache_cache_pos cache_pos;
u64 seg_gen;
};
Annotation
- Immediate include surface: `segment.h`.
- Detected declarations: `struct pcache_cache_pos_onmedia`, `struct pcache_cache_seg_gen`, `struct pcache_cache_seg_ctrl`, `struct pcache_cache_info`, `struct pcache_cache_pos`, `struct pcache_cache_segment`, `struct pcache_cache_subtree`, `struct pcache_cache_tree`, `struct pcache_cache_key`, `struct pcache_cache_key_onmedia`.
- 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.