summaryrefslogtreecommitdiffstats
path: root/src/objclass
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@redhat.com>2016-03-03 07:28:33 +0100
committerYehuda Sadeh <yehuda@redhat.com>2016-03-05 00:22:23 +0100
commit44600cb3ef88596fcf2fd5ffbeff91d6c0148c3a (patch)
tree6df134e060560c85d5958f86ae9aca2851c13a51 /src/objclass
parenttest: add a test for stat2(), mtime2() (diff)
downloadceph-44600cb3ef88596fcf2fd5ffbeff91d6c0148c3a.tar.xz
ceph-44600cb3ef88596fcf2fd5ffbeff91d6c0148c3a.zip
objclass: add cls_cxx_stat2()
allows retrieving high definition mtime Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Diffstat (limited to 'src/objclass')
-rw-r--r--src/objclass/class_api.cc25
-rw-r--r--src/objclass/objclass.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/src/objclass/class_api.cc b/src/objclass/class_api.cc
index a3c065cc726..1dd05c20869 100644
--- a/src/objclass/class_api.cc
+++ b/src/objclass/class_api.cc
@@ -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;
diff --git a/src/objclass/objclass.h b/src/objclass/objclass.h
index 0b4e538fe5f..08a9d238202 100644
--- a/src/objclass/objclass.h
+++ b/src/objclass/objclass.h
@@ -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);