]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/object_context_loader: Introduce with_clone_obc_only()
authorMatan Breizman <mbreizma@redhat.com>
Sun, 6 Nov 2022 13:28:27 +0000 (13:28 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Tue, 22 Nov 2022 09:35:38 +0000 (09:35 +0000)
A with_clone_obc() variant, in PGBackend::rollback() with_locked_obc
is locking the head obc used, we should not lock the head object
obc again (as in by calling with_head_obc()).

Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/crimson/osd/object_context_loader.cc
src/crimson/osd/object_context_loader.h

index 81edc3c74a8eb3a9162de631dfaac3900d4b7165..2c93a879a5f00a7306d51bf7d77889597e49ee58 100644 (file)
@@ -39,7 +39,7 @@ using crimson::common::local_conf;
   {
     assert(!oid.is_head());
     return with_head_obc<RWState::RWREAD>(oid.get_head(),
-      [oid, func=std::move(func), this](auto head)
+      [oid, func=std::move(func), this](auto head) mutable
       -> load_obc_iertr::future<> {
       if (!head->obs.exists) {
         logger().error("with_clone_obc: {} head doesn't exist",
@@ -48,23 +48,36 @@ using crimson::common::local_conf;
           crimson::ct_error::enoent::make()
         };
       }
-      auto coid = resolve_oid(head->get_ro_ss(), oid);
-      if (!coid) {
-        logger().error("with_clone_obc: {} clone not found", coid);
-        return load_obc_iertr::future<>{
-          crimson::ct_error::enoent::make()
-        };
-      }
-      auto [clone, existed] = shard_services.get_cached_obc(*coid);
-      return clone->template with_lock<State, IOInterruptCondition>(
-        [existed=existed, head=std::move(head), clone=std::move(clone),
-         func=std::move(func), this]() -> load_obc_iertr::future<> {
-        auto loaded = get_or_load_obc<State>(clone, existed);
-        clone->head = head;
-        return loaded.safe_then_interruptible(
-          [func = std::move(func)](auto clone) {
-          return std::move(func)(std::move(clone));
-        });
+      return this->with_clone_obc_only<State>(head,
+                                              oid,
+                                              std::move(func));
+    });
+  }
+
+  template<RWState::State State>
+  ObjectContextLoader::load_obc_iertr::future<>
+  ObjectContextLoader::with_clone_obc_only(ObjectContextRef head,
+                                           hobject_t oid,
+                                           with_obc_func_t&& func)
+  {
+    auto coid = resolve_oid(head->get_ro_ss(), oid);
+    if (!coid) {
+      logger().error("with_clone_obc_only: {} clone not found",
+                     coid);
+      return load_obc_iertr::future<>{
+        crimson::ct_error::enoent::make()
+      };
+    }
+    auto [clone, existed] = shard_services.get_cached_obc(*coid);
+    return clone->template with_lock<State, IOInterruptCondition>(
+      [existed=existed, clone=std::move(clone),
+       func=std::move(func), head=std::move(head), this]()
+      -> load_obc_iertr::future<> {
+      auto loaded = get_or_load_obc<State>(clone, existed);
+      clone->head = std::move(head);
+      return loaded.safe_then_interruptible(
+        [func = std::move(func)](auto clone) {
+        return std::move(func)(std::move(clone));
       });
     });
   }
index 7c572229ac924757b9c164aadb3f5b0cb831b1bf..e211fd1159a3ad7d0f82d947117d5496c6e9023b 100644 (file)
@@ -39,6 +39,14 @@ public:
   load_obc_iertr::future<> with_clone_obc(hobject_t oid,
                                           with_obc_func_t&& func);
 
+  // Use this variant in the case where the head object
+  // obc is already locked. Avoid nesting
+  // with_head_obc() as in using with_clone_obc().
+  template<RWState::State State>
+  load_obc_iertr::future<> with_clone_obc_only(ObjectContextRef head,
+                                               hobject_t oid,
+                                               with_obc_func_t&& func);
+
   template<RWState::State State>
   load_obc_iertr::future<> with_head_obc(ObjectContextRef obc,
                                          bool existed,