Skip to content

Commit cadc73b

Browse files
yehudasacbodley
authored andcommitted
objecter: use read policy configurable
for localized and balanced reads. Signed-off-by: Yehuda Sadeh <[email protected]>
1 parent abbc9d4 commit cadc73b

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

src/osdc/Objecter.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ void Objecter::handle_conf_change(const ConfigProxy& conf,
242242
if (changed.count("rados_osd_op_timeout")) {
243243
osd_timeout = conf.get_val<std::chrono::seconds>("rados_osd_op_timeout");
244244
}
245+
246+
auto read_policy = conf.get_val<std::string>("rados_replica_read_policy");
247+
if (read_policy == "localize") {
248+
extra_read_flags = CEPH_OSD_FLAG_LOCALIZE_READS;
249+
} else if (read_policy == "balance") {
250+
extra_read_flags = CEPH_OSD_FLAG_BALANCE_READS;
251+
}
245252
}
246253

247254
void Objecter::update_crush_location()
@@ -5111,6 +5118,13 @@ Objecter::Objecter(CephContext *cct,
51115118
{
51125119
mon_timeout = cct->_conf.get_val<std::chrono::seconds>("rados_mon_op_timeout");
51135120
osd_timeout = cct->_conf.get_val<std::chrono::seconds>("rados_osd_op_timeout");
5121+
5122+
auto read_policy = cct->_conf.get_val<std::string>("rados_replica_read_policy");
5123+
if (read_policy == "localize") {
5124+
extra_read_flags = CEPH_OSD_FLAG_LOCALIZE_READS;
5125+
} else if (read_policy == "balance") {
5126+
extra_read_flags = CEPH_OSD_FLAG_BALANCE_READS;
5127+
}
51145128
}
51155129

51165130
Objecter::~Objecter()

src/osdc/Objecter.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,8 @@ class Objecter : public md_config_obs_t, public Dispatcher {
17231723
bool keep_balanced_budget = false;
17241724
bool honor_pool_full = true;
17251725

1726+
std::atomic<int> extra_read_flags{0};
1727+
17261728
// If this is true, accumulate a set of blocklisted entities
17271729
// to be drained by consume_blocklist_events.
17281730
bool blocklist_events_enabled = false;
@@ -3089,7 +3091,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
30893091
int *data_offset = NULL,
30903092
uint64_t features = 0,
30913093
ZTracer::Trace *parent_trace = nullptr) {
3092-
Op *o = new Op(oid, oloc, std::move(op.ops), flags | global_op_flags |
3094+
Op *o = new Op(oid, oloc, std::move(op.ops), flags | global_op_flags | extra_read_flags |
30933095
CEPH_OSD_FLAG_READ, onack, objver,
30943096
data_offset, parent_trace);
30953097
o->priority = op.priority;
@@ -3125,7 +3127,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
31253127
int flags, Op::OpComp onack,
31263128
version_t *objver = nullptr, int *data_offset = nullptr,
31273129
uint64_t features = 0, ZTracer::Trace *parent_trace = nullptr) {
3128-
Op *o = new Op(oid, oloc, std::move(op.ops), flags | global_op_flags |
3130+
Op *o = new Op(oid, oloc, std::move(op.ops), flags | global_op_flags | extra_read_flags |
31293131
CEPH_OSD_FLAG_READ, std::move(onack), objver,
31303132
data_offset, parent_trace);
31313133
o->priority = op.priority;
@@ -3164,7 +3166,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
31643166
int *ctx_budget) {
31653167
Op *o = new Op(object_t(), oloc,
31663168
std::move(op.ops),
3167-
flags | global_op_flags | CEPH_OSD_FLAG_READ |
3169+
flags | global_op_flags | CEPH_OSD_FLAG_READ | extra_read_flags |
31683170
CEPH_OSD_FLAG_IGNORE_OVERLAY,
31693171
onack, NULL);
31703172
o->target.precalc_pgid = true;
@@ -3305,7 +3307,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
33053307
ops[i].op.op = CEPH_OSD_OP_STAT;
33063308
C_Stat *fin = new C_Stat(psize, pmtime, onfinish);
33073309
Op *o = new Op(oid, oloc, std::move(ops), flags | global_op_flags |
3308-
CEPH_OSD_FLAG_READ, fin, objver);
3310+
CEPH_OSD_FLAG_READ | extra_read_flags, fin, objver);
33093311
o->snapid = snap;
33103312
o->outbl = &fin->bl;
33113313
return o;
@@ -3337,7 +3339,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
33373339
ops[i].op.extent.truncate_seq = 0;
33383340
ops[i].op.flags = op_flags;
33393341
Op *o = new Op(oid, oloc, std::move(ops), flags | global_op_flags |
3340-
CEPH_OSD_FLAG_READ, onfinish, objver,
3342+
CEPH_OSD_FLAG_READ | extra_read_flags, onfinish, objver,
33413343
nullptr, parent_trace);
33423344
o->snapid = snap;
33433345
o->outbl = pbl;
@@ -3370,7 +3372,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
33703372
ops[i].indata = cmp_bl;
33713373
ops[i].op.flags = op_flags;
33723374
Op *o = new Op(oid, oloc, std::move(ops), flags | global_op_flags |
3373-
CEPH_OSD_FLAG_READ, onfinish, objver);
3375+
CEPH_OSD_FLAG_READ | extra_read_flags, onfinish, objver);
33743376
o->snapid = snap;
33753377
return o;
33763378
}
@@ -3402,7 +3404,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
34023404
ops[i].op.extent.truncate_seq = trunc_seq;
34033405
ops[i].op.flags = op_flags;
34043406
Op *o = new Op(oid, oloc, std::move(ops), flags | global_op_flags |
3405-
CEPH_OSD_FLAG_READ, onfinish, objver);
3407+
CEPH_OSD_FLAG_READ | extra_read_flags, onfinish, objver);
34063408
o->snapid = snap;
34073409
o->outbl = pbl;
34083410
ceph_tid_t tid;
@@ -3421,7 +3423,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
34213423
ops[i].op.extent.truncate_size = 0;
34223424
ops[i].op.extent.truncate_seq = 0;
34233425
Op *o = new Op(oid, oloc, std::move(ops), flags | global_op_flags |
3424-
CEPH_OSD_FLAG_READ, onfinish, objver);
3426+
CEPH_OSD_FLAG_READ | extra_read_flags, onfinish, objver);
34253427
o->snapid = snap;
34263428
o->outbl = pbl;
34273429
ceph_tid_t tid;
@@ -3440,7 +3442,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
34403442
if (name)
34413443
ops[i].indata.append(name, ops[i].op.xattr.name_len);
34423444
Op *o = new Op(oid, oloc, std::move(ops), flags | global_op_flags |
3443-
CEPH_OSD_FLAG_READ, onfinish, objver);
3445+
CEPH_OSD_FLAG_READ | extra_read_flags, onfinish, objver);
34443446
o->snapid = snap;
34453447
o->outbl = pbl;
34463448
ceph_tid_t tid;
@@ -3457,7 +3459,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
34573459
ops[i].op.op = CEPH_OSD_OP_GETXATTRS;
34583460
C_GetAttrs *fin = new C_GetAttrs(attrset, onfinish);
34593461
Op *o = new Op(oid, oloc, std::move(ops), flags | global_op_flags |
3460-
CEPH_OSD_FLAG_READ, fin, objver);
3462+
CEPH_OSD_FLAG_READ | extra_read_flags, fin, objver);
34613463
o->snapid = snap;
34623464
o->outbl = &fin->bl;
34633465
ceph_tid_t tid;

0 commit comments

Comments
 (0)