]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
objclass: add cls_cxx_stat2()
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 3 Mar 2016 06:28:33 +0000 (22:28 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 4 Mar 2016 23:22:23 +0000 (15:22 -0800)
allows retrieving high definition mtime

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/objclass/class_api.cc
src/objclass/objclass.h

index a3c065cc726ce6ac370318fae0ab0ff41887724f..1dd05c2086933b8d7f09abb368d8de67a56a8388 100644 (file)
@@ -242,6 +242,31 @@ int cls_cxx_stat(cls_method_context_t hctx, uint64_t *size, time_t *mtime)
   return 0;
 }
 
+int cls_cxx_stat2(cls_method_context_t hctx, uint64_t *size, ceph::real_time *mtime)
+{
+  ReplicatedPG::OpContext **pctx = (ReplicatedPG::OpContext **)hctx;
+  vector<OSDOp> ops(1);
+  int ret;
+  ops[0].op.op = CEPH_OSD_OP_STAT;
+  ret = (*pctx)->pg->do_osd_ops(*pctx, ops);
+  if (ret < 0)
+    return ret;
+  bufferlist::iterator iter = ops[0].outdata.begin();
+  real_time ut;
+  uint64_t s;
+  try {
+    ::decode(s, iter);
+    ::decode(ut, iter);
+  } catch (buffer::error& err) {
+    return -EIO;
+  }
+  if (size)
+    *size = s;
+  if (mtime)
+    *mtime = ut;
+  return 0;
+}
+
 int cls_cxx_read(cls_method_context_t hctx, int ofs, int len, bufferlist *outbl)
 {
   ReplicatedPG::OpContext **pctx = (ReplicatedPG::OpContext **)hctx;
index 0b4e538fe5fcdbfd881679c4f8820923fbd2e87a..08a9d2382022a9d79370eb2dae4c7eef3539140e 100644 (file)
@@ -9,6 +9,7 @@
 #include "../include/types.h"
 #include "msg/msg_types.h"
 #include "common/hobject.h"
+#include "common/ceph_time.h"
 
 extern "C" {
 #endif
@@ -142,6 +143,7 @@ extern int cls_register_cxx_filter(cls_handle_t hclass,
 extern int cls_cxx_create(cls_method_context_t hctx, bool exclusive);
 extern int cls_cxx_remove(cls_method_context_t hctx);
 extern int cls_cxx_stat(cls_method_context_t hctx, uint64_t *size, time_t *mtime);
+extern int cls_cxx_stat2(cls_method_context_t hctx, uint64_t *size, ceph::real_time *mtime);
 extern int cls_cxx_read(cls_method_context_t hctx, int ofs, int len, bufferlist *bl);
 extern int cls_cxx_write(cls_method_context_t hctx, int ofs, int len, bufferlist *bl);
 extern int cls_cxx_write_full(cls_method_context_t hctx, bufferlist *bl);