在 11/11/2025 8:13 PM, Li Chen 写道:
From: Li Chen <[email protected]>

pcache_meta_find_latest() leaves whatever it last copied into the
caller’s buffer even when it returns NULL. For cache_info_init(),
that meant cache->cache_info could still contain CRC-bad garbage when
no valid metadata exists, leading later initialization paths to read
bogus flags.

Explicitly memset cache->cache_info in cache_info_init_default()
so new-cache paths start from a clean slate. The default sequence
number assignment becomes redundant with this reset, so it drops out.

Signed-off-by: Li Chen <[email protected]>

Reviewed-by: Dongsheng Yang <[email protected]>

---
  drivers/md/dm-pcache/cache.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-pcache/cache.c b/drivers/md/dm-pcache/cache.c
index d516d4904227..698697a7a73c 100644
--- a/drivers/md/dm-pcache/cache.c
+++ b/drivers/md/dm-pcache/cache.c
@@ -181,7 +181,7 @@ static void cache_info_init_default(struct pcache_cache 
*cache)
  {
        struct pcache_cache_info *cache_info = &cache->cache_info;
- cache_info->header.seq = 0;
+       memset(cache_info, 0, sizeof(*cache_info));
        cache_info->n_segs = cache->cache_dev->seg_num;
        cache_info_set_gc_percent(cache_info, PCACHE_CACHE_GC_PERCENT_DEFAULT);
  }

Reply via email to