From: Sage Weil Date: Mon, 18 Jan 2016 16:05:51 +0000 (-0500) Subject: os/memstore: implement handle-based read methods X-Git-Tag: v10.0.4~153^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8e172a987516c28cab695690db41c48ae90fba0d;p=ceph.git os/memstore: implement handle-based read methods Signed-off-by: Sage Weil --- diff --git a/src/os/memstore/MemStore.cc b/src/os/memstore/MemStore.cc index bf56cf3eab6a..1b187081aaba 100644 --- a/src/os/memstore/MemStore.cc +++ b/src/os/memstore/MemStore.cc @@ -255,10 +255,18 @@ MemStore::CollectionRef MemStore::get_collection(coll_t cid) bool MemStore::exists(coll_t cid, const ghobject_t& oid) { - dout(10) << __func__ << " " << cid << " " << oid << dendl; - CollectionRef c = get_collection(cid); + CollectionHandle c = get_collection(cid); if (!c) return false; + return exists(c, oid); +} + +bool MemStore::exists(CollectionHandle &c_, const ghobject_t& oid) +{ + Collection *c = static_cast(c_.get()); + dout(10) << __func__ << " " << c->get_cid() << " " << oid << dendl; + if (!c->exists) + return false; // Perform equivalent of c->get_object_(oid) != NULL. In C++11 the // shared_ptr needs to be compared to nullptr. @@ -271,11 +279,22 @@ int MemStore::stat( struct stat *st, bool allow_eio) { - dout(10) << __func__ << " " << cid << " " << oid << dendl; - CollectionRef c = get_collection(cid); + CollectionHandle c = get_collection(cid); if (!c) return -ENOENT; + return stat(c, oid, st, allow_eio); +} +int MemStore::stat( + CollectionHandle &c_, + const ghobject_t& oid, + struct stat *st, + bool allow_eio) +{ + Collection *c = static_cast(c_.get()); + dout(10) << __func__ << " " << c->cid << " " << oid << dendl; + if (!c->exists) + return -ENOENT; ObjectRef o = c->get_object(oid); if (!o) return -ENOENT; @@ -295,12 +314,26 @@ int MemStore::read( uint32_t op_flags, bool allow_eio) { - dout(10) << __func__ << " " << cid << " " << oid << " " - << offset << "~" << len << dendl; - CollectionRef c = get_collection(cid); + CollectionHandle c = get_collection(cid); if (!c) return -ENOENT; + return read(c, oid, offset, len, bl, op_flags, allow_eio); +} +int MemStore::read( + CollectionHandle &c_, + const ghobject_t& oid, + uint64_t offset, + size_t len, + bufferlist& bl, + uint32_t op_flags, + bool allow_eio) +{ + Collection *c = static_cast(c_.get()); + dout(10) << __func__ << " " << c->cid << " " << oid << " " + << offset << "~" << len << dendl; + if (!c->exists) + return -ENOENT; ObjectRef o = c->get_object(oid); if (!o) return -ENOENT; @@ -344,11 +377,19 @@ int MemStore::fiemap(coll_t cid, const ghobject_t& oid, int MemStore::getattr(coll_t cid, const ghobject_t& oid, const char *name, bufferptr& value) { - dout(10) << __func__ << " " << cid << " " << oid << " " << name << dendl; - CollectionRef c = get_collection(cid); + CollectionHandle c = get_collection(cid); if (!c) return -ENOENT; + return getattr(c, oid, name, value); +} +int MemStore::getattr(CollectionHandle &c_, const ghobject_t& oid, + const char *name, bufferptr& value) +{ + Collection *c = static_cast(c_.get()); + dout(10) << __func__ << " " << c->cid << " " << oid << " " << name << dendl; + if (!c->exists) + return -ENOENT; ObjectRef o = c->get_object(oid); if (!o) return -ENOENT; @@ -364,10 +405,19 @@ int MemStore::getattr(coll_t cid, const ghobject_t& oid, int MemStore::getattrs(coll_t cid, const ghobject_t& oid, map& aset) { - dout(10) << __func__ << " " << cid << " " << oid << dendl; - CollectionRef c = get_collection(cid); + CollectionHandle c = get_collection(cid); if (!c) return -ENOENT; + return getattrs(c, oid, aset); +} + +int MemStore::getattrs(CollectionHandle &c_, const ghobject_t& oid, + map& aset) +{ + Collection *c = static_cast(c_.get()); + dout(10) << __func__ << " " << c->cid << " " << oid << dendl; + if (!c->exists) + return -ENOENT; ObjectRef o = c->get_object(oid); if (!o) diff --git a/src/os/memstore/MemStore.h b/src/os/memstore/MemStore.h index 174915f32880..f9aa968cce13 100644 --- a/src/os/memstore/MemStore.h +++ b/src/os/memstore/MemStore.h @@ -383,23 +383,37 @@ public: int statfs(struct statfs *buf); - bool exists(coll_t cid, const ghobject_t& oid); - int stat( + bool exists(coll_t cid, const ghobject_t& oid) override; + bool exists(CollectionHandle &c, const ghobject_t& oid) override; + int stat(coll_t cid, const ghobject_t& oid, + struct stat *st, bool allow_eio = false) override; + int stat(CollectionHandle &c, const ghobject_t& oid, + struct stat *st, bool allow_eio = false) override; + int read( coll_t cid, const ghobject_t& oid, - struct stat *st, - bool allow_eio = false); // struct stat? + uint64_t offset, + size_t len, + bufferlist& bl, + uint32_t op_flags = 0, + bool allow_eio = false) override; int read( - coll_t cid, + CollectionHandle &c, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl, uint32_t op_flags = 0, - bool allow_eio = false); + bool allow_eio = false) override; int fiemap(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl); - int getattr(coll_t cid, const ghobject_t& oid, const char *name, bufferptr& value); - int getattrs(coll_t cid, const ghobject_t& oid, map& aset); + int getattr(coll_t cid, const ghobject_t& oid, const char *name, + bufferptr& value) override; + int getattr(CollectionHandle &c, const ghobject_t& oid, const char *name, + bufferptr& value) override; + int getattrs(coll_t cid, const ghobject_t& oid, + map& aset) override; + int getattrs(CollectionHandle &c, const ghobject_t& oid, + map& aset) override; int list_collections(vector& ls);