]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/: add sync/async read methods to PGBackend
authorSamuel Just <sam.just@inktank.com>
Fri, 6 Dec 2013 19:44:02 +0000 (11:44 -0800)
committerSamuel Just <sam.just@inktank.com>
Wed, 22 Jan 2014 22:39:16 +0000 (14:39 -0800)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/OSD.cc
src/osd/OSD.h
src/osd/PGBackend.h
src/osd/ReplicatedBackend.cc
src/osd/ReplicatedBackend.h

index dc528d69fd372747c0576abca85ae1875e73c637..73ca64a8a44ca568d4f1b9c920d668e350c2d9fb 100644 (file)
@@ -185,6 +185,7 @@ OSDService::OSDService(OSD *osd) :
   scrub_finalize_wq(osd->scrub_finalize_wq),
   rep_scrub_wq(osd->rep_scrub_wq),
   push_wq("push_wq", cct->_conf->osd_recovery_thread_timeout, &osd->recovery_tp),
+  gen_wq("gen_wq", cct->_conf->osd_recovery_thread_timeout, &osd->recovery_tp),
   class_handler(osd->class_handler),
   publish_lock("OSDService::publish_lock"),
   pre_publish_lock("OSDService::pre_publish_lock"),
index 7d5f10efd76a7f8305463490822cb4e363472ec4..3ba78b1cdae0d5cfe778f99a45159f4283d897c7 100644 (file)
@@ -312,6 +312,7 @@ public:
   ThreadPool::WorkQueue<PG> &scrub_finalize_wq;
   ThreadPool::WorkQueue<MOSDRepScrub> &rep_scrub_wq;
   GenContextWQ push_wq;
+  GenContextWQ gen_wq;
   ClassHandler  *&class_handler;
 
   void dequeue_pg(PG *pg, list<OpRequestRef> *dequeued);
index 66456320926b1f3757940015d5258b7ea1393247..0b750420519a1b07eb8750c8a056cc9dff439e8f 100644 (file)
    virtual int objects_get_attrs(
      const hobject_t &hoid,
      map<string, bufferlist> *out) = 0;
+
+   virtual int objects_read_sync(
+     const hobject_t &hoid,
+     uint64_t off,
+     uint64_t len,
+     bufferlist *bl) = 0;
+
+   virtual void objects_read_async(
+     const hobject_t &hoid,
+     uint64_t off,
+     uint64_t len,
+     bufferlist *bl,
+     Context *on_complete) = 0;
  };
 
 #endif
index 56335f1e817ad9ef2a4ac6d255fa71e7f7dc7e33..6023654162554e93d3b8f49ecb306885c45a4cd1 100644 (file)
@@ -324,6 +324,41 @@ int ReplicatedBackend::objects_get_attrs(
     *out);
 }
 
+int ReplicatedBackend::objects_read_sync(
+  const hobject_t &hoid,
+  uint64_t off,
+  uint64_t len,
+  bufferlist *bl)
+{
+  return osd->store->read(coll, hoid, off, len, *bl);
+}
+
+struct AsyncReadCallback : public GenContext<ThreadPool::TPHandle&> {
+  int r;
+  Context *c;
+  AsyncReadCallback(int r, Context *c) : r(r), c(c) {}
+  void finish(ThreadPool::TPHandle&) {
+    c->complete(r);
+    c = NULL;
+  }
+  ~AsyncReadCallback() {
+    delete c;
+  }
+};
+void ReplicatedBackend::objects_read_async(
+  const hobject_t &hoid,
+  uint64_t off,
+  uint64_t len,
+  bufferlist *bl,
+  Context *on_complete)
+{
+  int r = osd->store->read(coll, hoid, off, len, *bl);
+  osd->gen_wq.queue(
+    get_parent()->bless_gencontext(
+      new AsyncReadCallback(r, on_complete)));
+}
+
+
 class RPGTransaction : public PGBackend::PGTransaction {
   coll_t coll;
   coll_t temp_coll;
index 84eacec10a6914b05376192edca21bc6bea8e700..e967d7dbcbd500fc8438e6afc422be809209ae1a 100644 (file)
@@ -176,6 +176,19 @@ public:
     const hobject_t &hoid,
     map<string, bufferlist> *out);
 
+  int objects_read_sync(
+    const hobject_t &hoid,
+    uint64_t off,
+    uint64_t len,
+    bufferlist *bl);
+
+  void objects_read_async(
+    const hobject_t &hoid,
+    uint64_t off,
+    uint64_t len,
+    bufferlist *bl,
+    Context *on_complete);
+
 private:
   // push
   struct PushInfo {