]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/osd_operations/client_request: check "can_serve_replica_reads" before... 57367/head
authorXuehan Xu <xxhdx1985126@gmail.com>
Thu, 9 May 2024 02:24:26 +0000 (10:24 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Tue, 11 Jun 2024 02:05:17 +0000 (10:05 +0800)
Fixes: https://tracker.ceph.com/issues/65872
Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
src/crimson/osd/osd_operations/client_request.cc

index b48e52ff31edaa077d8ec29709a5622869761e43..2cc7a7e4730133ecf68480a09f2c03521c260ae8 100644 (file)
@@ -167,6 +167,30 @@ ClientRequest::interruptible_future<> ClientRequest::with_pg_process_interruptib
       pg.wait_for_active_blocker,
       &decltype(pg.wait_for_active_blocker)::wait));
 
+  if (int res = op_info.set_from_op(&*m, *pg.get_osdmap());
+      res != 0) {
+    co_await reply_op_error(pgref, res);
+    co_return;
+  }
+
+  if (!pg.is_primary()) {
+    // primary can handle both normal ops and balanced reads
+    if (is_misdirected(pg)) {
+      DEBUGDPP("{}.{}: dropping misdirected op",
+              pg, *this, this_instance_id);
+      co_return;
+    } else if (const hobject_t& hoid = m->get_hobj();
+               !pg.get_peering_state().can_serve_replica_read(hoid)) {
+      DEBUGDPP("{}.{}: unstable write on replica, bouncing to primary",
+              pg, *this, this_instance_id);
+      co_await reply_op_error(pgref, -EAGAIN);
+      co_return;
+    } else {
+      DEBUGDPP("{}.{}: serving replica read on oid {}",
+              pg, *this, this_instance_id, m->get_hobj());
+    }
+  }
+
   DEBUGDPP("{}.{}: pg active, entering process[_pg]_op",
           *pgref, *this, this_instance_id);
 
@@ -332,11 +356,6 @@ ClientRequest::process_op(
 
   DEBUGDPP("{}.{}: entered get_obc stage, about to wait_scrub",
           *pg, *this, this_instance_id);
-  if (int res = op_info.set_from_op(&*m, *pg->get_osdmap());
-      res != 0) {
-    co_await reply_op_error(pg, res);
-    co_return;
-  }
   co_await ihref.enter_blocker(
     *this, pg->scrubber, &decltype(pg->scrubber)::wait_scrub,
     m->get_hobj());
@@ -465,24 +484,6 @@ ClientRequest::do_process(
     co_return;
   }
 
-  if (!pg->is_primary()) {
-    // primary can handle both normal ops and balanced reads
-    if (is_misdirected(*pg)) {
-      DEBUGDPP("{}.{}: dropping misdirected op",
-              *pg, *this, this_instance_id);
-      co_return;
-    } else if (const hobject_t& hoid = m->get_hobj();
-               !pg->get_peering_state().can_serve_replica_read(hoid)) {
-      DEBUGDPP("{}.{}: unstable write on replica, bouncing to primary",
-              *pg, *this, this_instance_id);
-      co_await reply_op_error(pg, -EAGAIN);
-      co_return;
-    } else {
-      DEBUGDPP("{}.{}: serving replica read on oid {}",
-              *pg, *this, this_instance_id, m->get_hobj());
-    }
-  }
-
   auto [submitted, all_completed] = co_await pg->do_osd_ops(
     m, r_conn, obc, op_info, snapc
   );