Skip to content

Commit 414085c

Browse files
authored
Merge pull request ceph#57367 from xxhdx1985126/wip-65872
crimson/osd/osd_operations/client_request: check "can_serve_replica_reads" before getting obc Reviewed-by: Samuel Just <[email protected]> Reviewed-by: Matan Breizman <[email protected]>
2 parents ba287d8 + 5d5ce17 commit 414085c

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

src/crimson/osd/osd_operations/client_request.cc

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,30 @@ ClientRequest::interruptible_future<> ClientRequest::with_pg_process_interruptib
170170
pg.wait_for_active_blocker,
171171
&decltype(pg.wait_for_active_blocker)::wait));
172172

173+
if (int res = op_info.set_from_op(&*m, *pg.get_osdmap());
174+
res != 0) {
175+
co_await reply_op_error(pgref, res);
176+
co_return;
177+
}
178+
179+
if (!pg.is_primary()) {
180+
// primary can handle both normal ops and balanced reads
181+
if (is_misdirected(pg)) {
182+
DEBUGDPP("{}.{}: dropping misdirected op",
183+
pg, *this, this_instance_id);
184+
co_return;
185+
} else if (const hobject_t& hoid = m->get_hobj();
186+
!pg.get_peering_state().can_serve_replica_read(hoid)) {
187+
DEBUGDPP("{}.{}: unstable write on replica, bouncing to primary",
188+
pg, *this, this_instance_id);
189+
co_await reply_op_error(pgref, -EAGAIN);
190+
co_return;
191+
} else {
192+
DEBUGDPP("{}.{}: serving replica read on oid {}",
193+
pg, *this, this_instance_id, m->get_hobj());
194+
}
195+
}
196+
173197
DEBUGDPP("{}.{}: pg active, entering process[_pg]_op",
174198
*pgref, *this, this_instance_id);
175199

@@ -335,11 +359,6 @@ ClientRequest::process_op(
335359

336360
DEBUGDPP("{}.{}: entered get_obc stage, about to wait_scrub",
337361
*pg, *this, this_instance_id);
338-
if (int res = op_info.set_from_op(&*m, *pg->get_osdmap());
339-
res != 0) {
340-
co_await reply_op_error(pg, res);
341-
co_return;
342-
}
343362
co_await ihref.enter_blocker(
344363
*this, pg->scrubber, &decltype(pg->scrubber)::wait_scrub,
345364
m->get_hobj());
@@ -468,24 +487,6 @@ ClientRequest::do_process(
468487
co_return;
469488
}
470489

471-
if (!pg->is_primary()) {
472-
// primary can handle both normal ops and balanced reads
473-
if (is_misdirected(*pg)) {
474-
DEBUGDPP("{}.{}: dropping misdirected op",
475-
*pg, *this, this_instance_id);
476-
co_return;
477-
} else if (const hobject_t& hoid = m->get_hobj();
478-
!pg->get_peering_state().can_serve_replica_read(hoid)) {
479-
DEBUGDPP("{}.{}: unstable write on replica, bouncing to primary",
480-
*pg, *this, this_instance_id);
481-
co_await reply_op_error(pg, -EAGAIN);
482-
co_return;
483-
} else {
484-
DEBUGDPP("{}.{}: serving replica read on oid {}",
485-
*pg, *this, this_instance_id, m->get_hobj());
486-
}
487-
}
488-
489490
auto [submitted, all_completed] = co_await pg->do_osd_ops(
490491
m, r_conn, obc, op_info, snapc
491492
);

0 commit comments

Comments
 (0)