]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: add per-ObjectOperation flags for balanced and localized reads
authorJosh Durgin <josh.durgin@inktank.com>
Sun, 12 May 2013 21:45:36 +0000 (14:45 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Mon, 13 May 2013 02:31:22 +0000 (19:31 -0700)
These need to apply to the entire ObjectOperation, not just a subop,
so use a new enum and a new aio_operate() call that takes them.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/include/rados/librados.hpp
src/librados/IoCtxImpl.cc
src/librados/IoCtxImpl.h
src/librados/librados.cc

index 0f09f3f13933c0179b63645e424446044c74bb34..af14a183b493b47e120aef567a0627d824f93c2e 100644 (file)
@@ -105,11 +105,28 @@ namespace librados
     PoolAsyncCompletionImpl *pc;
   };
 
+  /**
+   * These are per-op flags which may be different among
+   * ops added to an ObjectOperation.
+   */
   enum ObjectOperationFlags {
     OP_EXCL =   1,
     OP_FAILOK = 2,
   };
 
+  /**
+   * These flags apply to the ObjectOperation as a whole.
+   *
+   * BALANCE_READS and LOCALIZE_READS should only be used
+   * when reading from data you're certain won't change,
+   * like a snapshot, or where eventual consistency is ok.
+   */
+  enum ObjectOperationGlobalFlags {
+    OPERATION_NOFLAG         = 0,
+    OPERATION_BALANCE_READS  = 1,
+    OPERATION_LOCALIZE_READS = 2,
+  };
+
   /*
    * ObjectOperation : compound object operation
    * Batch multiple object operations into a single request, to be applied
@@ -586,7 +603,10 @@ namespace librados
     int aio_operate(const std::string& oid, AioCompletion *c,
                    ObjectWriteOperation *op, snap_t seq,
                    std::vector<snap_t>& snaps);
-    int aio_operate(const std::string& oid, AioCompletion *c, ObjectReadOperation *op,
+    int aio_operate(const std::string& oid, AioCompletion *c,
+                   ObjectReadOperation *op, bufferlist *pbl);
+    int aio_operate(const std::string& oid, AioCompletion *c,
+                   ObjectReadOperation *op, snap_t snapid, int flags,
                    bufferlist *pbl);
 
     // watch/notify
index d64eeea2dca8f33034daf9399960e3abdc56ac73..abeda88d018ec5f1470507e38dc89a08e93a0472 100644 (file)
@@ -695,7 +695,9 @@ int librados::IoCtxImpl::operate_read(const object_t& oid,
 
 int librados::IoCtxImpl::aio_operate_read(const object_t &oid,
                                          ::ObjectOperation *o,
-                                         AioCompletionImpl *c, bufferlist *pbl)
+                                         AioCompletionImpl *c,
+                                         int flags,
+                                         bufferlist *pbl)
 {
   Context *onack = new C_aio_Ack(c);
 
@@ -705,7 +707,7 @@ int librados::IoCtxImpl::aio_operate_read(const object_t &oid,
 
   Mutex::Locker l(*lock);
   objecter->read(oid, oloc,
-                *o, snap_seq, pbl, 0,
+                *o, snap_seq, pbl, flags,
                 onack, &c->objver);
   return 0;
 }
index 538c2f1d357ad1bd8f1819000dcd1614871adb81..7e589a82f505ba6e4cac70921266bb64ee3b5f1d 100644 (file)
@@ -140,7 +140,8 @@ struct librados::IoCtxImpl {
   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);
-  int aio_operate_read(const object_t& oid, ::ObjectOperation *o, AioCompletionImpl *c, bufferlist *pbl);
+  int aio_operate_read(const object_t& oid, ::ObjectOperation *o,
+                      AioCompletionImpl *c, int flags, bufferlist *pbl);
 
   struct C_aio_Ack : public Context {
     librados::AioCompletionImpl *c;
index 3700a4d1be0ec35b5aea964ddc5fa9b5be4f51fb..5e8b38f0b001285036bab347f12c0a39beb09223 100644 (file)
@@ -891,10 +891,28 @@ int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c,
                                  snapc);
 }
 
-int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c, librados::ObjectReadOperation *o, bufferlist *pbl)
+int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c,
+                                librados::ObjectReadOperation *o,
+                                bufferlist *pbl)
+{
+  object_t obj(oid);
+  return io_ctx_impl->aio_operate_read(obj, (::ObjectOperation*)o->impl, c->pc,
+                                      0, pbl);
+}
+
+int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c,
+                                librados::ObjectReadOperation *o, 
+                                snap_t snapid, int flags, bufferlist *pbl)
 {
   object_t obj(oid);
-  return io_ctx_impl->aio_operate_read(obj, (::ObjectOperation*)o->impl, c->pc, pbl);
+  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;
+
+  return io_ctx_impl->aio_operate_read(obj, (::ObjectOperation*)o->impl, c->pc,
+                                      op_flags, pbl);
 }
 
 void librados::IoCtx::snap_set_read(snap_t seq)