[Devel] [PATCH vz9] dm-ploop: add message to dump BAT page to kernel messages
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Mon May 20 14:51:02 MSK 2024
In case we need to debug in memory BAT state add interface
to dump it to kernel log
https://virtuozzo.atlassian.net/browse/PSBM-156565
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
drivers/md/dm-ploop-cmd.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 71f854c509f82..2fe75198da949 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -564,6 +564,28 @@ void ploop_free_pio_with_pages(struct ploop *ploop, struct pio *pio)
kfree(pio);
}
+static void hexdump8(unsigned char *buf, unsigned int len)
+{
+ print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ buf, len, false);
+}
+
+static int ploop_dump_page_nr(struct ploop *ploop, unsigned int page_nr)
+{
+ struct md_page *md;
+ unsigned char *data;
+
+ md = ploop_md_page_find(ploop, page_nr);
+ if (!md)
+ return -EIO;
+
+ data = kmap(md->page);
+ hexdump8(data, PAGE_SIZE);
+ kunmap(md->page);
+ return 0;
+}
+
/* @new_size is in sectors */
/* TODO: we may delegate this to userspace */
static int ploop_resize(struct ploop *ploop, sector_t new_sectors)
@@ -1245,6 +1267,10 @@ int ploop_message(struct dm_target *ti, unsigned int argc, char **argv,
if (argc != 1)
goto unlock;
ret = ploop_write_bat_to_file(ploop);
+ } else if (!strcmp(argv[0], "dump_bat_page")) {
+ if (argc != 2 || kstrtou64(argv[1], 10, &val) < 0)
+ goto unlock;
+ ret = ploop_dump_page_nr(ploop, val);
} else {
ret = -ENOTSUPP;
}
--
2.43.0
More information about the Devel
mailing list