Skip to content

Commit 3e6c66f

Browse files
committed
osdc: Add stub for ability to force an op to always go to a particular shard
This will eventually be used by SplitIo to direct ops to the correct OSD. Signed-off-by: Alex Ainscow <[email protected]>
1 parent ae57b80 commit 3e6c66f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/osdc/Objecter.cc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3099,7 +3099,18 @@ int Objecter::_calc_target(op_target_t *t, bool any_change)
30993099
t->pg_num_mask = pg_num_mask;
31003100
t->pg_num_pending = pg_num_pending;
31013101
spg_t spgid(actual_pgid);
3102-
if (pi->is_erasure()) {
3102+
if (t->force_shard) {
3103+
t->osd = t->acting[int(*t->force_shard)];
3104+
// In some redrive scenarios, the acting set can change. Fail the IO
3105+
// and retry.
3106+
if (!osdmap->exists(t->osd)) {
3107+
t->osd = -1;
3108+
return RECALC_OP_TARGET_POOL_DNE;
3109+
}
3110+
if (pi->is_erasure()) {
3111+
spgid.reset_shard(osdmap->pgtemp_undo_primaryfirst(*pi, actual_pgid, *t->force_shard));
3112+
}
3113+
} else if (pi->is_erasure()) {
31033114
// Optimized EC pools need to be careful when calculating the shard
31043115
// because an OSD may have multiple shards and the primary shard
31053116
// might not be the first one in the acting set. The lookup
@@ -3128,7 +3139,7 @@ int Objecter::_calc_target(op_target_t *t, bool any_change)
31283139
<< " acting " << t->acting
31293140
<< " primary " << acting_primary << dendl;
31303141
t->used_replica = false;
3131-
if ((t->flags & (CEPH_OSD_FLAG_BALANCE_READS |
3142+
if (!t->force_shard && (t->flags & (CEPH_OSD_FLAG_BALANCE_READS |
31323143
CEPH_OSD_FLAG_LOCALIZE_READS)) &&
31333144
!is_write && pi->is_replicated() && t->acting.size() > 1) {
31343145
int osd;
@@ -3165,7 +3176,7 @@ int Objecter::_calc_target(op_target_t *t, bool any_change)
31653176
osd = t->acting[best];
31663177
}
31673178
t->osd = osd;
3168-
} else {
3179+
} else if (!t->force_shard) {
31693180
t->osd = acting_primary;
31703181
}
31713182
}
@@ -3728,7 +3739,7 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m)
37283739
}
37293740
}
37303741

3731-
if (rc == -EAGAIN) {
3742+
if (rc == -EAGAIN && !op->target.force_shard) {
37323743
ldout(cct, 7) << " got -EAGAIN, resubmitting" << dendl;
37333744
if (op->has_completion())
37343745
num_in_flight--;

src/osdc/Objecter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
18741874
bool paused = false;
18751875

18761876
int osd = -1; ///< the final target osd, or -1
1877+
std::optional<shard_id_t> force_shard; // If set, only this shard may be used.
18771878

18781879
epoch_t last_force_resend = 0;
18791880

0 commit comments

Comments
 (0)