]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: implement cls_cxx_stat().
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 2 Aug 2019 11:46:20 +0000 (13:46 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Sat, 24 Aug 2019 01:33:57 +0000 (03:33 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/objclass.cc
src/crimson/osd/pg_backend.cc
src/include/rados/objclass.h

index 024c0999b06880b5b40e6fe0655cc8ec51bca8f3..e8a716010302e2e5e558b4a60d1ffde9e47bb8d4 100644 (file)
@@ -7,6 +7,9 @@
 #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"
 
@@ -63,6 +66,31 @@ int cls_cxx_remove(cls_method_context_t hctx)
 
 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;
 }
 
index e539544bed35be1e87ec73d445d5dc13d1af3db4..4a6bbc07334a41c88d3afb04ab5ccb16e7bdbda6 100644 (file)
@@ -257,7 +257,7 @@ seastar::future<> PGBackend::stat(
     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++;
@@ -451,9 +451,9 @@ seastar::future<> PGBackend::call(
 #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);
     }
index 80ae69d2511cf584a4082e7811a3d8dd93b4210e..16224b6a41029a4ef2b2cab3c1c7b51e5a97bee9 100644 (file)
@@ -57,7 +57,14 @@ typedef void *cls_method_handle_t;
  *
  * 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, ...)