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.

Dependency Surface

Detected Declarations

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

Implementation Notes