]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/memstore: implement handle-based read methods
authorSage Weil <sage@redhat.com>
Mon, 18 Jan 2016 16:05:51 +0000 (11:05 -0500)
committerSage Weil <sage@redhat.com>
Wed, 27 Jan 2016 19:34:51 +0000 (14:34 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/memstore/MemStore.cc
src/os/memstore/MemStore.h

index bf56cf3eab6a5723d82b42da7f9c576dc1464117..1b187081aaba8fc88785f9822b5cc8da6fbb209d 100644 (file)
@@ -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<Collection*>(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<Collection*>(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<Collection*>(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<Collection*>(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<string,bufferptr>& 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<string,bufferptr>& aset)
+{
+  Collection *c = static_cast<Collection*>(c_.get());
+  dout(10) << __func__ << " " << c->cid << " " << oid << dendl;
+  if (!c->exists)
+    return -ENOENT;
 
   ObjectRef o = c->get_object(oid);
   if (!o)
index 174915f32880bac74d3a7762b054b86960308112..f9aa968cce136b524b6ffaadfbe55bad1e9a3e8e 100644 (file)
@@ -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<string,bufferptr>& 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<string,bufferptr>& aset) override;
+  int getattrs(CollectionHandle &c, const ghobject_t& oid,
+              map<string,bufferptr>& aset) override;
 
   int list_collections(vector<coll_t>& ls);