From 7d73fa6a309dca4c5381596c5e92813e2e11ed3b Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Tue, 4 Sep 2018 19:51:08 -0400 Subject: [PATCH] buffer: base exceptions on system_error Thanks to Kefu Chai for assistance. Signed-off-by: Adam C. Emerson --- src/cls/rgw/cls_rgw_types.h | 2 +- src/common/buffer.cc | 125 ++++++++++++++++++++++++----- src/common/buffer_seastar.h | 1 + src/common/error_code.h | 71 ++++++++++++++++ src/include/Context.h | 53 +++++++++++- src/include/buffer.h | 43 +++------- src/include/denc.h | 1 + src/librbd/Journal.cc | 2 +- src/mds/CDir.cc | 6 +- src/mds/CInode.cc | 2 +- src/mds/MDCache.cc | 2 +- src/mon/MonMap.cc | 6 +- src/msg/async/ProtocolV2.cc | 2 +- src/osd/PrimaryLogPG.cc | 4 +- src/rgw/rgw_bucket.cc | 3 +- src/rgw/rgw_common.h | 2 +- src/test/encoding.cc | 4 +- src/test/perf_helper.cc | 1 + src/test/rgw/test_rgw_common.h | 2 +- src/tools/ceph_monstore_tool.cc | 2 +- src/tools/ceph_objectstore_tool.cc | 2 +- src/tools/cephfs/DataScan.cc | 7 +- src/tools/cephfs/MetaTool.cc | 10 +-- 23 files changed, 268 insertions(+), 85 deletions(-) diff --git a/src/cls/rgw/cls_rgw_types.h b/src/cls/rgw/cls_rgw_types.h index 2187603f26c..fd92803c300 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -304,7 +304,7 @@ void decode_packed_val(T& val, ceph::buffer::list::const_iterator& bl) } break; default: - throw ceph::buffer::error(); + throw ceph::buffer::malformed_input(); } } diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 65ef5964cfc..15ecd9626e0 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -27,12 +27,14 @@ #include "armor.h" #include "common/environment.h" #include "common/errno.h" +#include "common/error_code.h" #include "common/safe_io.h" #include "common/strtol.h" #include "common/likely.h" #include "common/valgrind.h" #include "common/deleter.h" #include "common/RWLock.h" +#include "common/error_code.h" #include "include/spinlock.h" #include "include/scope_guard.h" @@ -75,21 +77,6 @@ static ceph::spinlock debug_lock; return buffer_missed_crc; } - const char * buffer::error::what() const throw () { - return "buffer::exception"; - } - const char * buffer::bad_alloc::what() const throw () { - return "buffer::bad_alloc"; - } - const char * buffer::end_of_buffer::what() const throw () { - return "buffer::end_of_buffer"; - } - const char * buffer::malformed_input::what() const throw () { - return buf; - } - buffer::error_code::error_code(int error) : - buffer::malformed_input(cpp_strerror(error).c_str()), code(error) {} - /* * raw_combined is always placed within a single allocation along * with the data buffer. the data goes at the beginning, and @@ -640,6 +627,19 @@ static ceph::spinlock debug_lock; memset(c_str()+o, 0, l); } + template + buffer::ptr::iterator_impl& buffer::ptr::iterator_impl::operator +=(size_t len) { + pos += len; + if (pos > end_ptr) + throw end_of_buffer(); + return *this; + } + + template buffer::ptr::iterator_impl& + buffer::ptr::iterator_impl::operator +=(size_t len); + template buffer::ptr::iterator_impl& + buffer::ptr::iterator_impl::operator +=(size_t len); + // -- buffer::list::iterator -- /* buffer::list::iterator operator=(const buffer::list::iterator& other) @@ -2177,11 +2177,6 @@ std::ostream& buffer::operator<<(std::ostream& out, const buffer::list& bl) { return out; } -std::ostream& buffer::operator<<(std::ostream& out, const buffer::error& e) -{ - return out << e.what(); -} - MEMPOOL_DEFINE_OBJECT_FACTORY(buffer::raw_malloc, buffer_raw_malloc, buffer_meta); MEMPOOL_DEFINE_OBJECT_FACTORY(buffer::raw_posix_aligned, @@ -2192,3 +2187,93 @@ MEMPOOL_DEFINE_OBJECT_FACTORY(buffer::raw_claimed_char, buffer_raw_claimed_char, MEMPOOL_DEFINE_OBJECT_FACTORY(buffer::raw_static, buffer_raw_static, buffer_meta); + +namespace ceph::buffer { +inline namespace v15_2_0 { + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnon-virtual-dtor" +class buffer_error_category : public ceph::converting_category { +public: + buffer_error_category(){} + const char* name() const noexcept override; + const char* message(int ev, char*, std::size_t) const noexcept override; + std::string message(int ev) const override; + boost::system::error_condition default_error_condition(int ev) const noexcept + override; + using ceph::converting_category::equivalent; + bool equivalent(int ev, const boost::system::error_condition& c) const + noexcept override; + int from_code(int ev) const noexcept override; +}; +#pragma GCC diagnostic pop +#pragma clang diagnostic pop + +const char* buffer_error_category::name() const noexcept { + return "buffer"; +} + +const char* +buffer_error_category::message(int ev, char*, std::size_t) const noexcept { + using ceph::buffer::errc; + if (ev == 0) + return "No error"; + + switch (static_cast(ev)) { + case errc::bad_alloc: + return "Bad allocation"; + + case errc::end_of_buffer: + return "End of buffer"; + + case errc::malformed_input: + return "Malformed input"; + } + + return "Unknown error"; +} + +std::string buffer_error_category::message(int ev) const { + return message(ev, nullptr, 0); +} + +boost::system::error_condition +buffer_error_category::default_error_condition(int ev)const noexcept { + using ceph::buffer::errc; + switch (static_cast(ev)) { + case errc::bad_alloc: + return boost::system::errc::not_enough_memory; + case errc::end_of_buffer: + case errc::malformed_input: + return boost::system::errc::io_error; + } + return { ev, *this }; +} + +bool buffer_error_category::equivalent(int ev, const boost::system::error_condition& c) const noexcept { + return default_error_condition(ev) == c; +} + +int buffer_error_category::from_code(int ev) const noexcept { + using ceph::buffer::errc; + switch (static_cast(ev)) { + case errc::bad_alloc: + return -ENOMEM; + + case errc::end_of_buffer: + return -EIO; + + case errc::malformed_input: + return -EIO; + } + return -EDOM; +} + +const boost::system::error_category& buffer_category() noexcept { + static const buffer_error_category c; + return c; +} +} +} diff --git a/src/common/buffer_seastar.h b/src/common/buffer_seastar.h index 6a0e0cf6ca2..70a7b93251b 100644 --- a/src/common/buffer_seastar.h +++ b/src/common/buffer_seastar.h @@ -3,6 +3,7 @@ #include #include "include/buffer.h" +#include "common/error_code.h" namespace details { diff --git a/src/common/error_code.h b/src/common/error_code.h index 8a9b9b09467..67c6cb448d4 100644 --- a/src/common/error_code.h +++ b/src/common/error_code.h @@ -77,4 +77,75 @@ int from_error_code(boost::system::error_code e) noexcept; #pragma GCC diagnostic pop #pragma clang diagnostic pop +// Moved here from buffer.h so librados doesn't gain a dependency on +// Boost.System + +namespace ceph::buffer { +inline namespace v15_2_0 { +const boost::system::error_category& buffer_category() noexcept; +enum class errc { bad_alloc = 1, + end_of_buffer, + malformed_input }; +} +} + +namespace boost::system { +template<> +struct is_error_code_enum<::ceph::buffer::errc> { + static const bool value = true; +}; + +template<> +struct is_error_condition_enum<::ceph::buffer::errc> { + static const bool value = false; +}; +} + +namespace ceph::buffer { +inline namespace v15_2_0 { + +// implicit conversion: +inline boost::system::error_code make_error_code(errc e) noexcept { + return { static_cast(e), buffer_category() }; +} + +// explicit conversion: +inline boost::system::error_condition +make_error_condition(errc e) noexcept { + return { static_cast(e), buffer_category() }; +} + +struct error : boost::system::system_error { + using system_error::system_error; +}; + +struct bad_alloc : public error { + bad_alloc() : error(errc::bad_alloc) {} + bad_alloc(const char* what_arg) : error(errc::bad_alloc, what_arg) {} + bad_alloc(const std::string& what_arg) : error(errc::bad_alloc, what_arg) {} +}; +struct end_of_buffer : public error { + end_of_buffer() : error(errc::end_of_buffer) {} + end_of_buffer(const char* what_arg) : error(errc::end_of_buffer, what_arg) {} + end_of_buffer(const std::string& what_arg) + : error(errc::end_of_buffer, what_arg) {} +}; + +struct malformed_input : public error { + malformed_input() : error(errc::malformed_input) {} + malformed_input(const char* what_arg) + : error(errc::malformed_input, what_arg) {} + malformed_input(const std::string& what_arg) + : error(errc::malformed_input, what_arg) {} +}; +struct error_code : public error { + error_code(int r) : error(-r, boost::system::system_category()) {} + error_code(int r, const char* what_arg) + : error(-r, boost::system::system_category(), what_arg) {} + error_code(int r, const std::string& what_arg) + : error(-r, boost::system::system_category(), what_arg) {} +}; +} +} + #endif // COMMON_CEPH_ERROR_CODE diff --git a/src/include/Context.h b/src/include/Context.h index 6d39be55ba1..bef85ca5b52 100644 --- a/src/include/Context.h +++ b/src/include/Context.h @@ -18,10 +18,15 @@ #include "common/dout.h" -#include +#include #include -#include #include +#include + +#include +#include + +#include "common/error_code.h" #include "include/ceph_assert.h" #include "common/ceph_mutex.h" @@ -48,6 +53,23 @@ class GenContext { finish(std::forward(t)); delete this; } + + template + void operator()(C &&t) noexcept { + complete(std::forward(t)); + } + + template + auto operator()() noexcept + -> typename std::enable_if::value, + void>::type { + complete(T{}); + } + + + std::reference_wrapper func() { + return std::ref(*this); + } }; template @@ -84,6 +106,20 @@ class Context { } return false; } + void complete(boost::system::error_code ec) { + complete(ceph::from_error_code(ec)); + } + void operator()(boost::system::error_code ec) noexcept { + complete(ec); + } + + void operator()() noexcept { + complete({}); + } + + std::reference_wrapper func() { + return std::ref(*this); + } }; /** @@ -126,7 +162,10 @@ class LambdaContext : public Context { public: LambdaContext(T &&t) : t(std::forward(t)) {} void finish(int r) override { - t(r); + if constexpr (std::is_invocable_v) + t(r); + else + t(); } private: T t; @@ -483,6 +522,14 @@ public: virtual ContextType *build() = 0; }; +inline auto lambdafy(Context *c) { + return [fin = std::unique_ptr(c)] + (boost::system::error_code ec) mutable { + fin.release()->complete(ceph::from_error_code(ec)); + }; +} + + #undef mydout #endif diff --git a/src/include/buffer.h b/src/include/buffer.h index 80e990f30d6..3f00dbcc2a5 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -54,6 +54,7 @@ #include "crc32c.h" #include "buffer_fwd.h" + #ifdef __CEPH__ # include "include/ceph_assert.h" #else @@ -101,32 +102,12 @@ struct unique_leakable_ptr : public std::unique_ptr> { namespace buffer CEPH_BUFFER_API { inline namespace v15_2_0 { - /* - * exceptions - */ - - struct error : public std::exception{ - const char *what() const throw () override; - }; - struct bad_alloc : public error { - const char *what() const throw () override; - }; - struct end_of_buffer : public error { - const char *what() const throw () override; - }; - struct malformed_input : public error { - explicit malformed_input(const std::string& w) { - snprintf(buf, sizeof(buf), "buffer::malformed_input: %s", w.c_str()); - } - const char *what() const throw () override; - private: - char buf[256]; - }; - struct error_code : public malformed_input { - explicit error_code(int error); - int code; - }; - +/// Actual definitions in common/error_code.h +struct error; +struct bad_alloc; +struct end_of_buffer; +struct malformed_input; +struct error_code; /// count of cached crc hits (matching input) int get_cached_crc(); @@ -227,12 +208,7 @@ inline namespace v15_2_0 { } } - iterator_impl& operator+=(size_t len) { - pos += len; - if (pos > end_ptr) - throw end_of_buffer(); - return *this; - } + iterator_impl& operator+=(size_t len); const char *get_pos() { return pos; @@ -1271,8 +1247,6 @@ std::ostream& operator<<(std::ostream& out, const buffer::raw &r); std::ostream& operator<<(std::ostream& out, const buffer::list& bl); -std::ostream& operator<<(std::ostream& out, const buffer::error& e); - inline bufferhash& operator<<(bufferhash& l, const bufferlist &r) { l.update(r); return l; @@ -1282,4 +1256,5 @@ inline bufferhash& operator<<(bufferhash& l, const bufferlist &r) { } // namespace ceph + #endif diff --git a/src/include/denc.h b/src/include/denc.h index 6cc53277b94..24fe8b08d21 100644 --- a/src/include/denc.h +++ b/src/include/denc.h @@ -46,6 +46,7 @@ #include "byteorder.h" #include "common/convenience.h" +#include "common/error_code.h" template struct denc_traits { diff --git a/src/librbd/Journal.cc b/src/librbd/Journal.cc index 66849c461fa..4a32d93c94b 100644 --- a/src/librbd/Journal.cc +++ b/src/librbd/Journal.cc @@ -1645,7 +1645,7 @@ int Journal::check_resync_requested(bool *do_resync) { decode(client_data, bl_it); } catch (const buffer::error &err) { lderr(cct) << this << " " << __func__ << ": " - << "failed to decode client data: " << err << dendl; + << "failed to decode client data: " << err.what() << dendl; return -EINVAL; } diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index 7d6d69337fc..47b6d5ec648 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -1915,9 +1915,9 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map& omap, decode(got_fnode, p); } catch (const buffer::error &err) { derr << "Corrupt fnode in dirfrag " << dirfrag() - << ": " << err << dendl; + << ": " << err.what() << dendl; clog->warn() << "Corrupt fnode header in " << dirfrag() << ": " - << err << " (" << get_path() << ")"; + << err.what() << " (" << get_path() << ")"; go_bad(complete); return; } @@ -1983,7 +1983,7 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map& omap, } catch (const buffer::error &err) { cache->mds->clog->warn() << "Corrupt dentry '" << dname << "' in " "dir frag " << dirfrag() << ": " - << err << "(" << get_path() << ")"; + << err.what() << "(" << get_path() << ")"; // Remember that this dentry is damaged. Subsequent operations // that try to act directly on it will get their EIOs, but this diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 0de21439be1..f690908b60a 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -1287,7 +1287,7 @@ void CInode::_fetched(bufferlist& bl, bufferlist& bl2, Context *fin) fin->complete(0); } } catch (buffer::error &err) { - derr << "Corrupt inode " << ino() << ": " << err << dendl; + derr << "Corrupt inode " << ino() << ": " << err.what() << dendl; fin->complete(-EINVAL); return; } diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index e0a8313c497..2909db11018 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -8797,7 +8797,7 @@ void MDCache::_open_ino_backtrace_fetched(inodeno_t ino, bufferlist& bl, int err decode(backtrace, bl); } catch (const buffer::error &decode_exc) { derr << "corrupt backtrace on ino x0" << std::hex << ino - << std::dec << ": " << decode_exc << dendl; + << std::dec << ": " << decode_exc.what() << dendl; open_ino_finish(ino, info, -EIO); return; } diff --git a/src/mon/MonMap.cc b/src/mon/MonMap.cc index f02a65dab7a..dc9c4a8b1a5 100644 --- a/src/mon/MonMap.cc +++ b/src/mon/MonMap.cc @@ -660,7 +660,7 @@ int MonMap::init_with_config_file(const ConfigProxy& conf, using namespace seastar; -future<> MonMap::read_monmap(const std::string& monmap) +seastar::future<> MonMap::read_monmap(const std::string& monmap) { return open_file_dma(monmap, open_flags::ro).then([this] (file f) { return f.size().then([this, f = std::move(f)](size_t s) { @@ -676,7 +676,7 @@ future<> MonMap::read_monmap(const std::string& monmap) }); } -future<> MonMap::init_with_dns_srv(bool for_mkfs, const std::string& name) +seastar::future<> MonMap::init_with_dns_srv(bool for_mkfs, const std::string& name) { string domain; string service = name; @@ -753,7 +753,7 @@ seastar::future<> MonMap::build_monmap(const crimson::common::ConfigProxy& conf, }); } -future<> MonMap::build_initial(const crimson::common::ConfigProxy& conf, bool for_mkfs) +seastar::future<> MonMap::build_initial(const crimson::common::ConfigProxy& conf, bool for_mkfs) { // file? if (const auto monmap = conf.get_val("monmap"); diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index 36aa16cc5f3..36469e0b35f 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -44,7 +44,7 @@ void ProtocolV2::run_continuation(CtRef continuation) { try { CONTINUATION_RUN(continuation) } catch (const ceph::buffer::error &e) { - lderr(cct) << __func__ << " failed decoding of frame header: " << e + lderr(cct) << __func__ << " failed decoding of frame header: " << e.what() << dendl; _fault(); } catch (const ceph::crypto::onwire::MsgAuthError &e) { diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 08d3a39bcc3..23197dd8eed 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -11442,8 +11442,8 @@ SnapSetContext *PrimaryLogPG::get_snapset_context( bufferlist::const_iterator bvp = bv.begin(); try { ssc->snapset.decode(bvp); - } catch (ceph::buffer::error& e) { - dout(0) << __func__ << " Can't decode snapset: " << e << dendl; + } catch (const ceph::buffer::error& e) { + dout(0) << __func__ << " Can't decode snapset: " << e.what() << dendl; return NULL; } ssc->exists = true; diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 4d3abd187a8..d94d22a3ef0 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -3663,7 +3663,8 @@ int RGWBucketCtl::chown(rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_in decode(policy, bl); owner = policy.get_owner(); } catch (buffer::error& err) { - ldout(store->ctx(), 0) << "ERROR: decode policy failed" << err << dendl; + ldout(store->ctx(), 0) << "ERROR: decode policy failed" << err.what() + << dendl; return -EIO; } diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index f2194401106..b58e062a426 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -1905,7 +1905,7 @@ struct rgw_obj { } else { ssize_t pos = key.name.find('_', 1); if (pos < 0) { - throw buffer::error(); + throw buffer::malformed_input(); } key.name = key.name.substr(pos + 1); } diff --git a/src/test/encoding.cc b/src/test/encoding.cc index 4f91ecc4deb..6d252fae18b 100644 --- a/src/test/encoding.cc +++ b/src/test/encoding.cc @@ -320,8 +320,8 @@ TEST(EncodingRoundTrip, Integers) { } const char* expected_what[] = { - "buffer::malformed_input: void lame_decoder(int) no longer understand old encoding version 100 < 200", - "buffer::malformed_input: void lame_decoder(int) decode past end of struct encoding", + "void lame_decoder(int) no longer understand old encoding version 100 < 200: Malformed input", + "void lame_decoder(int) decode past end of struct encoding: Malformed input" }; void lame_decoder(int which) { diff --git a/src/test/perf_helper.cc b/src/test/perf_helper.cc index 7661cb58e25..00527ce9f79 100644 --- a/src/test/perf_helper.cc +++ b/src/test/perf_helper.cc @@ -16,6 +16,7 @@ */ #include "include/buffer.h" +#include "common/error_code.h" using namespace ceph; diff --git a/src/test/rgw/test_rgw_common.h b/src/test/rgw/test_rgw_common.h index c360e3b0ad5..29ab3e4ac38 100644 --- a/src/test/rgw/test_rgw_common.h +++ b/src/test/rgw/test_rgw_common.h @@ -414,7 +414,7 @@ public: } else { ssize_t pos = object.find('_', 1); if (pos < 0) { - throw buffer::error(); + throw buffer::malformed_input(); } orig_obj = object.substr(pos); } diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index d7169582b33..044fe30d6a4 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -952,7 +952,7 @@ int main(int argc, char **argv) { } } catch (const buffer::error &err) { std::cerr << "Could not decode for human readable output (you may still" - " use non-readable mode). Detail: " << err << std::endl; + " use non-readable mode). Detail: " << err.what() << std::endl; } out.append(ss); diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 3699c3821c9..2262924e8e7 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -681,7 +681,7 @@ int do_trim_pg_log(ObjectStore *store, const coll_t &coll, try { e.decode_with_checksum(bp); } catch (const buffer::error &e) { - cerr << "Error reading pg log entry: " << e << std::endl; + cerr << "Error reading pg log entry: " << e.what() << std::endl; } if (debug) { cerr << "read entry " << e << std::endl; diff --git a/src/tools/cephfs/DataScan.cc b/src/tools/cephfs/DataScan.cc index 8fb670ad08e..1698fdd7e4f 100644 --- a/src/tools/cephfs/DataScan.cc +++ b/src/tools/cephfs/DataScan.cc @@ -1317,7 +1317,7 @@ int DataScan::scan_frags() auto q = parent_bl.cbegin(); backtrace.decode(q); } catch (buffer::error &e) { - dout(4) << "Corrupt backtrace on '" << oid << "': " << e << dendl; + dout(4) << "Corrupt backtrace on '" << oid << "': " << e.what() << dendl; if (!force_corrupt) { return -EINVAL; } else { @@ -1332,7 +1332,7 @@ int DataScan::scan_frags() auto q = layout_bl.cbegin(); decode(loaded_layout, q); } catch (buffer::error &e) { - dout(4) << "Corrupt layout on '" << oid << "': " << e << dendl; + dout(4) << "Corrupt layout on '" << oid << "': " << e.what() << dendl; if (!force_corrupt) { return -EINVAL; } @@ -1615,7 +1615,8 @@ int MetadataDriver::get_frag_of( backtrace.decode(q); have_backtrace = true; } catch (buffer::error &e) { - dout(4) << "Corrupt backtrace on '" << root_frag_oid << "': " << e << dendl; + dout(4) << "Corrupt backtrace on '" << root_frag_oid << "': " + << e.what() << dendl; } } diff --git a/src/tools/cephfs/MetaTool.cc b/src/tools/cephfs/MetaTool.cc index 06357e527f1..7a07d866465 100644 --- a/src/tools/cephfs/MetaTool.cc +++ b/src/tools/cephfs/MetaTool.cc @@ -383,7 +383,7 @@ int MetaTool::_show_meta(inode_meta_t& inode_meta, const string& fn){ } }catch (const buffer::error &err){ cerr << "corrupt decode in snap_blob" - << ": " << err << std::endl; + << ": " << err.what() << std::endl; return -1; } @@ -503,7 +503,7 @@ int MetaTool::list_meta(meta_op &op){ ::decode(got_fnode, p); }catch (const buffer::error &err){ cerr << "corrupt fnode header in " << oid - << ": " << err << std::endl; + << ": " << err.what() << std::endl; return -1; } @@ -551,7 +551,7 @@ int MetaTool::list_meta(meta_op &op){ } } catch (const buffer::error &err) { derr << "Corrupt dentry '" << dname << "' : " - << err << "(" << "" << ")" << dendl; + << err.what() << "(" << "" << ")" << dendl; return -1; } } @@ -580,7 +580,7 @@ int MetaTool::list_meta(meta_op &op){ } } catch (const buffer::error &err) { derr << "Corrupt dentry '" << dname << "' : " - << err << "(" << "" << ")" << dendl; + << err.what() << "(" << "" << ")" << dendl; return -1; } } @@ -788,7 +788,7 @@ int MetaTool::show_child(std::string_view key, } }catch (const buffer::error &err){ cerr << "corrupt decode in snap_blob" - << ": " << err << std::endl; + << ": " << err.what() << std::endl; } f->close_section(); f->close_section(); -- 2.39.5