From a695d5b48552db05b70d2dc55321ec14c3e35a05 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Sat, 4 May 2019 11:32:40 -0700 Subject: [PATCH] osd: Output Base64 encoding of CRC header if binary data present Add optional paramter so cleanbin() for bufferlist can include "Base64:" Fixes: https://tracker.ceph.com/issues/39582 Signed-off-by: David Zafman (cherry picked from commit eea239c03ca8aeb9a1da742b07d8627fbe2317e2) Conflicts: src/include/util.h : Resolved for cleanbin src/osd/ReplicatedBackend.cc : Resolved for util.h --- src/common/util.cc | 8 ++++---- src/include/util.h | 2 +- src/osd/ReplicatedBackend.cc | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/common/util.cc b/src/common/util.cc index c07a493872e8b..01dc09af96623 100644 --- a/src/common/util.cc +++ b/src/common/util.cc @@ -269,7 +269,7 @@ void dump_services(Formatter* f, const map >& services, con // If non-printable characters found then convert bufferlist to // base64 encoded string indicating whether it did. -string cleanbin(bufferlist &bl, bool &base64) +string cleanbin(bufferlist &bl, bool &base64, bool show) { bufferlist::iterator it; for (it = bl.begin(); it != bl.end(); ++it) { @@ -285,6 +285,8 @@ string cleanbin(bufferlist &bl, bool &base64) bufferlist b64; bl.encode_base64(b64); string encoded(b64.c_str(), b64.length()); + if (show) + encoded = "Base64:" + encoded; base64 = true; return encoded; } @@ -296,9 +298,7 @@ string cleanbin(string &str) bool base64; bufferlist bl; bl.append(str); - string result = cleanbin(bl, base64); - if (base64) - result = "Base64:" + result; + string result = cleanbin(bl, base64, true); return result; } diff --git a/src/include/util.h b/src/include/util.h index 88eab27ad322d..c216325df1ead 100644 --- a/src/include/util.h +++ b/src/include/util.h @@ -87,7 +87,7 @@ void dump_services(Formatter* f, const map >& services, const /// @param type the service type of given @p services, for example @p osd or @p mon. void dump_services(Formatter* f, const map >& services, const char* type); -string cleanbin(bufferlist &bl, bool &b64); +string cleanbin(bufferlist &bl, bool &b64, bool show = false); string cleanbin(string &str); namespace ceph::util { diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 0b5911339a855..2c7802ee3c7a3 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -21,6 +21,7 @@ #include "messages/MOSDPGPushReply.h" #include "common/EventTrace.h" #include "include/random.h" +#include "include/util.h" #define dout_context cct #define dout_subsys ceph_subsys_osd @@ -661,8 +662,8 @@ int ReplicatedBackend::be_deep_scrub( return 0; } if (r == 0 && hdrbl.length()) { - dout(25) << "CRC header " << string(hdrbl.c_str(), hdrbl.length()) - << dendl; + bool encoded = false; + dout(25) << "CRC header " << cleanbin(hdrbl, encoded, true) << dendl; pos.omap_hash << hdrbl; } } -- 2.39.5