diff options
| author | Li Chen <chenl311@chinatelecom.cn> | 2025-11-11 20:13:36 +0800 |
|---|---|---|
| committer | Mikulas Patocka <mpatocka@redhat.com> | 2025-11-18 19:02:08 +0100 |
| commit | a6ee8422b4f2a591de010f4e60471060b13d4170 (patch) | |
| tree | 6e63c2a9661c33a000622882f780aa3c4eafb790 | |
| parent | 840b80af74fda9672f111023ca17ad7875427f13 (diff) | |
dm-pcache: zero cache_info before default init
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 <chenl311@chinatelecom.cn>
Reviewed-by: Zheng Gu <cengku@gmail.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
| -rw-r--r-- | drivers/md/dm-pcache/cache.c | 2 |
1 files changed, 1 insertions, 1 deletions
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); } |
