Skip to content

Commit af17631

Browse files
yehudasacbodley
authored andcommitted
objclass: change objclass exec read calls to write ones where needed
Many of the exec calls were using a read version of the API while they were calling a write objclass method. This modifies the calls to use the write API. Fixes: https://tracker.ceph.com/issues/65889 Signed-off-by: Yehuda Sadeh <[email protected]>
1 parent 0a2f572 commit af17631

File tree

7 files changed

+92
-47
lines changed

7 files changed

+92
-47
lines changed

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/test/cls_lua/test_cls_lua.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,10 @@ TEST_F(ClsLua, Json) {
11001100

11011101
inbl.append(json_test_script);
11021102

1103-
int ret = ioctx.exec(oid, "lua", "eval_json", inbl, outbl);
1103+
librados::ObjectWriteOperation wop;
1104+
int rval;
1105+
wop.exec("lua", "eval_json", inbl, &outbl, &rval);
1106+
int ret = ioctx.operate(oid, &wop);
11041107
ASSERT_EQ(ret, 0);
11051108

11061109
std::string out(outbl.c_str(), outbl.length());

src/test/cls_sdk/test_cls_sdk.cc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ TEST(ClsSDK, TestSDKCoverageWrite) {
1313
IoCtx ioctx;
1414
cluster.ioctx_create(pool_name.c_str(), ioctx);
1515

16-
bufferlist in, out;
17-
ASSERT_EQ(0, ioctx.exec("myobject", "sdk", "test_coverage_write", in, out));
16+
bufferlist in;
17+
librados::ObjectWriteOperation op;
18+
op.exec("sdk", "test_coverage_write", in);
19+
ASSERT_EQ(0, ioctx.operate("myobject", &op));
1820

1921
ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
2022
}
@@ -26,9 +28,14 @@ TEST(ClsSDK, TestSDKCoverageReplay) {
2628
IoCtx ioctx;
2729
cluster.ioctx_create(pool_name.c_str(), ioctx);
2830

29-
bufferlist in, out;
30-
ASSERT_EQ(0, ioctx.exec("myobject", "sdk", "test_coverage_write", in, out));
31-
ASSERT_EQ(0, ioctx.exec("myobject", "sdk", "test_coverage_replay", in, out));
31+
bufferlist in;
32+
librados::ObjectWriteOperation op;
33+
op.exec("sdk", "test_coverage_write", in);
34+
ASSERT_EQ(0, ioctx.operate("myobject", &op));
35+
36+
librados::ObjectWriteOperation op2;
37+
op2.exec("sdk", "test_coverage_replay", in);
38+
ASSERT_EQ(0, ioctx.operate("myobject", &op2));
3239

3340
ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
3441
}

0 commit comments

Comments
 (0)