From 7d3b2c41d64b6a6bc6957d4fdc81404c0359a7f4 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 16 Jan 2012 10:19:19 -0800 Subject: [PATCH] librados: allow ObjectReadOperation::stat() to get time_t mtime We can't use the internal utime_t type here. Signed-off-by: Sage Weil --- src/include/rados/librados.hpp | 2 +- src/librados.cc | 4 ++-- src/osdc/Objecter.h | 14 ++++++++++++-- src/rgw/rgw_rados.cc | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp index 04f1bc50845df..e27f9fc3f78ff 100644 --- a/src/include/rados/librados.hpp +++ b/src/include/rados/librados.hpp @@ -187,7 +187,7 @@ namespace librados ObjectReadOperation() {} ~ObjectReadOperation() {} - void stat(uint64_t *psize, int *prval); + void stat(uint64_t *psize, time_t *pmtime, int *prval); void getxattr(const char *name, bufferlist *pbl, int *prval); void getxattrs(std::map *pattrs, int *prval); void read(size_t off, uint64_t len, bufferlist *pbl, int *prval); diff --git a/src/librados.cc b/src/librados.cc index 1e48cabc808ef..28c43bf1b4c02 100644 --- a/src/librados.cc +++ b/src/librados.cc @@ -189,10 +189,10 @@ void librados::ObjectOperation::exec(const char *cls, const char *method, buffer o->call(cls, method, inbl); } -void librados::ObjectReadOperation::stat(uint64_t *psize, int *prval) +void librados::ObjectReadOperation::stat(uint64_t *psize, time_t *pmtime, int *prval) { ::ObjectOperation *o = (::ObjectOperation *)impl; - o->stat(psize, NULL, prval); + o->stat(psize, pmtime, prval); } void librados::ObjectReadOperation::read(size_t off, uint64_t len, bufferlist *pbl, int *prval) diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 346a347f6d072..94abea0fe1ac9 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -176,7 +176,8 @@ struct ObjectOperation { bufferlist bl; uint64_t *psize; utime_t *pmtime; - C_ObjectOperation_stat(uint64_t *ps, utime_t *pm) : psize(ps), pmtime(pm) {} + time_t *ptime; + C_ObjectOperation_stat(uint64_t *ps, utime_t *pm, time_t *pt) : psize(ps), pmtime(pm), ptime(pt) {} void finish(int r) { if (r >= 0) { bufferlist::iterator p = bl.begin(); @@ -189,6 +190,8 @@ struct ObjectOperation { *psize = size; if (pmtime) *pmtime = mtime; + if (ptime) + *ptime = mtime.sec(); } catch (buffer::error& e) { r = -EIO; @@ -198,7 +201,14 @@ struct ObjectOperation { }; void stat(uint64_t *psize, utime_t *pmtime, int *prval) { unsigned p = ops.size() - 1; - C_ObjectOperation_stat *h = new C_ObjectOperation_stat(psize, pmtime); + C_ObjectOperation_stat *h = new C_ObjectOperation_stat(psize, pmtime, NULL); + out_bl[p] = &h->bl; + out_handler[p] = h; + out_rval[p] = prval; + } + void stat(uint64_t *psize, time_t *ptime, int *prval) { + unsigned p = ops.size() - 1; + C_ObjectOperation_stat *h = new C_ObjectOperation_stat(psize, NULL, ptime); out_bl[p] = &h->bl; out_handler[p] = h; out_rval[p] = prval; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index d11556a833f05..a9b175fb3c417 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1784,7 +1784,7 @@ int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, ObjectReadOperation op; op.getxattrs(&attrset, NULL); - op.stat(&size, NULL); + op.stat(&size, &mtime, NULL); if (first_chunk) { op.read(0, RGW_MAX_CHUNK_SIZE, first_chunk, NULL); } -- 2.39.5