Message ID | 90290fe5047d688d8eecdc1357e9379252ae5352.1668529099.git.fdmanana@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs-progs: receive: fix a silent data loss bug with encoded writes | expand |
On Tue, Nov 15, 2022 at 04:25:24PM +0000, fdmanana@kernel.org wrote: > From: Filipe Manana <fdmanana@suse.com> > > Unlike for commands from the v1 stream, we have no debug messages logged > when processing encoded write commands, which makes it harder to debug > issues. > > So add log messages, when the log verbosity level is >= 3, for encoded > write commands, mentioning the value of all fields and also log when we > fallback from an encoded write to the decompress and write approach. > > The log messages look like this: > > encoded_write f3 - offset=33792, len=4096, unencoded_offset=33792, unencoded_file_len=31744, unencoded_len=65536, compression=1, encryption=0 > encoded_write f3 - falling back to decompress and write due to errno 22 ("Invalid argument") > > Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Boris Burkov <boris@bur.io> > --- > cmds/receive.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/cmds/receive.c b/cmds/receive.c > index 6f475544..b75a5634 100644 > --- a/cmds/receive.c > +++ b/cmds/receive.c > @@ -1246,6 +1246,13 @@ static int process_encoded_write(const char *path, const void *data, u64 offset, > .encryption = encryption, > }; > > + if (bconf.verbose >= 3) > + fprintf(stderr, > +"encoded_write %s - offset=%llu, len=%llu, unencoded_offset=%llu, unencoded_file_len=%llu, unencoded_len=%llu, compression=%u, encryption=%u\n", > + path, offset, len, unencoded_offset, unencoded_file_len, > + unencoded_len, compression, encryption); > + > + > if (encryption) { > error("encoded_write: encryption not supported"); > return -EOPNOTSUPP; > @@ -1271,6 +1278,10 @@ static int process_encoded_write(const char *path, const void *data, u64 offset, > error("encoded_write: writing to %s failed: %m", path); > return ret; > } > + if (bconf.verbose >= 3) > + fprintf(stderr, > +"encoded_write %s - falling back to decompress and write due to errno %d (\"%m\")\n", > + path, errno); > } > > return decompress_and_write(rctx, data, offset, len, unencoded_file_len, > -- > 2.35.1 >
diff --git a/cmds/receive.c b/cmds/receive.c index 6f475544..b75a5634 100644 --- a/cmds/receive.c +++ b/cmds/receive.c @@ -1246,6 +1246,13 @@ static int process_encoded_write(const char *path, const void *data, u64 offset, .encryption = encryption, }; + if (bconf.verbose >= 3) + fprintf(stderr, +"encoded_write %s - offset=%llu, len=%llu, unencoded_offset=%llu, unencoded_file_len=%llu, unencoded_len=%llu, compression=%u, encryption=%u\n", + path, offset, len, unencoded_offset, unencoded_file_len, + unencoded_len, compression, encryption); + + if (encryption) { error("encoded_write: encryption not supported"); return -EOPNOTSUPP; @@ -1271,6 +1278,10 @@ static int process_encoded_write(const char *path, const void *data, u64 offset, error("encoded_write: writing to %s failed: %m", path); return ret; } + if (bconf.verbose >= 3) + fprintf(stderr, +"encoded_write %s - falling back to decompress and write due to errno %d (\"%m\")\n", + path, errno); } return decompress_and_write(rctx, data, offset, len, unencoded_file_len,