All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dongsheng Yang <dongsheng.yang@linux.dev>
To: Li Chen <me@linux.beauty>,
	dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
	Zheng Gu <cengku@gmail.com>
Subject: Re: [PATCH v2 3/3] dm-pcache: zero cache_info before default init
Date: Thu, 13 Nov 2025 14:40:19 +0800	[thread overview]
Message-ID: <b24702f2-ea70-4c45-b0a9-dae9cc6104a3@linux.dev> (raw)
In-Reply-To: <20251111121337.1063443-4-me@linux.beauty>


在 11/11/2025 8:13 PM, Li Chen 写道:
> From: Li Chen <chenl311@chinatelecom.cn>
>
> 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: Dongsheng Yang <dongsheng.yang@linux.dev>

> ---
>   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);
>   }

  parent reply	other threads:[~2025-11-13  6:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-11 12:13 [PATCH v2 0/3] dm-pcache: built-in support and metadata hardening Li Chen
2025-11-11 12:13 ` [PATCH v2 1/3] dm-pcache: allow built-in build and rename flush helper Li Chen
2025-11-13  6:39   ` Dongsheng Yang
2025-11-11 12:13 ` [PATCH v2 2/3] dm-pcache: reuse meta_addr in pcache_meta_find_latest Li Chen
2025-11-13  6:40   ` Dongsheng Yang
2025-11-11 12:13 ` [PATCH v2 3/3] dm-pcache: zero cache_info before default init Li Chen
2025-11-12  8:24   ` Zheng Gu
2025-11-13  6:40   ` Dongsheng Yang [this message]
2025-11-13  6:43 ` [PATCH v2 0/3] dm-pcache: built-in support and metadata hardening Dongsheng Yang
2025-11-18 18:05   ` Mikulas Patocka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b24702f2-ea70-4c45-b0a9-dae9cc6104a3@linux.dev \
    --to=dongsheng.yang@linux.dev \
    --cc=cengku@gmail.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@linux.beauty \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.