From nobody Sun Feb 8 14:34:29 2026 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56C563126C1 for ; Tue, 2 Dec 2025 12:12:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764677550; cv=pass; b=YyYtqJYAfeuOmSk0A687Z4oXrJCfzwDgsOphYdeYMb8zBTHPhmu5A8L4JlCuOZFr0F1tt3BtjRtJz85aDy3VjSSJdTLtzflNqYznndGdXb+kG7c/7OvuCoV0lWGXhn026ZgqhawJlwUvMnD4S0pq/BbpQMscEFUvMrHA6nS+HAo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764677550; c=relaxed/simple; bh=TS6mDIsZor5eFsA8Qomc44SHWTWyqbcVSNNej0FQRFQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m6uwGEE70CLLzviqcruE18RO85C93Rgn3lvhBpnj56px07OP//2lhKEabitMPlhVQexTuRvpgxGxHHg39NjPDDpMO2oNkUmV/HUj/AyHnejVdDYVV/0EavG+F58h5u2rTF4vuOdfeXQpMncjNboEL4ZL28UFSmgLXsGqa2d6d1I= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty; spf=pass smtp.mailfrom=linux.beauty; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b=loP/if0E; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.beauty Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b="loP/if0E" ARC-Seal: i=1; a=rsa-sha256; t=1764677526; cv=none; d=zohomail.com; s=zohoarc; b=Aa3a8Xjitv/DiomLV1hHZ6Co0GSZKjfnxKkHGmreHLwlw2+hJxhquIsOOA3bn9NMRTeMcTf+XmQYxeJArPRvqOA+AGmgk6sF0ArNZlA8wG1lOuqCt15JnBqGg4UfCYo5IPxTUkjzcMk86S+731WHaFewQW3viFidZdP1Hxs7WOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764677526; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=vAsEvzdYup53HdslfNVkhOI9I6zIwVzd9GgWg/CjMWU=; b=O8Au0+oWzNfsyra5UsX8+rIUcYHuaOQi+NL9k5lj59HdTnpWSVjeiSjY9lyKVRFJc0nadZ8h0SfHAq7ZWnDsgcRUj4HhOA5KCLcJUZMnysLB39BTtokI7YXkafGd6/ZWVGCC40G5P5F3A94udGxKLtXeA8TPaeBXQtkB3zIc9cU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1764677526; s=zmail; d=linux.beauty; i=me@linux.beauty; h=From:From:To:To:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To:Cc; bh=vAsEvzdYup53HdslfNVkhOI9I6zIwVzd9GgWg/CjMWU=; b=loP/if0EwNtk5y7nYZ+RX4Q2sXafbK8TwjnrKChkdceuXmAMgwkADnzvQtFubMXB v8sT/Stn+G7iLdHbGZQ8731jdwKZXD6aUvRbZZMw/6E416AtRkj6ftcLNJIJjFaTAYB X/ZakgieJv8STxAs1Ekc2kqUEs9aRaUuUZkaLhHM= Received: by mx.zohomail.com with SMTPS id 1764677525155931.6215095890258; Tue, 2 Dec 2025 04:12:05 -0800 (PST) From: Li Chen To: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Dongsheng Yang , Zheng Gu Subject: [PATCH 1/2] dm pcache: fix cache info indexing Date: Tue, 2 Dec 2025 20:11:57 +0800 Message-ID: <20251202121158.111092-2-me@linux.beauty> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251202121158.111092-1-me@linux.beauty> References: <20251202121158.111092-1-me@linux.beauty> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" From: Li Chen The on-media cache_info index used sizeof(struct) instead of the 4K metadata stride, so gc_percent updates from dmsetup message were written between slots and lost after reboot. Use PCACHE_CACHE_INFO_SIZE in get_cache_info_addr() and align info_index with the slot returned by pcache_meta_find_latest(). Signed-off-by: Li Chen --- drivers/md/dm-pcache/cache.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-pcache/cache.c b/drivers/md/dm-pcache/cache.c index 698697a7a73c..6d5001548628 100644 --- a/drivers/md/dm-pcache/cache.c +++ b/drivers/md/dm-pcache/cache.c @@ -8,9 +8,11 @@ =20 struct kmem_cache *key_cache; =20 -static inline struct pcache_cache_info *get_cache_info_addr(struct pcache_= cache *cache) +static inline struct pcache_cache_info * +get_cache_info_addr(struct pcache_cache *cache) { - return cache->cache_info_addr + cache->info_index; + return (struct pcache_cache_info *)((char *)cache->cache_info_addr + + (size_t)cache->info_index * PCACHE_CACHE_INFO_SIZE); } =20 static void cache_info_write(struct pcache_cache *cache) @@ -40,7 +42,12 @@ static int cache_info_init(struct pcache_cache *cache, s= truct pcache_cache_optio if (IS_ERR(cache_info_addr)) return PTR_ERR(cache_info_addr); =20 - if (cache_info_addr) { + if (cache_info_addr) { + int index =3D ((char *)cache_info_addr - (char *)cache->cache_info_addr)= / + PCACHE_CACHE_INFO_SIZE; + + cache->info_index =3D (index + 1) % PCACHE_META_INDEX_MAX; + if (opts->data_crc !=3D (cache->cache_info.flags & PCACHE_CACHE_FLAGS_DATA_CRC)) { pcache_dev_err(pcache, "invalid option for data_crc: %s, expected: %s", --=20 2.51.0 From nobody Sun Feb 8 14:34:29 2026 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A736311C21 for ; Tue, 2 Dec 2025 12:12:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764677558; cv=pass; b=UiC0QPbnQQ6grfhTxOrRtroGX0L2VEpIphfzFq22ukgNQSsDDJywbEHgv/YXxcR3RI/dLnwfIgVm7o1FzTbyY+QoiQhYECcJI9T5AUVCwteeYX/jV4OnP1J7fcJ2aV+N7znCDOiDCOtMsypZ7CmTK1pHTHAKHlt/UTkgbhh2pc4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764677558; c=relaxed/simple; bh=tcTO13kKW/JdRxqJLkFgCIopsa50aOCNy/R5ovgeuYw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DkYs0JYDQJNfAZ2xmAhuewf9Fb21J8P44W9n8m8i/8wYs+fLF4zy8djtZxyg+FNTSFOsct6f6xqiliUGCgh0QH2k6hYG2WQBsoXmkV06WHZWznQyDWCUt9Q92UQVqu1HB1PUlOqtNRwoEE1nAW6mgtAaflAtRkz9hmLcHVFFvlY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty; spf=pass smtp.mailfrom=linux.beauty; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b=hQDVJoP3; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.beauty Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b="hQDVJoP3" ARC-Seal: i=1; a=rsa-sha256; t=1764677528; cv=none; d=zohomail.com; s=zohoarc; b=czjPwDvM0SWNOoWbfl0wY3VkWEh+4AZ1U1tDDEC6sQtr1lX8VQufJrvQ1FzxtXBlznGc7W8eo1R/hgC34jUggWGd6rulY9BHdJImq8/uyDQhXZ+FJBI3soETICrK7IVffFlSwI0HYDPcb/e7B9YmkuGEbODcMcdUn8FUHpPPfEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764677528; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=/THr4U3rxJNaFh3h9M6B25ZG2LY68Uc4k3xBNPI30Ts=; b=ZBplEIfRE3cpDDJJLklTXOrDPu4vpOTZZhKWK2OqFQBVVnjRB5e+n5Uf1K1NbzcfMSDVRLrlrU5jm9yEHoOrL5VM8y9gqRig74Hwi1RD4SaUTAZu89QIygfuMCKS/gGnpGAqnZr4AqUPDT9x5F7hVV4y0U2L6F0dApwnFRXUg24= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1764677528; s=zmail; d=linux.beauty; i=me@linux.beauty; h=From:From:To:To:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To:Cc; bh=/THr4U3rxJNaFh3h9M6B25ZG2LY68Uc4k3xBNPI30Ts=; b=hQDVJoP3/ChXPHlGuz8WwMxddzC9+YSwY44nuprBid35UBi7TwzLKixHQFT5u1uT 3geZ/xCPeoopmGOs3Kpt3ZHw3kptkt1/RLHj/oJU3ZWA4HzHpu2HMIzqIiy9qHZLpHR gGtTRoCFF3UHBQ1pmSRpD5WqpVUfHix+qtpHC/w4= Received: by mx.zohomail.com with SMTPS id 1764677526770286.1221850599361; Tue, 2 Dec 2025 04:12:06 -0800 (PST) From: Li Chen To: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Dongsheng Yang , Zheng Gu Subject: [PATCH 2/2] dm pcache: fix segment info indexing Date: Tue, 2 Dec 2025 20:11:58 +0800 Message-ID: <20251202121158.111092-3-me@linux.beauty> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251202121158.111092-1-me@linux.beauty> References: <20251202121158.111092-1-me@linux.beauty> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" From: Li Chen Segment info indexing also used sizeof(struct) instead of the 4K metadata stride, so info_index could point between slots and subsequent writes would advance incorrectly. Derive info_index from the pointer returned by the segment meta search using PCACHE_SEG_INFO_SIZE and advance to the next slot for future updates. Signed-off-by: Li Chen --- drivers/md/dm-pcache/cache_segment.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-pcache/cache_segment.c b/drivers/md/dm-pcache/ca= che_segment.c index f0b58980806e..0b4bb08011ce 100644 --- a/drivers/md/dm-pcache/cache_segment.c +++ b/drivers/md/dm-pcache/cache_segment.c @@ -56,7 +56,11 @@ static int cache_seg_info_load(struct pcache_cache_segme= nt *cache_seg) ret =3D -EIO; goto out; } - cache_seg->info_index =3D cache_seg_info_addr - cache_seg_info_addr_base; + + cache_seg->info_index =3D + ((char *)cache_seg_info_addr - (char *)cache_seg_info_addr_base) / + PCACHE_SEG_INFO_SIZE; + cache_seg->info_index =3D (cache_seg->info_index + 1) % PCACHE_META_INDEX= _MAX; out: mutex_unlock(&cache_seg->info_lock); =20 --=20 2.51.0