|
|
f954f3 |
From 4b576a8e0eb99ec1a79ca432350fb7ac27a5c089 Mon Sep 17 00:00:00 2001
|
|
|
f954f3 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
f954f3 |
Date: Mon, 26 Jul 2021 11:59:43 +0100
|
|
|
f954f3 |
Subject: [PATCH] cache: Reduce verbosity of debugging
|
|
|
f954f3 |
|
|
|
f954f3 |
The cache filter is very verbose in its debugging. Reduce the default
|
|
|
f954f3 |
level. Use -D cache.verbose=1 to restore original debugging.
|
|
|
f954f3 |
|
|
|
f954f3 |
Compare commit 745a0f13662031c2b9c9b69f62b4ae3a6b2f38f0.
|
|
|
f954f3 |
|
|
|
f954f3 |
(cherry picked from commit 6be735edf7d5fb3fb8350c72e6d9525badbab14d)
|
|
|
f954f3 |
---
|
|
|
f954f3 |
filters/cache/blk.c | 53 +++++++++++++++++++++++++++------------------
|
|
|
f954f3 |
1 file changed, 32 insertions(+), 21 deletions(-)
|
|
|
f954f3 |
|
|
|
f954f3 |
diff --git a/filters/cache/blk.c b/filters/cache/blk.c
|
|
|
f954f3 |
index 12e8407e..f52f30e3 100644
|
|
|
f954f3 |
--- a/filters/cache/blk.c
|
|
|
f954f3 |
+++ b/filters/cache/blk.c
|
|
|
f954f3 |
@@ -93,6 +93,9 @@ enum bm_entry {
|
|
|
f954f3 |
BLOCK_DIRTY = 3,
|
|
|
f954f3 |
};
|
|
|
f954f3 |
|
|
|
f954f3 |
+/* Extra debugging (-D cache.verbose=1). */
|
|
|
f954f3 |
+NBDKIT_DLL_PUBLIC int cache_debug_verbose = 0;
|
|
|
f954f3 |
+
|
|
|
f954f3 |
int
|
|
|
f954f3 |
blk_init (void)
|
|
|
f954f3 |
{
|
|
|
f954f3 |
@@ -199,12 +202,14 @@ blk_read (nbdkit_next *next,
|
|
|
f954f3 |
|
|
|
f954f3 |
reclaim (fd, &bm;;
|
|
|
f954f3 |
|
|
|
f954f3 |
- nbdkit_debug ("cache: blk_read block %" PRIu64 " (offset %" PRIu64 ") is %s",
|
|
|
f954f3 |
- blknum, (uint64_t) offset,
|
|
|
f954f3 |
- state == BLOCK_NOT_CACHED ? "not cached" :
|
|
|
f954f3 |
- state == BLOCK_CLEAN ? "clean" :
|
|
|
f954f3 |
- state == BLOCK_DIRTY ? "dirty" :
|
|
|
f954f3 |
- "unknown");
|
|
|
f954f3 |
+ if (cache_debug_verbose)
|
|
|
f954f3 |
+ nbdkit_debug ("cache: blk_read block %" PRIu64
|
|
|
f954f3 |
+ " (offset %" PRIu64 ") is %s",
|
|
|
f954f3 |
+ blknum, (uint64_t) offset,
|
|
|
f954f3 |
+ state == BLOCK_NOT_CACHED ? "not cached" :
|
|
|
f954f3 |
+ state == BLOCK_CLEAN ? "clean" :
|
|
|
f954f3 |
+ state == BLOCK_DIRTY ? "dirty" :
|
|
|
f954f3 |
+ "unknown");
|
|
|
f954f3 |
|
|
|
f954f3 |
if (state == BLOCK_NOT_CACHED) { /* Read underlying plugin. */
|
|
|
f954f3 |
unsigned n = blksize, tail = 0;
|
|
|
f954f3 |
@@ -225,9 +230,10 @@ blk_read (nbdkit_next *next,
|
|
|
f954f3 |
|
|
|
f954f3 |
/* If cache-on-read, copy the block to the cache. */
|
|
|
f954f3 |
if (cache_on_read) {
|
|
|
f954f3 |
- nbdkit_debug ("cache: cache-on-read block %" PRIu64
|
|
|
f954f3 |
- " (offset %" PRIu64 ")",
|
|
|
f954f3 |
- blknum, (uint64_t) offset);
|
|
|
f954f3 |
+ if (cache_debug_verbose)
|
|
|
f954f3 |
+ nbdkit_debug ("cache: cache-on-read block %" PRIu64
|
|
|
f954f3 |
+ " (offset %" PRIu64 ")",
|
|
|
f954f3 |
+ blknum, (uint64_t) offset);
|
|
|
f954f3 |
|
|
|
f954f3 |
if (pwrite (fd, block, blksize, offset) == -1) {
|
|
|
f954f3 |
*err = errno;
|
|
|
f954f3 |
@@ -259,12 +265,14 @@ blk_cache (nbdkit_next *next,
|
|
|
f954f3 |
|
|
|
f954f3 |
reclaim (fd, &bm;;
|
|
|
f954f3 |
|
|
|
f954f3 |
- nbdkit_debug ("cache: blk_cache block %" PRIu64 " (offset %" PRIu64 ") is %s",
|
|
|
f954f3 |
- blknum, (uint64_t) offset,
|
|
|
f954f3 |
- state == BLOCK_NOT_CACHED ? "not cached" :
|
|
|
f954f3 |
- state == BLOCK_CLEAN ? "clean" :
|
|
|
f954f3 |
- state == BLOCK_DIRTY ? "dirty" :
|
|
|
f954f3 |
- "unknown");
|
|
|
f954f3 |
+ if (cache_debug_verbose)
|
|
|
f954f3 |
+ nbdkit_debug ("cache: blk_cache block %" PRIu64
|
|
|
f954f3 |
+ " (offset %" PRIu64 ") is %s",
|
|
|
f954f3 |
+ blknum, (uint64_t) offset,
|
|
|
f954f3 |
+ state == BLOCK_NOT_CACHED ? "not cached" :
|
|
|
f954f3 |
+ state == BLOCK_CLEAN ? "clean" :
|
|
|
f954f3 |
+ state == BLOCK_DIRTY ? "dirty" :
|
|
|
f954f3 |
+ "unknown");
|
|
|
f954f3 |
|
|
|
f954f3 |
if (state == BLOCK_NOT_CACHED) {
|
|
|
f954f3 |
/* Read underlying plugin, copy to cache regardless of cache-on-read. */
|
|
|
f954f3 |
@@ -284,8 +292,9 @@ blk_cache (nbdkit_next *next,
|
|
|
f954f3 |
*/
|
|
|
f954f3 |
memset (block + n, 0, tail);
|
|
|
f954f3 |
|
|
|
f954f3 |
- nbdkit_debug ("cache: cache block %" PRIu64 " (offset %" PRIu64 ")",
|
|
|
f954f3 |
- blknum, (uint64_t) offset);
|
|
|
f954f3 |
+ if (cache_debug_verbose)
|
|
|
f954f3 |
+ nbdkit_debug ("cache: cache block %" PRIu64 " (offset %" PRIu64 ")",
|
|
|
f954f3 |
+ blknum, (uint64_t) offset);
|
|
|
f954f3 |
|
|
|
f954f3 |
if (pwrite (fd, block, blksize, offset) == -1) {
|
|
|
f954f3 |
*err = errno;
|
|
|
f954f3 |
@@ -324,8 +333,9 @@ blk_writethrough (nbdkit_next *next,
|
|
|
f954f3 |
|
|
|
f954f3 |
reclaim (fd, &bm;;
|
|
|
f954f3 |
|
|
|
f954f3 |
- nbdkit_debug ("cache: writethrough block %" PRIu64 " (offset %" PRIu64 ")",
|
|
|
f954f3 |
- blknum, (uint64_t) offset);
|
|
|
f954f3 |
+ if (cache_debug_verbose)
|
|
|
f954f3 |
+ nbdkit_debug ("cache: writethrough block %" PRIu64 " (offset %" PRIu64 ")",
|
|
|
f954f3 |
+ blknum, (uint64_t) offset);
|
|
|
f954f3 |
|
|
|
f954f3 |
if (pwrite (fd, block, blksize, offset) == -1) {
|
|
|
f954f3 |
*err = errno;
|
|
|
f954f3 |
@@ -357,8 +367,9 @@ blk_write (nbdkit_next *next,
|
|
|
f954f3 |
|
|
|
f954f3 |
reclaim (fd, &bm;;
|
|
|
f954f3 |
|
|
|
f954f3 |
- nbdkit_debug ("cache: writeback block %" PRIu64 " (offset %" PRIu64 ")",
|
|
|
f954f3 |
- blknum, (uint64_t) offset);
|
|
|
f954f3 |
+ if (cache_debug_verbose)
|
|
|
f954f3 |
+ nbdkit_debug ("cache: writeback block %" PRIu64 " (offset %" PRIu64 ")",
|
|
|
f954f3 |
+ blknum, (uint64_t) offset);
|
|
|
f954f3 |
|
|
|
f954f3 |
if (pwrite (fd, block, blksize, offset) == -1) {
|
|
|
f954f3 |
*err = errno;
|
|
|
f954f3 |
--
|
|
|
f954f3 |
2.31.1
|
|
|
f954f3 |
|