在 7/1/2025 10:59 PM, Jonathan Cameron 写道:
On Tue, 24 Jun 2025 07:33:52 +0000
Dongsheng Yang <dongsheng.y...@linux.dev> wrote:

Introduce *cache_segment.c*, the in-memory/on-disk glue that lets a
`struct pcache_cache` manage its array of data segments.

* Metadata handling
   - Loads the most-recent replica of both the segment-info block
     (`struct pcache_segment_info`) and per-segment generation counter
     (`struct pcache_cache_seg_gen`) using `pcache_meta_find_latest()`.
   - Updates those structures atomically with CRC + sequence rollover,
     writing alternately to the two metadata slots inside each segment.

* Segment initialisation (`cache_seg_init`)
   - Builds a `struct pcache_segment` pointing to the segment’s data
     area, sets up locks, generation counters, and, when formatting a new
     cache, zeroes the on-segment kset header.


+
+       cache = cache_seg->cache;
+       cache_seg_gen_increase(cache_seg);
+
+       spin_lock(&cache->seg_map_lock);
+       if (cache->cache_full)
+               cache->cache_full = false;
Perhaps just write cache->cache_full = false unconditionally?
If there is a reason to not do the write, then add a comment here.
Hi Jonathan,

When the cache->cache_full is already false, we don't need to write cache->cache_full with false.


Thanx

Dongsheng



+       clear_bit(cache_seg->cache_seg_id, cache->seg_map);
+       spin_unlock(&cache->seg_map_lock);
+
+       pcache_defer_reqs_kick(CACHE_TO_PCACHE(cache));
+       /* clean_work will clean the bad key in key_tree*/
+       queue_work(cache_get_wq(cache), &cache->clean_work);
+}

Reply via email to