]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: add an aio_operate that takes a write and flags
authorSage Weil <sage@inktank.com>
Wed, 23 Oct 2013 02:38:54 +0000 (19:38 -0700)
committerSage Weil <sage@inktank.com>
Sat, 14 Dec 2013 00:35:54 +0000 (16:35 -0800)
Until now you could only pass flags to read operations.

Signed-off-by: Sage Weil <sage@inktank.com>
src/include/rados/librados.hpp
src/librados/IoCtxImpl.cc
src/librados/IoCtxImpl.h
src/librados/librados.cc

index 7e7f069ff2f4ef26f8d7217c35dfdac2a40dcfa5..2a280760bd10fb007a5d7627901aebcaa6e0f010 100644 (file)
@@ -742,6 +742,7 @@ namespace librados
     int operate(const std::string& oid, ObjectWriteOperation *op);
     int operate(const std::string& oid, ObjectReadOperation *op, bufferlist *pbl);
     int aio_operate(const std::string& oid, AioCompletion *c, ObjectWriteOperation *op);
+    int aio_operate(const std::string& oid, AioCompletion *c, ObjectWriteOperation *op, int flags);
     /**
      * Schedule an async write operation with explicit snapshot parameters
      *
index 0da40e939d3f07997f52b28bb76aafbd6867846c..0e1046d6bf5b7979ffe129b1453552816600d995 100644 (file)
@@ -593,7 +593,7 @@ int librados::IoCtxImpl::aio_operate_read(const object_t &oid,
 
 int librados::IoCtxImpl::aio_operate(const object_t& oid,
                                     ::ObjectOperation *o, AioCompletionImpl *c,
-                                    const SnapContext& snap_context)
+                                    const SnapContext& snap_context, int flags)
 {
   utime_t ut = ceph_clock_now(client->cct);
   /* can't write to a snapshot */
@@ -607,7 +607,7 @@ int librados::IoCtxImpl::aio_operate(const object_t& oid,
   queue_aio_write(c);
 
   Mutex::Locker l(*lock);
-  objecter->mutate(oid, oloc, *o, snap_context, ut, 0, onack, oncommit,
+  objecter->mutate(oid, oloc, *o, snap_context, ut, flags, onack, oncommit,
                   &c->objver);
 
   return 0;
index 5939fed564f2df45e70147ed06ba53426f3d2836..2d85f48be24cdefd07fbfd6e6e8cfc8541d69f8d 100644 (file)
@@ -141,7 +141,8 @@ struct librados::IoCtxImpl {
   int operate(const object_t& oid, ::ObjectOperation *o, time_t *pmtime);
   int operate_read(const object_t& oid, ::ObjectOperation *o, bufferlist *pbl);
   int aio_operate(const object_t& oid, ::ObjectOperation *o,
-                 AioCompletionImpl *c, const SnapContext& snap_context);
+                 AioCompletionImpl *c, const SnapContext& snap_context,
+                 int flags);
   int aio_operate_read(const object_t& oid, ::ObjectOperation *o,
                       AioCompletionImpl *c, int flags, bufferlist *pbl);
 
index 44dbb40cc5411b54cab5ad13a4b883d6e9a99633..c3dba67eecad02930517be501451958c73197b6d 100644 (file)
@@ -940,6 +940,22 @@ int librados::IoCtx::omap_rm_keys(const std::string& oid,
   return operate(oid, &op);
 }
 
+
+
+static int translate_flags(int flags)
+{
+  int op_flags = 0;
+  if (flags & librados::OPERATION_BALANCE_READS)
+    op_flags |= CEPH_OSD_FLAG_BALANCE_READS;
+  if (flags & librados::OPERATION_LOCALIZE_READS)
+    op_flags |= CEPH_OSD_FLAG_LOCALIZE_READS;
+  if (flags & librados::OPERATION_ORDER_READS_WRITES)
+    op_flags |= CEPH_OSD_FLAG_RWORDERED;
+  if (flags & librados::OPERATION_IGNORE_OVERLAY)
+    op_flags |= CEPH_OSD_FLAG_IGNORE_OVERLAY;
+  return op_flags;
+}
+
 int librados::IoCtx::operate(const std::string& oid, librados::ObjectWriteOperation *o)
 {
   object_t obj(oid);
@@ -957,7 +973,15 @@ int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c,
 {
   object_t obj(oid);
   return io_ctx_impl->aio_operate(obj, (::ObjectOperation*)o->impl, c->pc,
-                                 io_ctx_impl->snapc);
+                                 io_ctx_impl->snapc, 0);
+}
+int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c,
+                                ObjectWriteOperation *o, int flags)
+{
+  object_t obj(oid);
+  return io_ctx_impl->aio_operate(obj, (::ObjectOperation*)o->impl, c->pc,
+                                 io_ctx_impl->snapc,
+                                 translate_flags(flags));
 }
 
 int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c,
@@ -971,7 +995,7 @@ int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c,
     snv[i] = snaps[i];
   SnapContext snapc(snap_seq, snv);
   return io_ctx_impl->aio_operate(obj, (::ObjectOperation*)o->impl, c->pc,
-                                 snapc);
+                                 snapc, 0);
 }
 
 int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c,
@@ -988,20 +1012,11 @@ int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c,
                                 snap_t snapid, int flags, bufferlist *pbl)
 {
   object_t obj(oid);
-  int op_flags = 0;
-  if (flags & OPERATION_BALANCE_READS)
-    op_flags |= CEPH_OSD_FLAG_BALANCE_READS;
-  if (flags & OPERATION_LOCALIZE_READS)
-    op_flags |= CEPH_OSD_FLAG_LOCALIZE_READS;
-  if (flags & OPERATION_ORDER_READS_WRITES)
-    op_flags |= CEPH_OSD_FLAG_RWORDERED;
-  if (flags & OPERATION_IGNORE_OVERLAY)
-    op_flags |= CEPH_OSD_FLAG_IGNORE_OVERLAY;
-
   return io_ctx_impl->aio_operate_read(obj, (::ObjectOperation*)o->impl, c->pc,
-                                      op_flags, pbl);
+                                      translate_flags(flags), pbl);
 }
 
+
 void librados::IoCtx::snap_set_read(snap_t seq)
 {
   io_ctx_impl->set_snap_read(seq);