diff options
author | Yehuda Sadeh <yehuda@redhat.com> | 2016-03-04 21:05:34 +0100 |
---|---|---|
committer | Yehuda Sadeh <yehuda@redhat.com> | 2016-03-04 21:05:34 +0100 |
commit | 4ad230a388d07102f72e04d922bc87b2dbc84150 (patch) | |
tree | 8fb5f877676dcfee5c5e7873178899d8c50c74c8 /src/librados | |
parent | librados: add stat2() calls that return high resultion mtime (diff) | |
download | ceph-4ad230a388d07102f72e04d922bc87b2dbc84150.tar.xz ceph-4ad230a388d07102f72e04d922bc87b2dbc84150.zip |
librados: new stat2() that returns ceph::real_time
Hiding ceph_real_time behind ceph_real_time_t
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Diffstat (limited to 'src/librados')
-rw-r--r-- | src/librados/IoCtxImpl.cc | 32 | ||||
-rw-r--r-- | src/librados/IoCtxImpl.h | 2 | ||||
-rw-r--r-- | src/librados/librados.cc | 11 |
3 files changed, 45 insertions, 0 deletions
diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index 2fca0863800..c8e7221e370 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -926,6 +926,19 @@ int librados::IoCtxImpl::aio_stat2(const object_t& oid, AioCompletionImpl *c, return 0; } +int librados::IoCtxImpl::aio_stat2(const object_t& oid, AioCompletionImpl *c, + uint64_t *psize, ceph_real_time_t *pmtime) +{ + Context *onack = new C_aio_Ack(c); + + c->io = this; + c->tid = objecter->stat(oid, oloc, + snap_seq, psize, (ceph::real_time *)pmtime, 0, + onack, &c->objver); + + return 0; +} + int librados::IoCtxImpl::aio_cancel(AioCompletionImpl *c) { return objecter->op_cancel(c->tid, -ECANCELED); @@ -1196,6 +1209,25 @@ int librados::IoCtxImpl::stat2(const object_t& oid, uint64_t *psize, struct time return 0; } +int librados::IoCtxImpl::stat2(const object_t& oid, uint64_t *psize, ceph_real_time_t *pmtime) +{ + uint64_t size; + ceph::real_time mtime; + + if (!psize) + psize = &size; + + ::ObjectOperation rd; + prepare_assert_ops(&rd); + rd.stat(psize, (ceph::real_time *)pmtime, NULL); + int r = operate_read(oid, &rd, NULL); + if (r < 0) { + return r; + } + + return 0; +} + int librados::IoCtxImpl::getxattr(const object_t& oid, const char *name, bufferlist& bl) { diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h index 3e45f16e123..b795202d4c1 100644 --- a/src/librados/IoCtxImpl.h +++ b/src/librados/IoCtxImpl.h @@ -138,6 +138,7 @@ struct librados::IoCtxImpl { int remove(const object_t& oid, int flags); int stat(const object_t& oid, uint64_t *psize, time_t *pmtime); int stat2(const object_t& oid, uint64_t *psize, struct timespec *pts); + int stat2(const object_t& oid, uint64_t *psize, ceph_real_time_t *pmtime); int trunc(const object_t& oid, uint64_t size); int tmap_update(const object_t& oid, bufferlist& cmdbl); @@ -206,6 +207,7 @@ struct librados::IoCtxImpl { const char *method, bufferlist& inbl, bufferlist *outbl); int aio_stat(const object_t& oid, AioCompletionImpl *c, uint64_t *psize, time_t *pmtime); int aio_stat2(const object_t& oid, AioCompletionImpl *c, uint64_t *psize, struct timespec *pts); + int aio_stat2(const object_t& oid, AioCompletionImpl *c, uint64_t *psize, ceph_real_time_t *pmtime); int aio_cancel(AioCompletionImpl *c); int pool_change_auid(unsigned long long auid); diff --git a/src/librados/librados.cc b/src/librados/librados.cc index d62a0415242..b3b70309f50 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -220,6 +220,11 @@ void librados::ObjectReadOperation::stat2(uint64_t *psize, struct timespec *pts, ::ObjectOperation *o = (::ObjectOperation *)impl; o->stat(psize, pts, prval); } +void librados::ObjectReadOperation::stat2(uint64_t *psize, ceph_real_time_t *pmtime, int *prval) +{ + ::ObjectOperation *o = (::ObjectOperation *)impl; + o->stat(psize, (ceph::real_time *)pmtime, prval); +} void librados::ObjectReadOperation::read(size_t off, uint64_t len, bufferlist *pbl, int *prval) { @@ -1239,6 +1244,12 @@ int librados::IoCtx::stat2(const std::string& oid, uint64_t *psize, struct times return io_ctx_impl->stat2(obj, psize, pts); } +int librados::IoCtx::stat2(const std::string& oid, uint64_t *psize, ceph_real_time_t *pmtime) +{ + object_t obj(oid); + return io_ctx_impl->stat2(obj, psize, pmtime); +} + int librados::IoCtx::exec(const std::string& oid, const char *cls, const char *method, bufferlist& inbl, bufferlist& outbl) { |