]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: load_head_obc -> load_obc
authorMatan Breizman <mbreizma@redhat.com>
Mon, 3 Oct 2022 07:40:42 +0000 (07:40 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Mon, 3 Oct 2022 10:27:23 +0000 (10:27 +0000)
Support both clone/head obc load instead of head_obc only.

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

index 35aae18cda4651b961127166c68cfdbec2b839ee..a77fd0bc6a4384a6132814a911a4e52aea99131a 100644 (file)
@@ -104,10 +104,9 @@ public:
     ssc = std::move(_ssc);
   }
 
-  void set_clone_state(ObjectState &&_obs, Ref &&_head) {
+  void set_clone_state(ObjectState &&_obs) {
     ceph_assert(!is_head());
     obs = std::move(_obs);
-    head = _head;
   }
 
   /// pass the provided exception to any waiting consumers of this ObjectContext
index 759ae2e3f989ed1acedcc99ce5ba208eb17757f5..4301394b64b719c10122bb7b0c163c57d58b5e72 100644 (file)
@@ -1029,7 +1029,7 @@ PG::with_head_obc(ObjectContextRef obc, bool existed, with_obc_func_t&& func)
     } else {
       logger().debug("with_head_obc: cache miss on {}", obc->get_oid());
       loaded = obc->with_promoted_lock<State, IOInterruptCondition>([this, obc] {
-        return load_head_obc(obc);
+        return load_obc(obc);
       });
     }
     return loaded.safe_then_interruptible([func = std::move(func)](auto obc) {
@@ -1085,16 +1085,12 @@ PG::with_clone_obc(hobject_t oid, with_obc_func_t&& func)
         logger().debug("with_clone_obc: found {} in cache", clone->get_oid());
       } else {
         logger().debug("with_clone_obc: cache miss on {}", clone->get_oid());
-        //TODO: generalize load_head_obc -> load_obc (support head/clone obc)
         loaded = clone->template with_promoted_lock<State, IOInterruptCondition>(
-          [clone, head, this] {
-          return backend->load_metadata(clone->get_oid()).safe_then_interruptible(
-            [clone=std::move(clone), head=std::move(head)](auto md) mutable {
-            clone->set_clone_state(std::move(md->os), std::move(head));
-            return clone;
-          });
+          [clone, this] {
+          return load_obc(clone);
         });
       }
+      clone->head = head;
       return loaded.safe_then_interruptible([func = std::move(func)](auto clone) {
         return std::move(func)(std::move(clone));
       });
@@ -1124,23 +1120,26 @@ PG::with_existing_clone_obc(ObjectContextRef clone, with_obc_func_t&& func)
 }
 
 PG::load_obc_iertr::future<crimson::osd::ObjectContextRef>
-PG::load_head_obc(ObjectContextRef obc)
+PG::load_obc(ObjectContextRef obc)
 {
   return backend->load_metadata(obc->get_oid()).safe_then_interruptible(
     [obc=std::move(obc)](auto md)
     -> load_obc_ertr::future<crimson::osd::ObjectContextRef> {
     const hobject_t& oid = md->os.oi.soid;
     logger().debug(
-      "load_head_obc: loaded obs {} for {}", md->os.oi, oid);
-    if (!md->ssc) {
-      logger().error(
-        "load_head_obc: oid {} missing snapsetcontext", oid);
-      return crimson::ct_error::object_corrupted::make();
-
+      "load_obc: loaded obs {} for {}", md->os.oi, oid);
+    if (oid.is_head()) {
+      if (!md->ssc) {
+        logger().error(
+          "load_obc: oid {} missing snapsetcontext", oid);
+        return crimson::ct_error::object_corrupted::make();
+      }
+      obc->set_head_state(std::move(md->os), std::move(md->ssc));
+    } else {
+      obc->set_clone_state(std::move(md->os));
     }
-    obc->set_head_state(std::move(md->os), std::move(md->ssc));
     logger().debug(
-      "load_head_obc: returning obc {} for {}",
+      "load_obc: returning obc {} for {}",
       obc->obs.oi, obc->obs.oi.soid);
     return load_obc_ertr::make_ready_future<
       crimson::osd::ObjectContextRef>(obc);
index c6a35c0aaa96510b7492d06823e6bd5c6ce987cb..4f4f9cb21b1952cbf81cbf2cd457e7ff21d5ce77 100644 (file)
@@ -527,7 +527,7 @@ public:
   get_or_load_head_obc(hobject_t oid);
 
   load_obc_iertr::future<crimson::osd::ObjectContextRef>
-  load_head_obc(ObjectContextRef obc);
+  load_obc(ObjectContextRef obc);
 
   load_obc_iertr::future<>
   reload_obc(crimson::osd::ObjectContext& obc) const;