#include "common/config.h"
#include "common/debug.h"
+#include "crimson/osd/exceptions.h"
+#include "crimson/osd/pg_backend.h"
+
#include "objclass/objclass.h"
#include "osd/ClassHandler.h"
int cls_cxx_stat(cls_method_context_t hctx, uint64_t *size, time_t *mtime)
{
+ OSDOp op;//{CEPH_OSD_OP_STAT};
+ op.op.op = CEPH_OSD_OP_STAT;
+
+ // we're blocking here which presumes execution in Seastar's thread.
+ try {
+ hctx.backend->stat(*hctx.os, op).get();
+ } catch (ceph::osd::error& e) {
+ return -e.code().value();
+ }
+
+ utime_t ut;
+ uint64_t s;
+ try {
+ auto iter = op.outdata.cbegin();
+ decode(s, iter);
+ decode(ut, iter);
+ } catch (buffer::error& err) {
+ return -EIO;
+ }
+ if (size) {
+ *size = s;
+ }
+ if (mtime) {
+ *mtime = ut.sec();
+ }
return 0;
}
encode(os.oi.mtime, osd_op.outdata);
} else {
logger().debug("stat object does not exist");
- throw ::object_not_found();
+ throw ceph::osd::object_not_found{};
}
return seastar::now();
// TODO: ctx->delta_stats.num_rd++;
#endif
- return seastar::async([&osd_op, method, indata=std::move(indata)]() mutable {
+ return seastar::async([this,&os,&osd_op, method, indata=std::move(indata)]() mutable {
ceph::bufferlist outdata;
- const auto ret = method->exec((cls_method_context_t)&osd_op, indata, outdata);
+ const auto ret = method->exec(cls_method_context_t{this, &os}, indata, outdata);
if (ret < 0) {
throw ceph::osd::make_error(ret);
}
*
* A context for the method of the object class.
*/
+#ifdef WITH_SEASTAR
+typedef struct {
+ class PGBackend *backend = nullptr;
+ class ObjectState *os = nullptr;
+} cls_method_context_t;
+#else
typedef void* cls_method_context_t;
+#endif // WITH_SEASTAR
/*class utils*/
extern int cls_log(int level, const char *format, ...)