]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/osd_operations/client_request: check "can_serve_replica_reads" before... 58819/head
authorXuehan Xu <xxhdx1985126@gmail.com>
Thu, 9 May 2024 02:24:26 +0000 (10:24 +0800)
committerMatan Breizman <mbreizma@redhat.com>
Thu, 25 Jul 2024 07:23:56 +0000 (10:23 +0300)
Fixes: https://tracker.ceph.com/issues/65872
Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
(cherry picked from commit 5d5ce176b3853284802e81e5743b55919c4c808d)

src/crimson/osd/osd_operations/client_request.cc

index d78d05cf7087d01049f6b550f68f56c32f1ae60d..4a721d1277fb6994f24dfda2ccc0c5401716bcb0 100644 (file)
@@ -170,6 +170,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);
 
@@ -335,11 +359,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());
@@ -468,24 +487,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
   );