linux/drivers/md/dm-pcache
Dongsheng Yang 3383f16f78 dm-pcache: advance slot index before writing slot
commit ebbb90344a upstream.

In dm-pcache, in order to ensure crash-consistency, a dual-copy scheme
is used to alternately update metadata, and there is a slot index that
records the current slot. However, in the write path the current
implementation writes directly to the current slot indexed by slot
index, and then advances the slot — which ends up overwriting the
existing slot, violating the crash-consistency guarantee.

This patch fixes that behavior, preventing metadata from being
overwritten incorrectly.

In addition, this patch add a missing pmem_wmb() after memcpy_flushcache().

Signed-off-by: Dongsheng Yang <dongsheng.yang@linux.dev>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Zheng Gu <cengku@gmail.com>
Cc: stable@vger.kernel.org	# 6.18
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-01-02 12:57:19 +01:00
..
backing_dev.c dm-pcache: add persistent cache target in device-mapper 2025-08-25 15:25:29 +02:00
backing_dev.h dm-pcache: add persistent cache target in device-mapper 2025-08-25 15:25:29 +02:00
cache.c dm-pcache: advance slot index before writing slot 2026-01-02 12:57:19 +01:00
cache.h dm-pcache: allow built-in build and rename flush helper 2025-11-18 19:01:47 +01:00
cache_dev.c dm-pcache: add persistent cache target in device-mapper 2025-08-25 15:25:29 +02:00
cache_dev.h dm-pcache: add persistent cache target in device-mapper 2025-08-25 15:25:29 +02:00
cache_gc.c dm-pcache: add persistent cache target in device-mapper 2025-08-25 15:25:29 +02:00
cache_key.c dm-pcache: add persistent cache target in device-mapper 2025-08-25 15:25:29 +02:00
cache_req.c dm-pcache: allow built-in build and rename flush helper 2025-11-18 19:01:47 +01:00
cache_segment.c dm-pcache: advance slot index before writing slot 2026-01-02 12:57:19 +01:00
cache_writeback.c dm-pcache: add persistent cache target in device-mapper 2025-08-25 15:25:29 +02:00
dm_pcache.c dm-pcache: add persistent cache target in device-mapper 2025-08-25 15:25:29 +02:00
dm_pcache.h dm-pcache: add persistent cache target in device-mapper 2025-08-25 15:25:29 +02:00
Kconfig dm-pcache: add persistent cache target in device-mapper 2025-08-25 15:25:29 +02:00
Makefile dm-pcache: allow built-in build and rename flush helper 2025-11-18 19:01:47 +01:00
pcache_internal.h dm-pcache: reuse meta_addr in pcache_meta_find_latest 2025-11-18 19:01:57 +01:00
segment.c dm-pcache: add persistent cache target in device-mapper 2025-08-25 15:25:29 +02:00
segment.h dm-pcache: add persistent cache target in device-mapper 2025-08-25 15:25:29 +02:00