From: Greg Farnum Date: Tue, 20 Aug 2013 21:21:04 +0000 (-0700) Subject: Objecter: librados: mass switch from eversion_t to version_t X-Git-Tag: v0.69~40^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ff1a573025b13bae3eb464d5278fd6de77ee2750;p=ceph.git Objecter: librados: mass switch from eversion_t to version_t There are a lot of pointers throughout our request infrastructure used solely for exporting the version to users. The interfaces we actually expose only provide a uint64_t (leaving off eversion_t's epoch), and that's all we're going to maintain in our new user_version scheme, so don't pretend we'll have more in our internal interfaces. I audited this pretty carefully; in particular: Op::objver is only used for passing data back to users via the calling functions IoCtxImpl::last_objver, etc IoCtxImpl::last_objver is used only for the set_sync_op_version() call, which provides data only for the uint64_t get_last_version() and rados_get_last_version() calls. AioCompletionImpl::objver is used only for the uint64_t get_version() call. LingerOp::pobjver is used only for referencing things that are now version_t. Signed-off-by: Greg Farnum --- diff --git a/src/librados/AioCompletionImpl.h b/src/librados/AioCompletionImpl.h index cf049e0a9a21..4243bcd2298f 100644 --- a/src/librados/AioCompletionImpl.h +++ b/src/librados/AioCompletionImpl.h @@ -32,7 +32,7 @@ struct librados::AioCompletionImpl { int ref, rval; bool released; bool ack, safe; - eversion_t objver; + version_t objver; rados_callback_t callback_complete, callback_safe; void *callback_arg; @@ -49,6 +49,7 @@ struct librados::AioCompletionImpl { AioCompletionImpl() : lock("AioCompletionImpl lock", false, false), ref(1), rval(0), released(false), ack(false), safe(false), + objver(0), callback_complete(0), callback_safe(0), callback_arg(0), is_read(false), pbl(0), buf(0), maxlen(0), io(NULL), aio_write_seq(0), aio_write_list_item(this) { } @@ -127,9 +128,9 @@ struct librados::AioCompletionImpl { } uint64_t get_version() { lock.Lock(); - eversion_t v = objver; + version_t v = objver; lock.Unlock(); - return v.version; + return v; } void get() { diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index c79005854584..aaa987316a37 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -502,7 +502,7 @@ int librados::IoCtxImpl::operate(const object_t& oid, ::ObjectOperation *o, Cond cond; bool done; int r; - eversion_t ver; + version_t ver; Context *oncommit = new C_SafeCond(&mylock, &cond, &done, &r); @@ -536,7 +536,7 @@ int librados::IoCtxImpl::operate_read(const object_t& oid, Cond cond; bool done; int r; - eversion_t ver; + version_t ver; Context *onack = new C_SafeCond(&mylock, &cond, &done, &r); @@ -609,7 +609,6 @@ int librados::IoCtxImpl::aio_read(const object_t oid, AioCompletionImpl *c, return -EDOM; Context *onack = new C_aio_Ack(c); - eversion_t ver; c->is_read = true; c->io = this; @@ -1002,7 +1001,7 @@ int librados::IoCtxImpl::getxattrs(const object_t& oid, return r; } -void librados::IoCtxImpl::set_sync_op_version(eversion_t& ver) +void librados::IoCtxImpl::set_sync_op_version(version_t ver) { last_objver = ver; } @@ -1016,7 +1015,7 @@ int librados::IoCtxImpl::watch(const object_t& oid, uint64_t ver, bool done; int r; Context *onfinish = new C_SafeCond(&mylock, &cond, &done, &r); - eversion_t objver; + version_t objver; lock->Lock(); @@ -1071,7 +1070,7 @@ int librados::IoCtxImpl::unwatch(const object_t& oid, uint64_t cookie) bool done; int r; Context *oncommit = new C_SafeCond(&mylock, &cond, &done, &r); - eversion_t ver; + version_t ver; lock->Lock(); client->unregister_watcher(cookie); @@ -1102,7 +1101,7 @@ int librados::IoCtxImpl::notify(const object_t& oid, uint64_t ver, bufferlist& b bool done, done_all; int r; Context *onack = new C_SafeCond(&mylock, &cond, &done, &r); - eversion_t objver; + version_t objver; uint64_t cookie; C_NotifyComplete *ctx = new C_NotifyComplete(&mylock_all, &cond_all, &done_all); @@ -1144,7 +1143,7 @@ int librados::IoCtxImpl::notify(const object_t& oid, uint64_t ver, bufferlist& b return r; } -eversion_t librados::IoCtxImpl::last_version() +version_t librados::IoCtxImpl::last_version() { return last_objver; } diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h index 74ca1d09880a..ccecd4e8184d 100644 --- a/src/librados/IoCtxImpl.h +++ b/src/librados/IoCtxImpl.h @@ -37,7 +37,7 @@ struct librados::IoCtxImpl { ::SnapContext snapc; uint64_t assert_ver; map assert_src_version; - eversion_t last_objver; + version_t last_objver; uint32_t notify_timeout; object_locator_t oloc; @@ -183,7 +183,7 @@ struct librados::IoCtxImpl { int pool_change_auid(unsigned long long auid); int pool_change_auid_async(unsigned long long auid, PoolAsyncCompletionImpl *c); - void set_sync_op_version(eversion_t& ver); + void set_sync_op_version(version_t ver); int watch(const object_t& oid, uint64_t ver, uint64_t *cookie, librados::WatchCtx *ctx); int unwatch(const object_t& oid, uint64_t cookie); int notify(const object_t& oid, uint64_t ver, bufferlist& bl); @@ -191,7 +191,7 @@ struct librados::IoCtxImpl { const object_t& oid, uint64_t notify_id, uint64_t ver, uint64_t cookie); - eversion_t last_version(); + version_t last_version(); void set_assert_version(uint64_t ver); void set_assert_src_version(const object_t& oid, uint64_t ver); void set_notify_timeout(uint32_t timeout); diff --git a/src/librados/librados.cc b/src/librados/librados.cc index 0a36092a3d97..f704412559fb 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -1108,8 +1108,7 @@ const librados::ObjectIterator& librados::IoCtx::objects_end() const uint64_t librados::IoCtx::get_last_version() { - eversion_t ver = io_ctx_impl->last_version(); - return ver.version; + return io_ctx_impl->last_version(); } int librados::IoCtx::aio_read(const std::string& oid, librados::AioCompletion *c, @@ -2142,8 +2141,7 @@ extern "C" int rados_read(rados_ioctx_t io, const char *o, char *buf, size_t len extern "C" uint64_t rados_get_last_version(rados_ioctx_t io) { librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; - eversion_t ver = ctx->last_version(); - return ver.version; + return ctx->last_version(); } extern "C" int rados_pool_create(rados_t cluster, const char *name) diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 6ed5a32e54fa..3bab76c9f373 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -357,7 +357,7 @@ tid_t Objecter::linger_mutate(const object_t& oid, const object_locator_t& oloc, const SnapContext& snapc, utime_t mtime, bufferlist& inbl, int flags, Context *onack, Context *oncommit, - eversion_t *objver) + version_t *objver) { LingerOp *info = new LingerOp; info->oid = oid; @@ -388,7 +388,7 @@ tid_t Objecter::linger_read(const object_t& oid, const object_locator_t& oloc, ObjectOperation& op, snapid_t snap, bufferlist& inbl, bufferlist *poutbl, int flags, Context *onfinish, - eversion_t *objver) + version_t *objver) { LingerOp *info = new LingerOp; info->oid = oid; diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 68830762e1ed..7041ab984f72 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -773,7 +773,7 @@ public: bool paused; - eversion_t *objver; + version_t *objver; epoch_t *reply_epoch; utime_t stamp; @@ -787,7 +787,7 @@ public: bool should_resend; Op(const object_t& o, const object_locator_t& ol, vector& op, - int f, Context *ac, Context *co, eversion_t *ov) : + int f, Context *ac, Context *co, version_t *ov) : session(NULL), session_item(this), incarnation(0), oid(o), oloc(ol), used_replica(false), con(NULL), @@ -1005,7 +1005,7 @@ public: vector ops; bufferlist inbl; bufferlist *poutbl; - eversion_t *pobjver; + version_t *pobjver; bool registered; Context *on_reg_ack, *on_reg_commit; @@ -1283,7 +1283,7 @@ private: tid_t mutate(const object_t& oid, const object_locator_t& oloc, ObjectOperation& op, const SnapContext& snapc, utime_t mtime, int flags, - Context *onack, Context *oncommit, eversion_t *objver = NULL) { + Context *onack, Context *oncommit, version_t *objver = NULL) { Op *o = new Op(oid, oloc, op.ops, flags | global_op_flags | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver); o->priority = op.priority; o->mtime = mtime; @@ -1293,7 +1293,7 @@ private: tid_t read(const object_t& oid, const object_locator_t& oloc, ObjectOperation& op, snapid_t snapid, bufferlist *pbl, int flags, - Context *onack, eversion_t *objver = NULL) { + Context *onack, version_t *objver = NULL) { Op *o = new Op(oid, oloc, op.ops, flags | global_op_flags | CEPH_OSD_FLAG_READ, onack, NULL, objver); o->priority = op.priority; o->snapid = snapid; @@ -1308,12 +1308,12 @@ private: const SnapContext& snapc, utime_t mtime, bufferlist& inbl, int flags, Context *onack, Context *onfinish, - eversion_t *objver); + version_t *objver); tid_t linger_read(const object_t& oid, const object_locator_t& oloc, ObjectOperation& op, snapid_t snap, bufferlist& inbl, bufferlist *poutbl, int flags, Context *onack, - eversion_t *objver); + version_t *objver); void unregister_linger(uint64_t linger_id); /** @@ -1347,7 +1347,7 @@ private: tid_t stat(const object_t& oid, const object_locator_t& oloc, snapid_t snap, uint64_t *psize, utime_t *pmtime, int flags, Context *onfinish, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_STAT; @@ -1361,7 +1361,7 @@ private: tid_t read(const object_t& oid, const object_locator_t& oloc, uint64_t off, uint64_t len, snapid_t snap, bufferlist *pbl, int flags, Context *onfinish, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_READ; @@ -1379,7 +1379,7 @@ private: uint64_t off, uint64_t len, snapid_t snap, bufferlist *pbl, int flags, uint64_t trunc_size, __u32 trunc_seq, Context *onfinish, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_READ; @@ -1395,7 +1395,7 @@ private: tid_t mapext(const object_t& oid, const object_locator_t& oloc, uint64_t off, uint64_t len, snapid_t snap, bufferlist *pbl, int flags, Context *onfinish, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_MAPEXT; @@ -1411,7 +1411,7 @@ private: tid_t getxattr(const object_t& oid, const object_locator_t& oloc, const char *name, snapid_t snap, bufferlist *pbl, int flags, Context *onfinish, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_GETXATTR; @@ -1428,7 +1428,7 @@ private: tid_t getxattrs(const object_t& oid, const object_locator_t& oloc, snapid_t snap, map& attrset, int flags, Context *onfinish, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_GETXATTRS; @@ -1442,7 +1442,7 @@ private: tid_t read_full(const object_t& oid, const object_locator_t& oloc, snapid_t snap, bufferlist *pbl, int flags, Context *onfinish, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { return read(oid, oloc, 0, 0, snap, pbl, flags | global_op_flags | CEPH_OSD_FLAG_READ, onfinish, objver); } @@ -1451,7 +1451,7 @@ private: vector& ops, utime_t mtime, const SnapContext& snapc, int flags, Context *onack, Context *oncommit, - eversion_t *objver = NULL) { + version_t *objver = NULL) { Op *o = new Op(oid, oloc, ops, flags | global_op_flags | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver); o->mtime = mtime; o->snapc = snapc; @@ -1461,7 +1461,7 @@ private: uint64_t off, uint64_t len, const SnapContext& snapc, const bufferlist &bl, utime_t mtime, int flags, Context *onack, Context *oncommit, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_WRITE; @@ -1479,7 +1479,7 @@ private: uint64_t len, const SnapContext& snapc, const bufferlist &bl, utime_t mtime, int flags, Context *onack, Context *oncommit, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_APPEND; @@ -1498,7 +1498,7 @@ private: utime_t mtime, int flags, uint64_t trunc_size, __u32 trunc_seq, Context *onack, Context *oncommit, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_WRITE; @@ -1515,7 +1515,7 @@ private: tid_t write_full(const object_t& oid, const object_locator_t& oloc, const SnapContext& snapc, const bufferlist &bl, utime_t mtime, int flags, Context *onack, Context *oncommit, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_WRITEFULL; @@ -1532,7 +1532,7 @@ private: utime_t mtime, int flags, uint64_t trunc_size, __u32 trunc_seq, Context *onack, Context *oncommit, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_TRUNCATE; @@ -1547,7 +1547,7 @@ private: tid_t zero(const object_t& oid, const object_locator_t& oloc, uint64_t off, uint64_t len, const SnapContext& snapc, utime_t mtime, int flags, Context *onack, Context *oncommit, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_ZERO; @@ -1561,7 +1561,7 @@ private: tid_t rollback_object(const object_t& oid, const object_locator_t& oloc, const SnapContext& snapc, snapid_t snapid, utime_t mtime, Context *onack, Context *oncommit, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_ROLLBACK; @@ -1575,7 +1575,7 @@ private: const SnapContext& snapc, utime_t mtime, int global_flags, int create_flags, Context *onack, Context *oncommit, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_CREATE; @@ -1588,7 +1588,7 @@ private: tid_t remove(const object_t& oid, const object_locator_t& oloc, const SnapContext& snapc, utime_t mtime, int flags, Context *onack, Context *oncommit, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_DELETE; @@ -1599,7 +1599,7 @@ private: } tid_t lock(const object_t& oid, const object_locator_t& oloc, int op, int flags, - Context *onack, Context *oncommit, eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + Context *onack, Context *oncommit, version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { SnapContext snapc; // no snapc for lock ops vector ops; int i = init_ops(ops, 1, extra_ops); @@ -1612,7 +1612,7 @@ private: const char *name, const SnapContext& snapc, const bufferlist &bl, utime_t mtime, int flags, Context *onack, Context *oncommit, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_SETXATTR; @@ -1630,7 +1630,7 @@ private: const char *name, const SnapContext& snapc, utime_t mtime, int flags, Context *onack, Context *oncommit, - eversion_t *objver = NULL, ObjectOperation *extra_ops = NULL) { + version_t *objver = NULL, ObjectOperation *extra_ops = NULL) { vector ops; int i = init_ops(ops, 1, extra_ops); ops[i].op.op = CEPH_OSD_OP_RMXATTR;