]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer: base exceptions on system_error
authorAdam C. Emerson <aemerson@redhat.com>
Tue, 4 Sep 2018 23:51:08 +0000 (19:51 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Fri, 15 May 2020 14:55:10 +0000 (10:55 -0400)
Thanks to Kefu Chai <kchai@redhat.com> for assistance.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
23 files changed:
src/cls/rgw/cls_rgw_types.h
src/common/buffer.cc
src/common/buffer_seastar.h
src/common/error_code.h
src/include/Context.h
src/include/buffer.h
src/include/denc.h
src/librbd/Journal.cc
src/mds/CDir.cc
src/mds/CInode.cc
src/mds/MDCache.cc
src/mon/MonMap.cc
src/msg/async/ProtocolV2.cc
src/osd/PrimaryLogPG.cc
src/rgw/rgw_bucket.cc
src/rgw/rgw_common.h
src/test/encoding.cc
src/test/perf_helper.cc
src/test/rgw/test_rgw_common.h
src/tools/ceph_monstore_tool.cc
src/tools/ceph_objectstore_tool.cc
src/tools/cephfs/DataScan.cc
src/tools/cephfs/MetaTool.cc

index 2187603f26cdc4ac48b56a9fa94adff0519c7aea..fd92803c300559c3c1e8bb86b1fa670dc216e07b 100644 (file)
@@ -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();
   }
 }
 
index 65ef5964cfc66f72c81ae38fc6d67ebb1590fb4a..15ecd9626e0b4839fcab2cd132384743b2ec69e0 100644 (file)
 #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<bool B>
+  buffer::ptr::iterator_impl<B>& buffer::ptr::iterator_impl<B>::operator +=(size_t len) {
+    pos += len;
+    if (pos > end_ptr)
+      throw end_of_buffer();
+    return *this;
+  }
+
+  template buffer::ptr::iterator_impl<false>&
+  buffer::ptr::iterator_impl<false>::operator +=(size_t len);
+  template buffer::ptr::iterator_impl<true>&
+  buffer::ptr::iterator_impl<true>::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<errc>(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<errc>(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<errc>(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;
+}
+}
+}
index 6a0e0cf6ca2f9a706d7c44c209fa41a9272f0ecc..70a7b93251b891a8bec45cdc575c3877e06a66c1 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <seastar/core/temporary_buffer.hh>
 #include "include/buffer.h"
+#include "common/error_code.h"
 
 namespace details {
 
index 8a9b9b09467fb91dd94cbaa5a1eec14f5ee0848d..67c6cb448d462eb9590df12893339e61f3276388 100644 (file)
@@ -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<int>(e), buffer_category() };
+}
+
+// explicit conversion:
+inline boost::system::error_condition
+make_error_condition(errc e) noexcept {
+  return { static_cast<int>(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
index 6d39be55ba1a25fa0703a98fb6282a1c939c5746..bef85ca5b52fd7a82e91df35ef0fa33a81c7bed1 100644 (file)
 
 #include "common/dout.h"
 
-#include <boost/function.hpp>
+#include <functional>
 #include <list>
-#include <set>
 #include <memory>
+#include <set>
+
+#include <boost/function.hpp>
+#include <boost/system/error_code.hpp>
+
+#include "common/error_code.h"
 
 #include "include/ceph_assert.h"
 #include "common/ceph_mutex.h"
@@ -48,6 +53,23 @@ class GenContext {
     finish(std::forward<C>(t));
     delete this;
   }
+
+  template <typename C>
+  void operator()(C &&t) noexcept {
+    complete(std::forward<C>(t));
+  }
+
+  template<typename U = T>
+  auto operator()() noexcept
+    -> typename std::enable_if<std::is_default_constructible<U>::value,
+                              void>::type {
+    complete(T{});
+  }
+
+
+  std::reference_wrapper<GenContext> func() {
+    return std::ref(*this);
+  }
 };
 
 template <typename T>
@@ -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<Context> func() {
+    return std::ref(*this);
+  }
 };
 
 /**
@@ -126,7 +162,10 @@ class LambdaContext : public Context {
 public:
   LambdaContext(T &&t) : t(std::forward<T>(t)) {}
   void finish(int r) override {
-    t(r);
+    if constexpr (std::is_invocable_v<T, int>)
+      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<Context>(c)]
+    (boost::system::error_code ec) mutable {
+          fin.release()->complete(ceph::from_error_code(ec));
+        };
+}
+
+
 #undef mydout
 
 #endif
index 80e990f30d62e792eeea6fe584f0013db0128e2c..3f00dbcc2a507061726bd531070cf06686f3b866 100644 (file)
@@ -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<T, ceph::nop_delete<T>> {
 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
index 6cc53277b94502596b1eb8281937d3ad47cae487..24fe8b08d215cb5d98cb6030d79cc6d0725e4072 100644 (file)
@@ -46,6 +46,7 @@
 #include "byteorder.h"
 
 #include "common/convenience.h"
+#include "common/error_code.h"
 
 template<typename T, typename=void>
 struct denc_traits {
index 66849c461fad21b87eff0092d5822aae68075001..4a32d93c94b8de7d5b52ff7ec89b09d02d841f64 100644 (file)
@@ -1645,7 +1645,7 @@ int Journal<I>::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;
   }
 
index 7d6d69337fcf27ad93b77be8e5016c275d8a0901..47b6d5ec6484f52c7b4b226f17561fc16f2ce9f7 100644 (file)
@@ -1915,9 +1915,9 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& 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<string, bufferlist>& 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
index 0de21439be1886599007bcc9974459a768e71f98..f690908b60a917a871758fe266fb78ca3e87b7db 100644 (file)
@@ -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;
   }
index e0a8313c497275246b88d200ab32bca99c20bcb8..2909db1101849de61df6d87790e8c5ba6a0bc441 100644 (file)
@@ -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;
     }
index f02a65dab7a09c933b4e705401f48b747f3a8d58..dc9c4a8b1a5d8b1b0545ba334454c966424fa274 100644 (file)
@@ -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<std::string>("monmap");
index 36aa16cc5f3e3eec1ce018772266de4972e16984..36469e0b35ff928f710bfad52feddfa8df70f9ee 100644 (file)
@@ -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) {
index 08d3a39bcc30755ddf118c4e502a0073290b20cb..23197dd8eed88a20b7439c371304bc8d4f187a4a 100644 (file)
@@ -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;
index 4d3abd187a82f29663f9a4f318501cb8c5d25024..d94d22a3ef0df3b6fcc3b35e4d46797ec59cadb2 100644 (file)
@@ -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;
         }
 
index f21944011066e4d86371f6de5abad144ce258ae2..b58e062a426cdcfab56fc649cfa95daf806b0aef 100644 (file)
@@ -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);
         }
index 4f91ecc4debd8b2d11f5306733889e80d43c144d..6d252fae18b71d65e4698c70fcf697de8bdd480a 100644 (file)
@@ -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) {
index 7661cb58e250521cb892fa8f388829ac0629803c..00527ce9f79757bac07fcb1ae73e52c2d1d24714 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include "include/buffer.h"
+#include "common/error_code.h"
 
 using namespace ceph;
 
index c360e3b0ad5036ad534c3d474e2f9a393146ae46..29ab3e4ac38a6d14440e05e804bc0c903f940208 100644 (file)
@@ -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);
       }
index d7169582b3338c786a711ab3c15ad5aa03a2e1e2..044fe30d6a479ca2f6b079c361a9defb7039888b 100644 (file)
@@ -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);
index 3699c3821c95255cd9566d38fad6ae1c5ee38cd1..2262924e8e7ded823bbac3586981509f65d99908 100644 (file)
@@ -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;
index 8fb670ad08e62a59186ac40a552a4933020c72ff..1698fdd7e4f4ba15ca2a49e994f0e62aff2ae436 100644 (file)
@@ -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;
     }
   }
 
index 06357e527f1aad387c8df23c9b8f5bf2b5a751b0..7a07d86646582cadcef4ba5ba159c0dfe3457262 100644 (file)
@@ -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();