]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: pass the the cause by string_view 37099/head
authorKefu Chai <kchai@redhat.com>
Fri, 11 Sep 2020 08:43:37 +0000 (16:43 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 11 Sep 2020 08:59:55 +0000 (16:59 +0800)
in future, string_view can be used almost every where string can be
used. in this change, `const char*` is instead passed to the constructor
of system_error, as we can ensure that the string_view instances are
always constructed from a `const char*` ended with `\0`.

we need this change for two reasons:

* better performance
* prefer for the world where string_view rules.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/recovery_backend.cc
src/crimson/osd/recovery_backend.h

index deb0ca4a07b91bf6e2fc2b198e9b199caf174fc5..77a5480a9750965f80b3950e1098f6b0014419a4 100644 (file)
@@ -30,7 +30,7 @@ hobject_t RecoveryBackend::get_temp_recovery_object(
 }
 
 void RecoveryBackend::clean_up(ceph::os::Transaction& t,
-                              const std::string& why)
+                              std::string_view why)
 {
   for (auto& soid : temp_contents) {
     t.remove(pg.get_collection_ref()->get_cid(),
index b9d63c1d04172f102059d7f0acfaf110b333124d..b529fda5a15c81d6a4bbb296a831950d6374481c 100644 (file)
@@ -155,16 +155,16 @@ protected:
     void set_push_failed(pg_shard_t shard, std::exception_ptr e) {
       pushes.at(shard).set_exception(e);
     }
-    void interrupt(const std::string& why) {
+    void interrupt(std::string_view why) {
       readable.set_exception(std::system_error(
-           std::make_error_code(std::errc::interrupted), why));
+        std::make_error_code(std::errc::interrupted), why.data()));
       recovered.set_exception(std::system_error(
-           std::make_error_code(std::errc::interrupted), why));
+        std::make_error_code(std::errc::interrupted), why.data()));
       pulled.set_exception(std::system_error(
-           std::make_error_code(std::errc::interrupted), why));
+        std::make_error_code(std::errc::interrupted), why.data()));
       for (auto& [pg_shard, pr] : pushes) {
-       pr.set_exception(std::system_error(
-             std::make_error_code(std::errc::interrupted), why));
+        pr.set_exception(std::system_error(
+          std::make_error_code(std::errc::interrupted), why.data()));
       }
     }
     void stop();
@@ -184,6 +184,6 @@ protected:
   void clear_temp_obj(const hobject_t &oid) {
     temp_contents.erase(oid);
   }
-  void clean_up(ceph::os::Transaction& t, const std::string& why);
+  void clean_up(ceph::os::Transaction& t, std::string_view why);
   virtual seastar::future<> on_stop() = 0;
 };