#define dout_context ClassHandler::get_instance().cct
+using std::map;
+using std::set;
+using std::string;
+using std::vector;
+
+using ceph::bufferlist;
+using ceph::decode;
+using ceph::encode;
+using ceph::real_time;
+
int cls_call(cls_method_context_t hctx, const char *cls, const char *method,
- char *indata, int datalen,
- char **outdata, int *outdatalen)
+ char *indata, int datalen, char **outdata, int *outdatalen)
{
PrimaryLogPG::OpContext **pctx = (PrimaryLogPG::OpContext **)hctx;
bufferlist idata;
}
int cls_getxattr(cls_method_context_t hctx, const char *name,
- char **outdata, int *outdatalen)
+ char **outdata, int *outdatalen)
{
PrimaryLogPG::OpContext **pctx = (PrimaryLogPG::OpContext **)hctx;
vector<OSDOp> nops(1);
}
int cls_setxattr(cls_method_context_t hctx, const char *name,
- const char *value, int val_len)
+ const char *value, int val_len)
{
PrimaryLogPG::OpContext **pctx = (PrimaryLogPG::OpContext **)hctx;
vector<OSDOp> nops(1);
}
int cls_read(cls_method_context_t hctx, int ofs, int len,
- char **outdata, int *outdatalen)
+ char **outdata, int *outdatalen)
{
PrimaryLogPG::OpContext **pctx = (PrimaryLogPG::OpContext **)hctx;
vector<OSDOp> ops(1);
try {
decode(s, iter);
decode(ut, iter);
- } catch (buffer::error& err) {
+ } catch (ceph::buffer::error& err) {
return -EIO;
}
if (size)
try {
decode(s, iter);
decode(ut, iter);
- } catch (buffer::error& err) {
+ } catch (ceph::buffer::error& err) {
return -EIO;
}
if (size)
ret = (*pctx)->pg->do_osd_ops(*pctx, ops);
if (ret < 0)
return ret;
- outbl->claim(ops[0].outdata);
+ *outbl = std::move(ops[0].outdata);
return outbl->length();
}
if (r < 0)
return r;
- outbl->claim(op.outdata);
+ *outbl = std::move(op.outdata);
return outbl->length();
}
auto iter = op.outdata.cbegin();
try {
decode(*attrset, iter);
- } catch (buffer::error& err) {
+ } catch (ceph::buffer::error& err) {
return -EIO;
}
return 0;
try {
decode(*vals, iter);
decode(*more, iter);
- } catch (buffer::error& err) {
+ } catch (ceph::buffer::error& err) {
return -EIO;
}
return vals->size();
try {
decode(*keys, iter);
decode(*more, iter);
- } catch (buffer::error& err) {
+ } catch (ceph::buffer::error& err) {
return -EIO;
}
return keys->size();
try {
decode(*vals, iter);
decode(*more, iter);
- } catch (buffer::error& err) {
+ } catch (ceph::buffer::error& err) {
return -EIO;
}
return vals->size();
if (ret < 0)
return ret;
- outbl->claim(op.outdata);
+ *outbl = std::move(op.outdata);
return 0;
}
return -ENOENT;
*outbl = iter->second;
+ } catch (ceph::buffer::error& e) {
+ return -EIO;
+ }
+ return 0;
+}
+
+int cls_cxx_map_get_vals_by_keys(cls_method_context_t hctx,
+ const std::set<std::string> &keys,
+ std::map<std::string, bufferlist> *map)
+{
+ PrimaryLogPG::OpContext **pctx = (PrimaryLogPG::OpContext **)hctx;
+ vector<OSDOp> ops(1);
+ OSDOp& op = ops[0];
+ int ret;
+
+ encode(keys, op.indata);
+
+ op.op.op = CEPH_OSD_OP_OMAPGETVALSBYKEYS;
+ ret = (*pctx)->pg->do_osd_ops(*pctx, ops);
+ if (ret < 0)
+ return ret;
+
+ auto iter = op.outdata.cbegin();
+ try {
+ decode(*map, iter);
} catch (buffer::error& e) {
return -EIO;
}
PrimaryLogPG::OpContext **pctx = (PrimaryLogPG::OpContext **)hctx;
vector<OSDOp> ops(1);
OSDOp& op = ops[0];
- op.indata.claim(*inbl);
+ op.indata = std::move(*inbl);
op.op.op = CEPH_OSD_OP_OMAPSETHEADER;
auto iter = op.outdata.cbegin();
try {
decode(*watchers, iter);
- } catch (buffer::error& err) {
+ } catch (ceph::buffer::error& err) {
return -EIO;
}
return 0;
}
int cls_cxx_chunk_write_and_set(cls_method_context_t hctx, int ofs, int len,
- bufferlist *write_inbl, uint32_t op_flags, bufferlist *set_inbl,
- int set_len)
+ bufferlist *write_inbl, uint32_t op_flags,
+ bufferlist *set_inbl, int set_len)
{
PrimaryLogPG::OpContext **pctx = (PrimaryLogPG::OpContext **)hctx;
char cname[] = "cas";
return (*pctx)->pg->do_osd_ops(*pctx, ops);
}
-bool cls_has_chunk(cls_method_context_t hctx, string fp_oid)
+int cls_get_manifest_ref_count(cls_method_context_t hctx, string fp_oid)
{
PrimaryLogPG::OpContext *ctx = *(PrimaryLogPG::OpContext **)hctx;
- if (!ctx->obc->obs.oi.has_manifest()) {
- return false;
- }
-
- for (auto &p : ctx->obc->obs.oi.manifest.chunk_map) {
- if (p.second.oid.oid.name == fp_oid) {
- return true;
- }
- }
-
- return false;
+ return ctx->pg->get_manifest_ref_count(ctx->obc, fp_oid);
}
uint64_t cls_get_osd_min_alloc_size(cls_method_context_t hctx) {
return ctx->pg->get_min_alloc_size();
}
+
+uint64_t cls_get_pool_stripe_width(cls_method_context_t hctx)
+{
+ PrimaryLogPG::OpContext *ctx = *(PrimaryLogPG::OpContext **)hctx;
+
+ return ctx->pg->get_pool().stripe_width;
+}