]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: can set mtime for operate (mutate)
authorYehuda Sadeh <yehuda@hq.newdream.net>
Sat, 6 Aug 2011 00:22:06 +0000 (17:22 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Sat, 6 Aug 2011 00:22:06 +0000 (17:22 -0700)
src/include/rados/librados.hpp
src/librados.cc

index 16545e155e030aa45b409c6567c0fa7308508bc7..5d769e302e49eb9c441b135540d1a08f11504135 100644 (file)
@@ -136,10 +136,16 @@ namespace librados
    */
   class ObjectWriteOperation : public ObjectOperation
   {
+  protected:
+    time_t *pmtime;
   public:
-    ObjectWriteOperation() {}
+    ObjectWriteOperation() : pmtime(NULL) {}
     ~ObjectWriteOperation() {}
 
+    void mtime(time_t *pt) {
+      pmtime = pt;
+    }
+
     void create(bool exclusive);
     void write(uint64_t off, const bufferlist& bl);
     void write_full(const bufferlist& bl);
@@ -153,6 +159,8 @@ namespace librados
     void clone_range(uint64_t dst_off,
                      const std::string& src_oid, uint64_t src_off,
                      size_t len);
+
+    friend class IoCtx;
   };
 
   /*
index c4d43cc0cb7edcc49a00e44cb2e1babb7245f0d1..6dbe2a5a4a0b23261fd016ea634697316e0bb658 100644 (file)
@@ -598,7 +598,7 @@ public:
 
   int list(Objecter::ListContext *context, int max_entries);
 
-  int operate(IoCtxImpl& io, const object_t& oid, ::ObjectOperation *o, bufferlist *pbl);
+  int operate(IoCtxImpl& io, const object_t& oid, ::ObjectOperation *o, time_t *pmtime, bufferlist *pbl);
   int operate_read(IoCtxImpl& io, const object_t& oid, ::ObjectOperation *o, bufferlist *pbl);
   int aio_operate(IoCtxImpl& io, const object_t& oid, ::ObjectOperation *o, AioCompletionImpl *c, bufferlist *pbl);
 
@@ -1657,14 +1657,22 @@ clone_range(IoCtxImpl& io, const object_t& dst_oid, uint64_t dst_offset, const o
 }
 
 int librados::RadosClient::
-operate(IoCtxImpl& io, const object_t& oid, ::ObjectOperation *o, bufferlist *pbl)
+operate(IoCtxImpl& io, const object_t& oid, ::ObjectOperation *o, time_t *pmtime, bufferlist *pbl)
 {
-  utime_t ut = ceph_clock_now(cct);
+  utime_t ut;
+  if (pmtime) {
+    ut = utime_t(*pmtime, 0);
+  } else {
+    ut = ceph_clock_now(cct);
+  }
 
   /* can't write to a snapshot */
   if (io.snap_seq != CEPH_NOSNAP)
     return -EINVAL;
 
+  if (!o->size())
+    return 0;
+
   Mutex mylock("RadosClient::mutate::mylock");
   Cond cond;
   bool done;
@@ -1698,6 +1706,9 @@ operate_read(IoCtxImpl& io, const object_t& oid, ::ObjectOperation *o, bufferlis
   if (io.snap_seq != CEPH_NOSNAP)
     return -EINVAL;
 
+  if (!o->size())
+    return 0;
+
   Mutex mylock("RadosClient::mutate::mylock");
   Cond cond;
   bool done;
@@ -2824,7 +2835,7 @@ tmap_update(const std::string& oid, bufferlist& cmdbl)
 int librados::IoCtx::operate(const std::string& oid, librados::ObjectWriteOperation *o, bufferlist *pbl)
 {
   object_t obj(oid);
-  return io_ctx_impl->client->operate(*io_ctx_impl, obj, (::ObjectOperation*)o->impl, pbl);
+  return io_ctx_impl->client->operate(*io_ctx_impl, obj, (::ObjectOperation*)o->impl, o->pmtime, pbl);
 }
 
 int librados::IoCtx::operate(const std::string& oid, librados::ObjectReadOperation *o, bufferlist *pbl)