drivers/md/dm-pcache/cache_gc.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-pcache/cache_gc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-pcache/cache_gc.c- Extension
.c- Size
- 5438 bytes
- Lines
- 171
- 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
cache.hbacking_dev.hcache_dev.hdm_pcache.h
Detected Declarations
function cache_key_gcfunction need_gcfunction last_kset_gcfunction pcache_cache_gc_fn
Annotated Snippet
if (kset_onmedia->flags & PCACHE_KSET_FLAGS_LAST) {
/* Don't move to the next segment if dirty_tail has not moved */
if (dirty_tail.cache_seg == key_tail.cache_seg)
break;
last_kset_gc(cache, kset_onmedia);
continue;
}
for (i = 0; i < kset_onmedia->key_num; i++) {
struct pcache_cache_key key_tmp = { 0 };
key_onmedia = &kset_onmedia->data[i];
key = &key_tmp;
cache_key_init(&cache->req_key_tree, key);
ret = cache_key_decode(cache, key_onmedia, key);
if (ret) {
/* return without re-arm gc work, and prevent future
* gc, because we can't retry the partial-gc-ed kset
*/
atomic_inc(&cache->gc_errors);
pcache_dev_err(pcache, "failed to decode cache key in gc\n");
return;
}
cache_key_gc(cache, key);
}
pcache_dev_debug(pcache, "gc advance: %u:%u %u\n",
key_tail.cache_seg->cache_seg_id,
key_tail.seg_off,
get_kset_onmedia_size(kset_onmedia));
mutex_lock(&cache->key_tail_lock);
cache_pos_advance(&cache->key_tail, get_kset_onmedia_size(kset_onmedia));
cache_encode_key_tail(cache);
mutex_unlock(&cache->key_tail_lock);
}
queue_delayed_work(cache_get_wq(cache), &cache->gc_work, PCACHE_CACHE_GC_INTERVAL);
}
Annotation
- Immediate include surface: `cache.h`, `backing_dev.h`, `cache_dev.h`, `dm_pcache.h`.
- Detected declarations: `function cache_key_gc`, `function need_gc`, `function last_kset_gc`, `function pcache_cache_gc_fn`.
- 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.