From e2df67f7570c68e53775bc55cda12c6253e66d2f Mon Sep 17 00:00:00 2001 From: Evgeniy Firsov Date: Sat, 5 Dec 2015 18:08:00 -0800 Subject: [PATCH] osd: use ceph_map/ceph_list in Transaction object Signed-off-by: Evgeniy Firsov --- src/include/Context.h | 18 ++++++++++++++++++ src/os/ObjectStore.h | 16 ++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/include/Context.h b/src/include/Context.h index 16c7c43e2920d..aac67c4d2e611 100644 --- a/src/include/Context.h +++ b/src/include/Context.h @@ -188,6 +188,9 @@ class C_ContextsBase : public ContextInstanceType { void take(std::list& ls) { contexts.splice(contexts.end(), ls); } + void take(ceph_list& ls) { + contexts.insert(contexts.end(), ls.begin(), ls.end()); + } void complete(int r) { // Neuter any ContextInstanceType custom complete(), because although // I want to look like it, I don't actually want to run its code. @@ -211,8 +214,23 @@ class C_ContextsBase : public ContextInstanceType { return c; } } + + static ContextType *list_to_context(ceph_list &cs) { + if (cs.size() == 0) { + return 0; + } else if (cs.size() == 1) { + ContextType *c = cs.front(); + cs.clear(); + return c; + } else { + C_ContextsBase *c(new C_ContextsBase(0)); + c->take(cs); + return c; + } + } }; + typedef C_ContextsBase C_Contexts; diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index f4c047c6eb44b..341b4b33b6b0e 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -447,8 +447,8 @@ class ObjectStore { bool use_tbl; //use_tbl for encode/decode bufferlist tbl; - map coll_index; - map object_index; + ceph_map coll_index; + ceph_map object_index; __le32 coll_id; __le32 object_id; @@ -458,9 +458,9 @@ class ObjectStore { bufferptr op_ptr; - list on_applied; - list on_commit; - list on_applied_sync; + ceph_list on_applied; + ceph_list on_commit; + ceph_list on_applied_sync; public: @@ -496,9 +496,9 @@ class ObjectStore { for (list::iterator i = t.begin(); i != t.end(); ++i) { - on_applied.splice(on_applied.end(), (*i)->on_applied); - on_commit.splice(on_commit.end(), (*i)->on_commit); - on_applied_sync.splice(on_applied_sync.end(), (*i)->on_applied_sync); + on_applied.insert(on_applied.end(), (*i)->on_applied.begin(), (*i)->on_applied.end()); + on_commit.insert(on_commit.end(), (*i)->on_commit.begin(), (*i)->on_commit.end()); + on_applied_sync.insert(on_applied_sync.end(), (*i)->on_applied_sync.begin(), (*i)->on_applied_sync.end()); } *out_on_applied = C_Contexts::list_to_context(on_applied); *out_on_commit = C_Contexts::list_to_context(on_commit);