dm-pcache: fix metadata indexing and persistence issues
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 9 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | dm pcache: fix cache info indexingdrivers/ | +10 | 2 replies | |
| 2/2 | dm pcache: fix segment info indexingdrivers/ | +5 | 2 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] dm-pcache: fix metadata indexing and persistence issues
From: Li Chen <[email protected]>
dm-pcache stores metadata (cache_info and segment_info) in 4K-aligned slots on the cache device, using sequence numbers and CRC to identify the latest valid copy.
However, the cache_info and segment_info paths were computing their on-media index using sizeof(struct) instead of the 4K metadata stride. As a result:
* cache_info updates (including gc_percent set via a dmsetup message) were written to invalid offsets between metadata slots and failed to persist across table reloads or reboots.
* segment_info indexing became desynchronized, so rotation to the "next" slot no longer matched the location returned by pcache_meta_find_latest().
The issue can be reproduced with:
dmsetup create pcache_vdb --table \
"0 $(blockdev --getsz /dev/vdb) pcache /dev/pmem0 /dev/vdb 4 \
cache_mode writeback data_crc false" # Check default gc_percent (70)
dmsetup status pcache_vdb
# Change gc_percent to 10
dmsetup message pcache_vdb 0 "gc_percent 10"
# Verify change is active in memory
dmsetup status pcache_vdb
# Reboot the system...
# Without patch (gc_percent reverts to 70):
dmsetup status pcache_vdb
# With patch (gc_percent persists as 10):
dmsetup status pcache_vdb
This series fixes the issue by deriving the metadata slot index from the pointer returned by pcache_meta_find_latest(), using the 4K stride (CACHE_INFO_SIZE / SEG_INFO_SIZE). This ensures that updates to cache_info and segment_info are written to valid slots and remain consistent with the on-media layout.
Li Chen (2):
dm pcache: fix cache info indexing
dm pcache: fix segment info indexing
drivers/md/dm-pcache/cache.c | 13 ++++++++++--- drivers/md/dm-pcache/cache_segment.c | 6 +++++- 2 files changed, 15 insertions(+), 4 deletions(-)
Signature · 1 line
2.51.0