dm_pcache_status(STATUSTYPE_TABLE) emits "crc %s", but pcache_parse_args()
only recognizes "data_crc". The string produced by STATUSTYPE_TABLE is what
`dmsetup table` prints and what userspace feeds back to reload or restore a
mapping (dmsetup create/load, initramfs generators, LVM metadata). Because
the two spellings differ, a pcache mapping cannot be restored:
device-mapper: table: 252:0: pcache: Unrecognised cache option requested
Documentation/admin-guide/device-mapper/dm-pcache.rst documents the option
as "data_crc true|false", and the parser and the docs agree; only the status
output is wrong. Print "data_crc" so the status is re-loadable.
Reproducer, on a kernel with CONFIG_DM_PCACHE=m and a DAX-capable device:
dmsetup create pc --table "0 524288 pcache /dev/pmem0 /dev/vda 4 \
cache_mode writeback data_crc true"
dmsetup table pc
-> 0 524288 pcache 259:0 253:0 4 cache_mode writeback crc true
dmsetup remove pc
dmsetup create pc2 --table "0 524288 pcache 259:0 253:0 4 \
cache_mode writeback crc true"
-> Unrecognised cache option requested
Tested in QEMU (virtio-pmem + virtio-blk, KASAN kernel):
before: step 4 fails with -EINVAL
after: step 4 succeeds, mapping is active, direct I/O to the mapping
works in both directions
Fixes: 1d57628ff95b ("dm-pcache: add persistent cache target in device-mapper")
Cc: [email protected]
Assisted-by: Hermes: Deepseek v4
Signed-off-by: Ruiqiang Hao <[email protected]>
---
drivers/md/dm-pcache/dm_pcache.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-pcache/dm_pcache.c b/drivers/md/dm-pcache/dm_pcache.c
index 645fc27d82ba..5d26aa6bcf0b 100644
--- a/drivers/md/dm-pcache/dm_pcache.c
+++ b/drivers/md/dm-pcache/dm_pcache.c
@@ -424,7 +424,11 @@ static void dm_pcache_status(struct dm_target *ti,
status_type_t type,
cache->key_tail.seg_off);
break;
case STATUSTYPE_TABLE:
- DMEMIT("%s %s 4 cache_mode writeback crc %s",
+ /*
+ * Must be re-loadable by pcache_parse_args(), which accepts
+ * "data_crc", not "crc".
+ */
+ DMEMIT("%s %s 4 cache_mode writeback data_crc %s",
cache_dev->dm_dev->name,
backing_dev->dm_dev->name,
cache_data_crc_on(cache) ? "true" : "false");
--
2.43.0