Skip to content

Commit 13883f5

Browse files
authored
Merge pull request ceph#56180 from yehudasa/wip-objecter-local-read
objecter: use configurable to set local and balanced reads Reviewed-by: Mark Kogan <[email protected]> Reviewed-by: Casey Bodley <[email protected]> Reviewed-by: Radoslaw Zarzynski <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]>
2 parents 90a35dc + 158f7c3 commit 13883f5

File tree

15 files changed

+192
-76
lines changed

15 files changed

+192
-76
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
overrides:
2+
ceph:
3+
conf:
4+
osd:
5+
crush location: 'root=default host=host-$id'
6+
client:
7+
rados replica read policy: balance
8+

qa/suites/rados/verify/read-affinity/default.yaml

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
overrides:
2+
ceph:
3+
conf:
4+
osd:
5+
crush location: 'root=default host=host-$id'
6+
client:
7+
crush location: host=host-0
8+
rados replica read policy: localize
9+

src/cls/lua/cls_lua_client.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ namespace cls_lua_client {
2929
bufferlist inbl;
3030
encode(op, inbl);
3131

32-
return ioctx.exec(oid, "lua", "eval_bufferlist", inbl, output);
32+
librados::ObjectWriteOperation wop;
33+
int rval;
34+
wop.exec("lua", "eval_bufferlist", inbl, &output, &rval);
35+
return ioctx.operate(oid, &wop);
3336
}
3437
}

src/cls/numops/cls_numops_client.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@ namespace rados {
2828
const std::string& key,
2929
double value_to_add)
3030
{
31-
bufferlist in, out;
31+
bufferlist in;
3232
encode(key, in);
3333

3434
std::stringstream stream;
3535
stream << value_to_add;
3636

3737
encode(stream.str(), in);
3838

39-
return ioctx->exec(oid, "numops", "add", in, out);
39+
librados::ObjectWriteOperation op;
40+
op.exec("numops", "add", in);
41+
42+
return ioctx->operate(oid, &op);
4043
}
4144

4245
int sub(librados::IoCtx *ioctx,
@@ -60,7 +63,10 @@ namespace rados {
6063

6164
encode(stream.str(), in);
6265

63-
return ioctx->exec(oid, "numops", "mul", in, out);
66+
librados::ObjectWriteOperation op;
67+
op.exec("numops", "mul", in);
68+
69+
return ioctx->operate(oid, &op);
6470
}
6571

6672
int div(librados::IoCtx *ioctx,

src/cls/otp/cls_otp_client.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ namespace rados {
6868
bufferlist in;
6969
bufferlist out;
7070
encode(op, in);
71-
int r = ioctx.exec(oid, "otp", "otp_check", in, out);
71+
librados::ObjectWriteOperation wop;
72+
wop.exec("otp", "otp_check", in);
73+
int r = ioctx.operate(oid, &wop);
7274
if (r < 0) {
7375
return r;
7476
}

src/cls/rbd/cls_rbd_client.cc

Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,9 +1873,9 @@ int mirror_mode_set(librados::IoCtx *ioctx,
18731873
bufferlist in_bl;
18741874
encode(static_cast<uint32_t>(mirror_mode), in_bl);
18751875

1876-
bufferlist out_bl;
1877-
int r = ioctx->exec(RBD_MIRRORING, "rbd", "mirror_mode_set", in_bl,
1878-
out_bl);
1876+
librados::ObjectWriteOperation op;
1877+
op.exec("rbd", "mirror_mode_set", in_bl);
1878+
int r = ioctx->operate(RBD_MIRRORING, &op);
18791879
if (r < 0) {
18801880
return r;
18811881
}
@@ -2002,9 +2002,9 @@ int mirror_peer_remove(librados::IoCtx *ioctx,
20022002
bufferlist in_bl;
20032003
encode(uuid, in_bl);
20042004

2005-
bufferlist out_bl;
2006-
int r = ioctx->exec(RBD_MIRRORING, "rbd", "mirror_peer_remove", in_bl,
2007-
out_bl);
2005+
librados::ObjectWriteOperation op;
2006+
op.exec("rbd", "mirror_peer_remove", in_bl);
2007+
int r = ioctx->operate(RBD_MIRRORING, &op);
20082008
if (r < 0) {
20092009
return r;
20102010
}
@@ -2018,9 +2018,9 @@ int mirror_peer_set_client(librados::IoCtx *ioctx,
20182018
encode(uuid, in_bl);
20192019
encode(client_name, in_bl);
20202020

2021-
bufferlist out_bl;
2022-
int r = ioctx->exec(RBD_MIRRORING, "rbd", "mirror_peer_set_client",
2023-
in_bl, out_bl);
2021+
librados::ObjectWriteOperation op;
2022+
op.exec("rbd", "mirror_peer_set_client", in_bl);
2023+
int r = ioctx->operate(RBD_MIRRORING, &op);
20242024
if (r < 0) {
20252025
return r;
20262026
}
@@ -2034,9 +2034,9 @@ int mirror_peer_set_cluster(librados::IoCtx *ioctx,
20342034
encode(uuid, in_bl);
20352035
encode(cluster_name, in_bl);
20362036

2037-
bufferlist out_bl;
2038-
int r = ioctx->exec(RBD_MIRRORING, "rbd", "mirror_peer_set_cluster",
2039-
in_bl, out_bl);
2037+
librados::ObjectWriteOperation op;
2038+
op.exec("rbd", "mirror_peer_set_cluster", in_bl);
2039+
int r = ioctx->operate(RBD_MIRRORING, &op);
20402040
if (r < 0) {
20412041
return r;
20422042
}
@@ -2050,9 +2050,9 @@ int mirror_peer_set_direction(
20502050
encode(uuid, in_bl);
20512051
encode(static_cast<uint8_t>(mirror_peer_direction), in_bl);
20522052

2053-
bufferlist out_bl;
2054-
int r = ioctx->exec(RBD_MIRRORING, "rbd", "mirror_peer_set_direction",
2055-
in_bl, out_bl);
2053+
librados::ObjectWriteOperation op;
2054+
op.exec("rbd", "mirror_peer_set_direction", in_bl);
2055+
int r = ioctx->operate(RBD_MIRRORING, &op);
20562056
if (r < 0) {
20572057
return r;
20582058
}
@@ -2630,39 +2630,47 @@ int group_dir_list(librados::IoCtx *ioctx, const std::string &oid,
26302630
int group_dir_add(librados::IoCtx *ioctx, const std::string &oid,
26312631
const std::string &name, const std::string &id)
26322632
{
2633-
bufferlist in, out;
2633+
bufferlist in;
26342634
encode(name, in);
26352635
encode(id, in);
2636-
return ioctx->exec(oid, "rbd", "group_dir_add", in, out);
2636+
librados::ObjectWriteOperation op;
2637+
op.exec("rbd", "group_dir_add", in);
2638+
return ioctx->operate(oid, &op);
26372639
}
26382640

26392641
int group_dir_rename(librados::IoCtx *ioctx, const std::string &oid,
26402642
const std::string &src, const std::string &dest,
26412643
const std::string &id)
26422644
{
2643-
bufferlist in, out;
2645+
bufferlist in;
26442646
encode(src, in);
26452647
encode(dest, in);
26462648
encode(id, in);
2647-
return ioctx->exec(oid, "rbd", "group_dir_rename", in, out);
2649+
librados::ObjectWriteOperation op;
2650+
op.exec("rbd", "group_dir_rename", in);
2651+
return ioctx->operate(oid, &op);
26482652
}
26492653

26502654
int group_dir_remove(librados::IoCtx *ioctx, const std::string &oid,
26512655
const std::string &name, const std::string &id)
26522656
{
2653-
bufferlist in, out;
2657+
bufferlist in;
26542658
encode(name, in);
26552659
encode(id, in);
2656-
return ioctx->exec(oid, "rbd", "group_dir_remove", in, out);
2660+
librados::ObjectWriteOperation op;
2661+
op.exec("rbd", "group_dir_remove", in);
2662+
return ioctx->operate(oid, &op);
26572663
}
26582664

26592665
int group_image_remove(librados::IoCtx *ioctx, const std::string &oid,
26602666
const cls::rbd::GroupImageSpec &spec)
26612667
{
2662-
bufferlist bl, bl2;
2668+
bufferlist bl;
26632669
encode(spec, bl);
26642670

2665-
return ioctx->exec(oid, "rbd", "group_image_remove", bl, bl2);
2671+
librados::ObjectWriteOperation op;
2672+
op.exec("rbd", "group_image_remove", bl);
2673+
return ioctx->operate(oid, &op);
26662674
}
26672675

26682676
int group_image_list(librados::IoCtx *ioctx,
@@ -2692,28 +2700,34 @@ int group_image_list(librados::IoCtx *ioctx,
26922700
int group_image_set(librados::IoCtx *ioctx, const std::string &oid,
26932701
const cls::rbd::GroupImageStatus &st)
26942702
{
2695-
bufferlist bl, bl2;
2703+
bufferlist bl;
26962704
encode(st, bl);
26972705

2698-
return ioctx->exec(oid, "rbd", "group_image_set", bl, bl2);
2706+
librados::ObjectWriteOperation op;
2707+
op.exec("rbd", "group_image_set", bl);
2708+
return ioctx->operate(oid, &op);
26992709
}
27002710

27012711
int image_group_add(librados::IoCtx *ioctx, const std::string &oid,
27022712
const cls::rbd::GroupSpec &group_spec)
27032713
{
2704-
bufferlist bl, bl2;
2714+
bufferlist bl;
27052715
encode(group_spec, bl);
27062716

2707-
return ioctx->exec(oid, "rbd", "image_group_add", bl, bl2);
2717+
librados::ObjectWriteOperation op;
2718+
op.exec("rbd", "image_group_add", bl);
2719+
return ioctx->operate(oid, &op);
27082720
}
27092721

27102722
int image_group_remove(librados::IoCtx *ioctx, const std::string &oid,
27112723
const cls::rbd::GroupSpec &group_spec)
27122724
{
2713-
bufferlist bl, bl2;
2725+
bufferlist bl;
27142726
encode(group_spec, bl);
27152727

2716-
return ioctx->exec(oid, "rbd", "image_group_remove", bl, bl2);
2728+
librados::ObjectWriteOperation op;
2729+
op.exec("rbd", "image_group_remove", bl);
2730+
return ioctx->operate(oid, &op);
27172731
}
27182732

27192733
void image_group_get_start(librados::ObjectReadOperation *op)
@@ -2753,19 +2767,23 @@ int group_snap_set(librados::IoCtx *ioctx, const std::string &oid,
27532767
const cls::rbd::GroupSnapshot &snapshot)
27542768
{
27552769
using ceph::encode;
2756-
bufferlist inbl, outbl;
2770+
bufferlist inbl;
27572771
encode(snapshot, inbl);
2758-
int r = ioctx->exec(oid, "rbd", "group_snap_set", inbl, outbl);
2772+
librados::ObjectWriteOperation op;
2773+
op.exec("rbd", "group_snap_set", inbl);
2774+
int r = ioctx->operate(oid, &op);
27592775
return r;
27602776
}
27612777

27622778
int group_snap_remove(librados::IoCtx *ioctx, const std::string &oid,
27632779
const std::string &snap_id)
27642780
{
27652781
using ceph::encode;
2766-
bufferlist inbl, outbl;
2782+
bufferlist inbl;
27672783
encode(snap_id, inbl);
2768-
return ioctx->exec(oid, "rbd", "group_snap_remove", inbl, outbl);
2784+
librados::ObjectWriteOperation op;
2785+
op.exec("rbd", "group_snap_remove", inbl);
2786+
return ioctx->operate(oid, &op);
27692787
}
27702788

27712789
int group_snap_get_by_id(librados::IoCtx *ioctx, const std::string &oid,

src/cls/rgw/cls_rgw_client.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,9 @@ int cls_rgw_bi_put(librados::IoCtx& io_ctx, const string oid, const rgw_cls_bi_e
481481
rgw_cls_bi_put_op call;
482482
call.entry = entry;
483483
encode(call, in);
484-
int r = io_ctx.exec(oid, RGW_CLASS, RGW_BI_PUT, in, out);
484+
librados::ObjectWriteOperation op;
485+
op.exec(RGW_CLASS, RGW_BI_PUT, in);
486+
int r = io_ctx.operate(oid, &op);
485487
if (r < 0)
486488
return r;
487489

@@ -1223,15 +1225,19 @@ int cls_rgw_set_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
12231225
cls_rgw_set_bucket_resharding_op call;
12241226
call.entry = entry;
12251227
encode(call, in);
1226-
return io_ctx.exec(oid, RGW_CLASS, RGW_SET_BUCKET_RESHARDING, in, out);
1228+
librados::ObjectWriteOperation op;
1229+
op.exec(RGW_CLASS, RGW_SET_BUCKET_RESHARDING, in);
1230+
return io_ctx.operate(oid, &op);
12271231
}
12281232

12291233
int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid)
12301234
{
12311235
bufferlist in, out;
12321236
cls_rgw_clear_bucket_resharding_op call;
12331237
encode(call, in);
1234-
return io_ctx.exec(oid, RGW_CLASS, RGW_CLEAR_BUCKET_RESHARDING, in, out);
1238+
librados::ObjectWriteOperation op;
1239+
op.exec(RGW_CLASS, RGW_CLEAR_BUCKET_RESHARDING, in);
1240+
return io_ctx.operate(oid, &op);
12351241
}
12361242

12371243
int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,

src/common/options/global.yaml.in

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6377,6 +6377,36 @@ options:
63776377
min: 0
63786378
flags:
63796379
- runtime
6380+
- name: rados_replica_read_policy
6381+
type: str
6382+
level: advanced
6383+
desc: read policy for sending read requests to OSD
6384+
fmt_desc : |
6385+
Policy for determining which OSD will receive read operations.
6386+
If set to ``default``, each PG's primary OSD will always be used
6387+
for read operations. If set to ``balance``, read operations will
6388+
be sent to a randomly selected OSD within the replica set. If set
6389+
to ``localize``, read operations will be sent to the closest OSD
6390+
as determined by the CRUSH map.
6391+
default: default
6392+
enum_values:
6393+
- default
6394+
- balance
6395+
- localize
6396+
flags:
6397+
- runtime
6398+
- name: rados_replica_read_policy_on_objclass
6399+
type: bool
6400+
level: advanced
6401+
desc: enable read policy for sending read requests to OSD on objclass ops
6402+
fmt_desc : |
6403+
This would enable objclass ops to leverage read policy that can
6404+
determine which OSD will receive read operation. The reason
6405+
we might want to disable this is because objclass operations may
6406+
not be flagged correctly as read or write ops and we don't want
6407+
write ops to be sent to the wrong OSD (and system won't function
6408+
correctly).
6409+
default: false
63806410
# true if LTTng-UST tracepoints should be enabled
63816411
- name: rados_tracing
63826412
type: bool

0 commit comments

Comments
 (0)