Blame SOURCES/1112-btrfs-progs-receive-add-debug-messages-when-processi.patch

Boris Burkov 40ef45
From 6c27db46dacb827f46dfbd5fa83c828fd81db991 Mon Sep 17 00:00:00 2001
Boris Burkov 40ef45
Message-Id: <6c27db46dacb827f46dfbd5fa83c828fd81db991.1668799549.git.boris@bur.io>
Boris Burkov 40ef45
In-Reply-To: <cover.1668799549.git.boris@bur.io>
Boris Burkov 40ef45
References: <cover.1668799549.git.boris@bur.io>
Boris Burkov 40ef45
From: Filipe Manana <fdmanana@suse.com>
Boris Burkov 40ef45
Date: Tue, 15 Nov 2022 16:25:24 +0000
Boris Burkov 40ef45
Subject: [PATCH 1/3] btrfs-progs: receive: add debug messages when processing
Boris Burkov 40ef45
 encoded writes
Boris Burkov 40ef45
Boris Burkov 40ef45
Unlike for commands from the v1 stream, we have no debug messages logged
Boris Burkov 40ef45
when processing encoded write commands, which makes it harder to debug
Boris Burkov 40ef45
issues.
Boris Burkov 40ef45
Boris Burkov 40ef45
So add log messages, when the log verbosity level is >= 3, for encoded
Boris Burkov 40ef45
write commands, mentioning the value of all fields and also log when we
Boris Burkov 40ef45
fallback from an encoded write to the decompress and write approach.
Boris Burkov 40ef45
Boris Burkov 40ef45
The log messages look like this:
Boris Burkov 40ef45
Boris Burkov 40ef45
  encoded_write f3 - offset=33792, len=4096, unencoded_offset=33792, unencoded_file_len=31744, unencoded_len=65536, compression=1, encryption=0
Boris Burkov 40ef45
  encoded_write f3 - falling back to decompress and write due to errno 22 ("Invalid argument")
Boris Burkov 40ef45
Boris Burkov 40ef45
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Boris Burkov 40ef45
Reviewed-by: Boris Burkov <boris@bur.io>
Boris Burkov 40ef45
---
Boris Burkov 40ef45
 cmds/receive.c | 11 +++++++++++
Boris Burkov 40ef45
 1 file changed, 11 insertions(+)
Boris Burkov 40ef45
Boris Burkov 40ef45
diff --git a/cmds/receive.c b/cmds/receive.c
Boris Burkov 40ef45
index af3138d5..ce615e7c 100644
Boris Burkov 40ef45
--- a/cmds/receive.c
Boris Burkov 40ef45
+++ b/cmds/receive.c
Boris Burkov 40ef45
@@ -1246,6 +1246,13 @@ static int process_encoded_write(const char *path, const void *data, u64 offset,
Boris Burkov 40ef45
 		.encryption = encryption,
Boris Burkov 40ef45
 	};
Boris Burkov 40ef45
 
Boris Burkov 40ef45
+	if (bconf.verbose >= 3)
Boris Burkov 40ef45
+		fprintf(stderr,
Boris Burkov 40ef45
+"encoded_write %s - offset=%llu, len=%llu, unencoded_offset=%llu, unencoded_file_len=%llu, unencoded_len=%llu, compression=%u, encryption=%u\n",
Boris Burkov 40ef45
+			path, offset, len, unencoded_offset, unencoded_file_len,
Boris Burkov 40ef45
+			unencoded_len, compression, encryption);
Boris Burkov 40ef45
+
Boris Burkov 40ef45
+
Boris Burkov 40ef45
 	if (encryption) {
Boris Burkov 40ef45
 		error("encoded_write: encryption not supported");
Boris Burkov 40ef45
 		return -EOPNOTSUPP;
Boris Burkov 40ef45
@@ -1271,6 +1278,10 @@ static int process_encoded_write(const char *path, const void *data, u64 offset,
Boris Burkov 40ef45
 			error("encoded_write: writing to %s failed: %m", path);
Boris Burkov 40ef45
 			return ret;
Boris Burkov 40ef45
 		}
Boris Burkov 40ef45
+		if (bconf.verbose >= 3)
Boris Burkov 40ef45
+			fprintf(stderr,
Boris Burkov 40ef45
+"encoded_write %s - falling back to decompress and write due to errno %d (\"%m\")\n",
Boris Burkov 40ef45
+				path, errno);
Boris Burkov 40ef45
 	}
Boris Burkov 40ef45
 
Boris Burkov 40ef45
 	return decompress_and_write(rctx, data, offset, len, unencoded_file_len,
Boris Burkov 40ef45
-- 
Boris Burkov 40ef45
2.38.1
Boris Burkov 40ef45