]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/client_request: Move writer SnapContext initialization
authorMatan Breizman <mbreizma@redhat.com>
Wed, 15 Mar 2023 15:45:27 +0000 (15:45 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 15 Mar 2023 16:17:37 +0000 (16:17 +0000)
Move the initialization from PG::do_osd_ops() to ClientRequest::do_process()
in order to allow for ORDERSNAP error checking before do_osd_ops. (See next commit)

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

index 2cc2c59d282a0cdee0050a3a78aae01fb14007fe..20fc7beb9e1067fb1235ee6e47fcf4b26be9fac6 100644 (file)
@@ -289,6 +289,8 @@ ClientRequest::do_process(
     return reply_op_error(pg, -ENOENT);
   }
 
+  SnapContext snapc = get_snapc(pg,obc);
+
   if (!pg->is_primary()) {
     // primary can handle both normal ops and balanced reads
     if (is_misdirected(*pg)) {
@@ -305,7 +307,7 @@ ClientRequest::do_process(
                      __func__, m->get_hobj());
     }
   }
-  return pg->do_osd_ops(m, obc, op_info).safe_then_unpack_interruptible(
+  return pg->do_osd_ops(m, obc, op_info, snapc).safe_then_unpack_interruptible(
     [this, pg, &ihref](auto submitted, auto all_completed) mutable {
       return submitted.then_interruptible([this, pg, &ihref] {
        return ihref.enter_stage<interruptor>(pp(*pg).wait_repop, *this);
@@ -355,4 +357,28 @@ void ClientRequest::put_historic() const
   put_historic_shard_services->get_registry().put_historic(*this);
 }
 
+const SnapContext ClientRequest::get_snapc(
+  Ref<PG>& pg,
+  crimson::osd::ObjectContextRef obc) const
+{
+  SnapContext snapc;
+  if (op_info.may_write() || op_info.may_cache()) {
+    // snap
+    if (pg->get_pgpool().info.is_pool_snaps_mode()) {
+      // use pool's snapc
+      snapc = pg->get_pgpool().snapc;
+      logger().debug("{} using pool's snapc snaps={}",
+                     __func__, snapc.snaps);
+
+    } else {
+      // client specified snapc
+      snapc.seq = m->get_snap_seq();
+      snapc.snaps = m->get_snaps();
+      logger().debug("{} client specified snapc seq={} snaps={}",
+                     __func__, snapc.seq, snapc.snaps);
+    }
+  }
+  return snapc;
+}
+
 }
index a44893b9230e321209a2e8bda7dd70c7afeda1b2..a7d68fccf2836cfe6da0425beed96aaeea656fff 100644 (file)
@@ -242,6 +242,10 @@ private:
 
   bool is_misdirected(const PG& pg) const;
 
+  const SnapContext get_snapc(
+    Ref<PG>& pg,
+    crimson::osd::ObjectContextRef obc) const;
+
 public:
 
   friend class LttngBackend;
index 9400f1a260028d7140d885e4bfb106d6d7f021cf..82f51d3274532c16c4d0662fa4c3ff304af9aba2 100644 (file)
@@ -952,28 +952,12 @@ PG::do_osd_ops_iertr::future<PG::pg_rep_op_fut_t<MURef<MOSDOpReply>>>
 PG::do_osd_ops(
   Ref<MOSDOp> m,
   ObjectContextRef obc,
-  const OpInfo &op_info)
+  const OpInfo &op_info,
+  const SnapContext& snapc)
 {
   if (__builtin_expect(stopping, false)) {
     throw crimson::common::system_shutdown_exception();
   }
-  SnapContext snapc;
-  if (op_info.may_write() || op_info.may_cache()) {
-    // snap
-    if (get_pgpool().info.is_pool_snaps_mode()) {
-      // use pool's snapc
-      snapc = get_pgpool().snapc;
-      logger().debug("{} using pool's snapc snaps={}",
-                     __func__, snapc.snaps);
-
-    } else {
-      // client specified snapc
-      snapc.seq = m->get_snap_seq();
-      snapc.snaps = m->get_snaps();
-      logger().debug("{} client specified snapc seq={} snaps={}",
-                     __func__, snapc.seq, snapc.snaps);
-    }
-  }
   return do_osd_ops_execute<MURef<MOSDOpReply>>(
     seastar::make_lw_shared<OpsExecuter>(
       Ref<PG>{this}, obc, op_info, *m, snapc),
index 6d26f58748ffc2d53f723e6e315afdc9ae8a7fd2..573979915379707a2c4c4041e863bf3931d6f3e7 100644 (file)
@@ -565,7 +565,8 @@ private:
   do_osd_ops_iertr::future<pg_rep_op_fut_t<MURef<MOSDOpReply>>> do_osd_ops(
     Ref<MOSDOp> m,
     ObjectContextRef obc,
-    const OpInfo &op_info);
+    const OpInfo &op_info,
+    const SnapContext& snapc);
   using do_osd_ops_success_func_t =
     std::function<do_osd_ops_iertr::future<>()>;
   using do_osd_ops_failure_func_t =