Skip to content

Commit 9204194

Browse files
authored
Merge pull request ceph#59011 from xxhdx1985126/wip-67327
crimson/osd: send empty transactions to backfill targets that haven't backfilled the objects yet Reviewed-by: Matan Breizman <[email protected]>
2 parents 26b82db + dc366fa commit 9204194

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/crimson/osd/pg.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,28 @@ bool PG::is_degraded_or_backfilling_object(const hobject_t& soid) const {
16981698
return false;
16991699
}
17001700

1701+
bool PG::should_send_op(
1702+
pg_shard_t peer,
1703+
const hobject_t &hoid) const
1704+
{
1705+
if (peer == get_primary())
1706+
return true;
1707+
bool should_send =
1708+
(hoid.pool != (int64_t)get_info().pgid.pool() ||
1709+
(has_backfill_state() && hoid <= get_last_backfill_started()) ||
1710+
hoid <= peering_state.get_peer_info(peer).last_backfill);
1711+
if (!should_send) {
1712+
ceph_assert(is_backfill_target(peer));
1713+
logger().debug("{} issue_repop shipping empty opt to osd."
1714+
"{}, object {} beyond std::max(last_backfill_started, "
1715+
"peer_info[peer].last_backfill {})",
1716+
peer, hoid, peering_state.get_peer_info(peer).last_backfill);
1717+
}
1718+
return should_send;
1719+
// TODO: should consider async recovery cases in the future which are not supported
1720+
// by crimson yet
1721+
}
1722+
17011723
PG::interruptible_future<std::optional<PG::complete_op_t>>
17021724
PG::already_complete(const osd_reqid_t& reqid)
17031725
{

src/crimson/osd/pg.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ class PG : public boost::intrusive_ref_counter<
521521
bool get_need_up_thru() const {
522522
return peering_state.get_need_up_thru();
523523
}
524+
bool should_send_op(pg_shard_t peer, const hobject_t &hoid) const;
524525
epoch_t get_same_interval_since() const {
525526
return get_info().history.same_interval_since;
526527
}
@@ -740,6 +741,15 @@ class PG : public boost::intrusive_ref_counter<
740741
PeeringState& get_peering_state() final {
741742
return peering_state;
742743
}
744+
bool has_backfill_state() const {
745+
return (bool)(recovery_handler->backfill_state);
746+
}
747+
const BackfillState& get_backfill_state() const {
748+
return *recovery_handler->backfill_state;
749+
}
750+
hobject_t get_last_backfill_started() const {
751+
return get_backfill_state().get_last_backfill_started();
752+
}
743753
bool has_reset_since(epoch_t epoch) const final {
744754
return peering_state.pg_has_reset_since(epoch);
745755
}

src/crimson/osd/replicated_backend.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@ ReplicatedBackend::_submit_transaction(std::set<pg_shard_t>&& pg_shards,
6565
min_epoch,
6666
tid,
6767
osd_op_p.at_version);
68-
m->set_data(encoded_txn);
68+
if (pg.should_send_op(pg_shard, hoid)) {
69+
m->set_data(encoded_txn);
70+
} else {
71+
ceph::os::Transaction t;
72+
bufferlist bl;
73+
encode(t, bl);
74+
m->set_data(bl);
75+
}
6976
pending_txn->second.acked_peers.push_back({pg_shard, eversion_t{}});
7077
encode(log_entries, m->logbl);
7178
m->pg_trim_to = osd_op_p.pg_trim_to;

0 commit comments

Comments
 (0)