From d2ed77d1b8fedcba3aedadeed883553886f4bb56 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 9 Aug 2021 14:09:31 +0100 Subject: [PATCH] cow: Add some more debugging especially for blk_read_multiple and cow-on-read Only activated when we use -D cow.verbose=1 (cherry picked from commit 2da1ae0ca966af955d8fcf3feffffc80d07142fd) --- filters/cow/blk.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/filters/cow/blk.c b/filters/cow/blk.c index 9d42b5fc..879f471a 100644 --- a/filters/cow/blk.c +++ b/filters/cow/blk.c @@ -258,8 +258,10 @@ blk_read_multiple (nbdkit_next *next, if (cow_debug_verbose) nbdkit_debug ("cow: blk_read_multiple block %" PRIu64 - " (offset %" PRIu64 ") is %s", - blknum, (uint64_t) offset, state_to_string (state)); + " (offset %" PRIu64 ") run of length %" PRIu64 + " is %s", + blknum, (uint64_t) offset, runblocks, + state_to_string (state)); if (state == BLOCK_NOT_ALLOCATED) { /* Read underlying plugin. */ unsigned n, tail = 0; @@ -285,6 +287,11 @@ blk_read_multiple (nbdkit_next *next, * set them as allocated. */ if (cow_on_read) { + if (cow_debug_verbose) + nbdkit_debug ("cow: cow-on-read saving %" PRIu64 " blocks " + "at offset %" PRIu64 " into the cache", + runblocks, offset); + if (full_pwrite (fd, block, BLKSIZE * runblocks, offset) == -1) { *err = errno; nbdkit_error ("pwrite: %m"); -- 2.31.1