From nobody Fri Dec 19 12:50:27 2025 Received: from sender3-pp-f112.zoho.com (sender3-pp-f112.zoho.com [136.143.184.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 BA40B313E32 for ; Tue, 11 Nov 2025 12:14:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.184.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762863260; cv=pass; b=S8MgyndK2iv7gVbWzPcFXC5Vx/6qWOvyukI6fIOxK21A9OkvmEa1AAMkEkh128Bw86/pnWn2v55vesgQu+XMSHxio5qHmB2ZmWDzj7U7PgMG2DMkt9yw5YBvkM8Uy3t9idDkJssjF081YxrW+KCVP2XA4rYgAaSBA55dYsoTf0M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762863260; c=relaxed/simple; bh=dN55HW4FfkzTBtEO25VWJ9JrD1kDv1xDO/lxQFE+MTg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HRLV0RynU+XN0xcjFevnahanMooYKoFukVZI6AL7YM9P5RBnf8tIA6jM3cnhYfrBYHaajHnISQzUH7SmJAr2ebhx5z66vvtokDP1Xf+AkaCpPfVfzBG1gjVDwdhs7GAkQgWw9prRsBRbkrUtt7iizszbeJ3qqnl4cuV3YpyBrMw= 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=XWvMoxww; arc=pass smtp.client-ip=136.143.184.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="XWvMoxww" ARC-Seal: i=1; a=rsa-sha256; t=1762863230; cv=none; d=zohomail.com; s=zohoarc; b=TiY0i1ybo101BBxI7dKvCHEh6iQtuUXZo7nz1ztUZfGai4a2AhGT6e4HXXbpLsIfZ3HnibbFc45DGfat8tQBMVRoJpZi8vdtNXetE/ZildlXuxdrBjPshcM+9X6UUrrhwSsauM/qD7B1XjthQvkEnMV1eDd1+PMWIOJ/0wUkDEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762863230; 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=4oaOTUtuN2YDsbIeaOrLhfRRJFbe0Y3tgRUZy7WUjE8=; b=Wwc9Cvfq+bCVUpkPdCYZjzqCn2Zs1zKZlOOaa3aQEsieilxHJfZvBk6+AKZXBm+5D2jAc2zK8ghKpZU52com8EYTECseYmVhTdIvk4OBEuwKpR42n2MCcoYJbn6LhXPLWdZDbNq0SsHngljBYtnMYOTLq+Fxf49FR8peFBw4Gtk= 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=1762863230; 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=4oaOTUtuN2YDsbIeaOrLhfRRJFbe0Y3tgRUZy7WUjE8=; b=XWvMoxwwSgojaqGpQrycDpraZaShPE8R3JvLdRCvaeh+v0NsiLkLbBHqCrYJeCvb bE0iNyzNlyjMOMBmVUfoLuZTfknepXFJ6NvWP6aKXUj0H5upkqwrqEERWUszLrt5WoC YDdWN5M4/0NpwNvGZXkgojs1GVcOYvSj5GrWlFXE= Received: by mx.zohomail.com with SMTPS id 1762863226002819.1329271635038; Tue, 11 Nov 2025 04:13:46 -0800 (PST) From: Li Chen To: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Dongsheng Yang , Zheng Gu Subject: [PATCH v2 1/3] dm-pcache: allow built-in build and rename flush helper Date: Tue, 11 Nov 2025 20:13:34 +0800 Message-ID: <20251111121337.1063443-2-me@linux.beauty> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251111121337.1063443-1-me@linux.beauty> References: <20251111121337.1063443-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 CONFIG_BCACHE is tristate, so dm-pcache can also be built-in. Switch the Makefile to use obj-$(CONFIG_DM_PCACHE) so the target can be linked into vmlinux instead of always being a loadable module. Also rename cache_flush() to pcache_cache_flush() to avoid a global symbol clash with sunrpc/cache.c's cache_flush(). Signed-off-by: Li Chen Reviewed-by=EF=BC=9A Dongsheng Yang --- drivers/md/dm-pcache/Makefile | 2 +- drivers/md/dm-pcache/cache.c | 2 +- drivers/md/dm-pcache/cache.h | 2 +- drivers/md/dm-pcache/cache_req.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/md/dm-pcache/Makefile b/drivers/md/dm-pcache/Makefile index 86776e4acad2..cedfd38854f6 100644 --- a/drivers/md/dm-pcache/Makefile +++ b/drivers/md/dm-pcache/Makefile @@ -1,3 +1,3 @@ dm-pcache-y :=3D dm_pcache.o cache_dev.o segment.o backing_dev.o cache.o c= ache_gc.o cache_writeback.o cache_segment.o cache_key.o cache_req.o =20 -obj-m +=3D dm-pcache.o +obj-$(CONFIG_DM_PCACHE) +=3D dm-pcache.o diff --git a/drivers/md/dm-pcache/cache.c b/drivers/md/dm-pcache/cache.c index d8e92367d947..d516d4904227 100644 --- a/drivers/md/dm-pcache/cache.c +++ b/drivers/md/dm-pcache/cache.c @@ -411,7 +411,7 @@ void pcache_cache_stop(struct dm_pcache *pcache) { struct pcache_cache *cache =3D &pcache->cache; =20 - cache_flush(cache); + pcache_cache_flush(cache); =20 cancel_delayed_work_sync(&cache->gc_work); flush_work(&cache->clean_work); diff --git a/drivers/md/dm-pcache/cache.h b/drivers/md/dm-pcache/cache.h index 1136d86958c8..27613b56be54 100644 --- a/drivers/md/dm-pcache/cache.h +++ b/drivers/md/dm-pcache/cache.h @@ -339,7 +339,7 @@ void cache_seg_put(struct pcache_cache_segment *cache_s= eg); void cache_seg_set_next_seg(struct pcache_cache_segment *cache_seg, u32 se= g_id); =20 /* cache request*/ -int cache_flush(struct pcache_cache *cache); +int pcache_cache_flush(struct pcache_cache *cache); void miss_read_end_work_fn(struct work_struct *work); int pcache_cache_handle_req(struct pcache_cache *cache, struct pcache_requ= est *pcache_req); =20 diff --git a/drivers/md/dm-pcache/cache_req.c b/drivers/md/dm-pcache/cache_= req.c index 27f94c1fa968..7854a30e07b7 100644 --- a/drivers/md/dm-pcache/cache_req.c +++ b/drivers/md/dm-pcache/cache_req.c @@ -790,7 +790,7 @@ static int cache_write(struct pcache_cache *cache, stru= ct pcache_request *pcache } =20 /** - * cache_flush - Flush all ksets to persist any pending cache data + * pcache_cache_flush - Flush all ksets to persist any pending cache data * @cache: Pointer to the cache structure * * This function iterates through all ksets associated with the provided `= cache` @@ -802,7 +802,7 @@ static int cache_write(struct pcache_cache *cache, stru= ct pcache_request *pcache * the respective error code, preventing the flush operation from proceedi= ng to * subsequent ksets. */ -int cache_flush(struct pcache_cache *cache) +int pcache_cache_flush(struct pcache_cache *cache) { struct pcache_cache_kset *kset; int ret; @@ -827,7 +827,7 @@ int pcache_cache_handle_req(struct pcache_cache *cache,= struct pcache_request *p struct bio *bio =3D pcache_req->bio; =20 if (unlikely(bio->bi_opf & REQ_PREFLUSH)) - return cache_flush(cache); + return pcache_cache_flush(cache); =20 if (bio_data_dir(bio) =3D=3D READ) return cache_read(cache, pcache_req); --=20 2.51.0 From nobody Fri Dec 19 12:50:27 2025 Received: from sender3-pp-f112.zoho.com (sender3-pp-f112.zoho.com [136.143.184.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 C6B9E313E32 for ; Tue, 11 Nov 2025 12:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.184.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762863276; cv=pass; b=tevoSpJ+lkBq+5hd3Hy2BAVWKO4QvYZEt9pIAty59yQCea02ubxKhQqsm0ZpMWNBh1aVexW5mmH7vJ4NzDEbiSv0D59ND8dDMsGRnZaqRuiDKZA+C4r0Ct4H2K1ci569okhhhQwHuID1/DEo0aDhTy0bYc8IC3eMtPqwarL/xTQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762863276; c=relaxed/simple; bh=xYvHnt73+ArXoWf25mlB0olseCbE6Pe3s3so3DB4RP0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fTIp4dxpBZt7miZGELmfG15zt4m+UNo/2bAUtsg184R4444F934b2EoIdawd6evTxenyUHS3bJ0E/wniC8SvDJmxPeBmLDgJr2TMLwMsbP2KmfbntdmQ21fPFJWaos5gDGea7a1757aOcACEOJgY5aQlzYLzRhMEX0Ic2YVu9Is= 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=UA1MOXPN; arc=pass smtp.client-ip=136.143.184.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="UA1MOXPN" ARC-Seal: i=1; a=rsa-sha256; t=1762863231; cv=none; d=zohomail.com; s=zohoarc; b=lX1iu0UXwB/Hh3T5RvS3ducclCMeLGYssC1Zv8mAQNa0mBfbpLmLFamKv1tEMkkzOWjsLLcTrHqxytp5i3kEWBPS+PqXa4kGW1lhXqVd8QRWkHoXw1r0vfoFY1j8jvld8zw3cDBbGXs19I7Rc426c26fj+DB5TPHogd3+/Tepws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762863231; 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=Qe8C8WW7PdlIqS1nea6IPWW3yId8LkgwE49m8YwS7i8=; b=Tf1LJbxF3k+rBiF+GtoWZgv39vhtdcih/FzwpFqXlJC8eh6uNMTi1gFLiaasrx9YjI2G9FPWlV8W6xcz3NEoaF3wp3Gv+Ir81Png9bmwCMbqC/LKlNBZaTzooIGTeknHACdnKAVUdKJaZ2bl22EAV5fQUpnSvFxX25ckzn87uAU= 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=1762863231; 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=Qe8C8WW7PdlIqS1nea6IPWW3yId8LkgwE49m8YwS7i8=; b=UA1MOXPNejWzEeBRSnkHix83U8pPE3VS5BVnXjzr5YpIQMoYe/Hj+bbxL5pF2E1F ed/5xcNofUB7WhCsYrlqoj6bADPC9VvWODn/Et4obf4wmacc2L5Ymrq7LNBieeUFurr G08j5BfgUkgRrpOeVLHPDn8DsoebYrhWIUvq3F4g= Received: by mx.zohomail.com with SMTPS id 1762863228249716.4687552539734; Tue, 11 Nov 2025 04:13:48 -0800 (PST) From: Li Chen To: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Dongsheng Yang , Zheng Gu Subject: [PATCH v2 2/3] dm-pcache: reuse meta_addr in pcache_meta_find_latest Date: Tue, 11 Nov 2025 20:13:35 +0800 Message-ID: <20251111121337.1063443-3-me@linux.beauty> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251111121337.1063443-1-me@linux.beauty> References: <20251111121337.1063443-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 pcache_meta_find_latest() already computes the metadata address as meta_addr. Reuse that instead of recomputing. Signed-off-by: Li Chen Reviewed-by=EF=BC=9A Dongsheng Yang seq, seq_latest)) { seq_latest =3D meta->seq; - latest =3D (void *)header + (i * meta_max_size); + latest =3D meta_addr; } } =20 --=20 2.51.0 From nobody Fri Dec 19 12:50:27 2025 Received: from sender3-pp-f112.zoho.com (sender3-pp-f112.zoho.com [136.143.184.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 47FFD3587A9 for ; Tue, 11 Nov 2025 12:14:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.184.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762863284; cv=pass; b=GWsz85jOEOJtGg9gvL/GnfHAq/4VI0a9WDp+3jsx8N1OVryyf05alfOvu6+7y9hYx6+Xh9/sMZPM0UxLHUlNleEbtDJS0YfVB/2xwzK0XDv3XtH9MxnmLEcGS3Wos34Yv0cMViPe8yDE8DryCNjvrx2o4Rtk0fAhEwBJ2dVynBs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762863284; c=relaxed/simple; bh=HO/xgZwNfw3SHaM5XQjXQaEpPq4xSdasLKY87kqLdRY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F29VT0d2N2mBYy0Gj2nfmiOBspmPmQwLeqt7qa5KNW0EMsST9rNpZkMwktoMrg0GFcAHpPSFOyFFukD0nH5DlETEdXVKTuGX+cLo+qiVraqWHYFx1zp6ukD/xT3Sld9hvrCrDSSZ2rOTyHK8moAZwG1K1KTfznPMv9BFZJNRr6g= 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=Y29i8Sp/; arc=pass smtp.client-ip=136.143.184.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="Y29i8Sp/" ARC-Seal: i=1; a=rsa-sha256; t=1762863232; cv=none; d=zohomail.com; s=zohoarc; b=VxDJXeAklUcPstyg1cbbbem34q1qZNgFbFwd90VGDEEX5NO8ooZVEYCSWm24t5rW7tfZq6jkF0XLa2cW3bMLTEcTM7Nbt6OZFIuoF8MkRcgh+OyRRUS9ZQUdh3UZUzlB7/o3vjk8G9xz41Ro9X9xCp1NQFhR2MsycmtFK1ZpwbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762863232; h=Content-Type: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=9Kk+Bv9tIcvBVIBGem7wGRwTENm4Q38PWqcUNwLSQXk=; b=JMj/+ILO+0pj5SRmBkVeFtYTdum4ogarozUeW3jhAIR0o1djzcRFT7L5iBXMV9HAtQYnWqoImSApmuxWB/ZNnhirin9Nj8sSZang5j6OcvgDxbxqk1riyAsCVYZpdx8L8tWC12oQxEqKf/Ma9rsfAuAhUHiqtBMaQCTSM7Pl/8o= 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=1762863232; 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-Type:Content-Transfer-Encoding:Message-Id:Reply-To:Cc; bh=9Kk+Bv9tIcvBVIBGem7wGRwTENm4Q38PWqcUNwLSQXk=; b=Y29i8Sp/THToixrSBbZz3gc38wSyJSWK/cLpufYh09zKPYyKaU/XjmjRmRdLjqBm TlZRDa93ejtivnqLN5RenyUn7vgCcuc+9fVVVlKOb/9pZbvdX37j9b0wP/8MuxVV74p 19rGiSCTY5Nf8x8op4VmiX3dLTjlc3nKdvylPQ9c= Received: by mx.zohomail.com with SMTPS id 176286323041672.15557441965711; Tue, 11 Nov 2025 04:13:50 -0800 (PST) From: Li Chen To: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Dongsheng Yang , Zheng Gu Subject: [PATCH v2 3/3] dm-pcache: zero cache_info before default init Date: Tue, 11 Nov 2025 20:13:36 +0800 Message-ID: <20251111121337.1063443-4-me@linux.beauty> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251111121337.1063443-1-me@linux.beauty> References: <20251111121337.1063443-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External From: Li Chen pcache_meta_find_latest() leaves whatever it last copied into the caller=E2=80=99s 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 Reviewed-by: Zheng Gu Reviewed-by=EF=BC=9A Dongsheng Yang --- 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 =3D &cache->cache_info; =20 - cache_info->header.seq =3D 0; + memset(cache_info, 0, sizeof(*cache_info)); cache_info->n_segs =3D cache->cache_dev->seg_num; cache_info_set_gc_percent(cache_info, PCACHE_CACHE_GC_PERCENT_DEFAULT); } --=20 2.51.0