]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: remove no-op func passed to OpsExecuter::flush_changes()
authorKefu Chai <kchai@redhat.com>
Sun, 7 Feb 2021 05:53:11 +0000 (13:53 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 9 Feb 2021 03:38:22 +0000 (11:38 +0800)
no need to create an empty func for an request which creates no
transactions.

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

index 42fcf61b8003d67a219dc83b91240d1845e9bb7d..54a715b0060b48a0fa046fba909164971c2a06f0 100644 (file)
@@ -180,8 +180,8 @@ public:
 
   osd_op_errorator::future<> execute_op(class OSDOp& osd_op);
 
-  template <typename Func, typename MutFunc>
-  osd_op_errorator::future<> flush_changes(Func&& func, MutFunc&& mut_func) &&;
+  template <typename MutFunc>
+  osd_op_errorator::future<> flush_changes(MutFunc&& mut_func) &&;
 
   const auto& get_message() const {
     return msg;
@@ -235,29 +235,25 @@ auto OpsExecuter::with_effect_on_obc(
   return std::forward<MainFunc>(main_func)(ctx_ref);
 }
 
-template <typename Func,
-          typename MutFunc>
+template <typename MutFunc>
 OpsExecuter::osd_op_errorator::future<> OpsExecuter::flush_changes(
-  Func&& func,
   MutFunc&& mut_func) &&
 {
   const bool want_mutate = !txn.empty();
   // osd_op_params are instantiated by every wr-like operation.
   assert(osd_op_params || !want_mutate);
   assert(obc);
+  auto maybe_mutated = osd_op_errorator::now();
+  if (want_mutate) {
+    maybe_mutated = std::forward<MutFunc>(mut_func)(std::move(txn),
+                                                    std::move(obc),
+                                                    std::move(*osd_op_params),
+                                                    user_modify);
+  }
   if (__builtin_expect(op_effects.empty(), true)) {
-    return want_mutate ? std::forward<MutFunc>(mut_func)(std::move(txn),
-                                                         std::move(obc),
-                                                         std::move(*osd_op_params),
-                                                         user_modify)
-                       : std::forward<Func>(func)(std::move(obc));
+    return maybe_mutated;
   } else {
-    return (want_mutate ? std::forward<MutFunc>(mut_func)(std::move(txn),
-                                                          std::move(obc),
-                                                          std::move(*osd_op_params),
-                                                          user_modify)
-                        : std::forward<Func>(func)(std::move(obc))
-    ).safe_then([this] {
+    return maybe_mutated.safe_then([this] {
       // let's do the cleaning of `op_effects` in destructor
       return crimson::do_for_each(op_effects, [] (auto& op_effect) {
         return op_effect->execute();
index 145293565b3800d74a113e7d32f36cbb3ce90569..28551eb0a264b8ab91248ab2888546b840c651d1 100644 (file)
@@ -728,13 +728,6 @@ PG::do_osd_ops(
       *m,
       obc->obs.oi.soid);
     return std::move(*ox).flush_changes(
-      [m] (auto&& obc) -> osd_op_errorator::future<> {
-       logger().debug(
-         "do_osd_ops: {} - object {} txn is empty, bypassing mutate",
-         *m,
-         obc->obs.oi.soid);
-        return osd_op_errorator::now();
-      },
       [this, m, &op_info] (auto&& txn,
                           auto&& obc,
                           auto&& osd_op_p,