]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc: pass fadvise op flags to WritebackHandler read requests 3759/head
authorJason Dillaman <dillaman@redhat.com>
Thu, 19 Feb 2015 20:38:32 +0000 (15:38 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 19 Feb 2015 20:50:36 +0000 (15:50 -0500)
librbd was previously attempting to cast the provided Context to
retrieve the fadvise flags.  To eliminate the unsafe cast, now
the fadvise flags are directly passed to the WritebackHandler::read
callback.

Fixes: #10914
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/client/ObjecterWriteback.h
src/librbd/AioCompletion.h
src/librbd/AioRequest.h
src/librbd/LibrbdWriteback.cc
src/librbd/LibrbdWriteback.h
src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h
src/osdc/WritebackHandler.h
src/test/osdc/FakeWriteback.cc
src/test/osdc/FakeWriteback.h

index f6506fa953dd58845c5d2fd1d36808910a905c7c..b9e6f9c3cf1daee3bb6820ca8ef13f755491a193 100644 (file)
@@ -17,7 +17,7 @@ class ObjecterWriteback : public WritebackHandler {
   virtual void read(const object_t& oid, uint64_t object_no,
                    const object_locator_t& oloc, uint64_t off, uint64_t len,
                    snapid_t snapid, bufferlist *pbl, uint64_t trunc_size,
-                   __u32 trunc_seq, Context *onfinish) {
+                   __u32 trunc_seq, int op_flags, Context *onfinish) {
     m_objecter->read_trunc(oid, oloc, off, len, snapid, pbl, 0,
                           trunc_size, trunc_seq,
                           new C_OnFinisher(new C_Lock(m_lock, onfinish),
index 6f6d74357aabb87a481cf99d79008bddddef03ca..41c89f2f0b934e918ed145aa6b734a0850b04488 100644 (file)
@@ -146,9 +146,6 @@ namespace librbd {
     void set_req(AioRead *req) {
       m_req = req;
     }
-    AioRead *get_req() {
-      return m_req;
-    }
   private:
     CephContext *m_cct;
     AioCompletion *m_completion;
index ae8c855038a6b470463639ec9f06bbdbcaff045e..6da04b802fb4d0c3d7d1b8d50a3a0dc81675fe4e 100644 (file)
@@ -77,10 +77,6 @@ namespace librbd {
       return m_read_data;
     }
 
-    int get_op_flags() {
-      return m_op_flags;
-    }
-
     std::map<uint64_t, uint64_t> m_ext_map;
 
     friend class C_AioRead;
index dd8f46b87116f02db15f9d797f1a011b29440cca..4c917d4adb7a376e421ba4643ff31b5224d3b984 100644 (file)
@@ -102,7 +102,7 @@ namespace librbd {
                             const object_locator_t& oloc,
                             uint64_t off, uint64_t len, snapid_t snapid,
                             bufferlist *pbl, uint64_t trunc_size,
-                            __u32 trunc_seq, Context *onfinish)
+                            __u32 trunc_seq, int op_flags, Context *onfinish)
   {
     // on completion, take the mutex and then call onfinish.
     Context *req = new C_Request(m_ictx->cct, onfinish, &m_lock);
@@ -120,10 +120,7 @@ namespace librbd {
       librados::Rados::aio_create_completion(req, context_cb, NULL);
     librados::ObjectReadOperation op;
     op.read(off, len, pbl, NULL);
-    {
-      AioRead *req = (static_cast<C_AioRead *>(onfinish))->get_req();
-      op.set_op_flags2((uint32_t)req->get_op_flags());
-    }
+    op.set_op_flags2(op_flags);
     int flags = m_ictx->get_read_flags(snapid);
     int r = m_ictx->data_ctx.aio_operate(oid.name, rados_completion, &op,
                                         flags, NULL);
index 0212dad9a2cffb8a9c81a3af1a387f14e466a5fa..2c71e8434cb9d25aba1e734a23625f4d6e0aed8f 100644 (file)
@@ -27,7 +27,7 @@ namespace librbd {
     virtual void read(const object_t& oid, uint64_t object_no,
                      const object_locator_t& oloc, uint64_t off, uint64_t len,
                      snapid_t snapid, bufferlist *pbl, uint64_t trunc_size,
-                     __u32 trunc_seq, Context *onfinish);
+                     __u32 trunc_seq, int op_flags, Context *onfinish);
 
     // Determine whether a read to this extent could be affected by a write-triggered copy-on-write
     virtual bool may_copy_on_write(const object_t& oid, uint64_t read_off, uint64_t read_len, snapid_t snapid);
index 70426b6437904474253ed3fc977c648a42c5b17f..75174a68ff290c57fa36e4b587aa7d19787c983b 100644 (file)
@@ -631,7 +631,7 @@ void ObjectCacher::close_object(Object *ob)
 
 
 
-void ObjectCacher::bh_read(BufferHead *bh)
+void ObjectCacher::bh_read(BufferHead *bh, int op_flags)
 {
   assert(lock.is_locked());
   ldout(cct, 7) << "bh_read on " << *bh << " outstanding reads "
@@ -647,7 +647,8 @@ void ObjectCacher::bh_read(BufferHead *bh)
   writeback_handler.read(bh->ob->get_oid(), bh->ob->get_object_number(),
                         bh->ob->get_oloc(), bh->start(), bh->length(),
                         bh->ob->get_snap(), &onfinish->bl,
-                        bh->ob->truncate_size, bh->ob->truncate_seq, onfinish);
+                        bh->ob->truncate_size, bh->ob->truncate_seq,
+                        op_flags, onfinish);
 
   ++reads_outstanding;
 }
@@ -1157,7 +1158,7 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
          bh_remove(o, bh_it->second);
          delete bh_it->second;
        } else {
-         bh_read(bh_it->second);
+         bh_read(bh_it->second, rd->fadvise_flags);
          if (success && onfinish) {
            ldout(cct, 10) << "readx missed, waiting on " << *bh_it->second
                           << " off " << bh_it->first << dendl;
index 880e6eb6b6dcf81e57b58add7b54c5d1b20d14f6..ca23549ceac953227f215678490da4111673f21e 100644 (file)
@@ -453,7 +453,7 @@ class ObjectCacher {
   void bh_remove(Object *ob, BufferHead *bh);
 
   // io
-  void bh_read(BufferHead *bh);
+  void bh_read(BufferHead *bh, int op_flags);
   void bh_write(BufferHead *bh);
 
   void trim();
index caf20959b8a49b271dc7de5eb207a6e5bfae1dfd..466f84e77983bfed4cef8e7d8c12bfd1f0ab2cd0 100644 (file)
@@ -15,7 +15,7 @@ class WritebackHandler {
   virtual void read(const object_t& oid, uint64_t object_no,
                    const object_locator_t& oloc, uint64_t off, uint64_t len,
                    snapid_t snapid, bufferlist *pbl, uint64_t trunc_size,
-                   __u32 trunc_seq, Context *onfinish) = 0;
+                   __u32 trunc_seq, int op_flags, Context *onfinish) = 0;
   /**
    * check if a given extent read result may change due to a write
    *
index d444ff6d0c18ae73212d9de277febf8c400ee82d..69f32991b89ea763476662ca00502bb2617950aa 100644 (file)
@@ -62,7 +62,7 @@ void FakeWriteback::read(const object_t& oid, uint64_t object_no,
                         const object_locator_t& oloc,
                         uint64_t off, uint64_t len, snapid_t snapid,
                         bufferlist *pbl, uint64_t trunc_size,
-                        __u32 trunc_seq, Context *onfinish)
+                        __u32 trunc_seq, int op_flags, Context *onfinish)
 {
   C_Delay *wrapper = new C_Delay(m_cct, onfinish, m_lock, off, pbl, m_delay_ns);
   m_finisher->queue(wrapper, len);
index ef2bb3d1f3b677b34c10fc9bbf9c11b3320f0ead..9b9598ed94800886a728640aff4dc6a2346fd54c 100644 (file)
@@ -20,7 +20,7 @@ public:
   virtual void read(const object_t& oid, uint64_t object_no,
                    const object_locator_t& oloc, uint64_t off, uint64_t len,
                    snapid_t snapid, bufferlist *pbl, uint64_t trunc_size,
-                   __u32 trunc_seq, Context *onfinish);
+                   __u32 trunc_seq, int op_flags, Context *onfinish);
 
   virtual ceph_tid_t write(const object_t& oid, const object_locator_t& oloc,
                           uint64_t off, uint64_t len,