From: Josh Durgin Date: Sun, 12 May 2013 21:45:36 +0000 (-0700) Subject: librados: add per-ObjectOperation flags for balanced and localized reads X-Git-Tag: v0.63~38^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4ddaea70b2d10d4544bd05a59400b2c2fc275179;p=ceph.git librados: add per-ObjectOperation flags for balanced and localized reads 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 --- diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp index 0f09f3f13933..af14a183b493 100644 --- a/src/include/rados/librados.hpp +++ b/src/include/rados/librados.hpp @@ -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& 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 diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index d64eeea2dca8..abeda88d018e 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -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; } diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h index 538c2f1d357a..7e589a82f505 100644 --- a/src/librados/IoCtxImpl.h +++ b/src/librados/IoCtxImpl.h @@ -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; diff --git a/src/librados/librados.cc b/src/librados/librados.cc index 3700a4d1be0e..5e8b38f0b001 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -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)