]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Fixed part of the seg fault described in bug 9356 by adding reference counting on...
authorSebastien Ponce <sebastien.ponce@cern.ch>
Mon, 8 Sep 2014 12:23:03 +0000 (14:23 +0200)
committerSebastien Ponce <sebastien.ponce@cern.ch>
Mon, 20 Oct 2014 16:46:31 +0000 (18:46 +0200)
Signed-off-by: Sebastien Ponce <sebastien.ponce@cern.ch>
src/libradosstriper/RadosStriperImpl.cc
src/libradosstriper/RadosStriperImpl.h

index 5685b2fefdbe85278c0c3db9b717054e3dccad2e..3691e32fcc61ccc25b041eee10b2eedf7bca968b 100644 (file)
@@ -392,10 +392,9 @@ static void rados_req_read_safe(rados_completion_t c, void *arg)
   // ENOENT means that we are dealing with a sparse file. This is fine,
   // data (0s) will be created on the fly by the rados_req_read_complete method
   if (rc == -ENOENT) rc = 0;
-  librados::AioCompletion *comp = reinterpret_cast<librados::AioCompletion*>(c);
   libradosstriper::MultiAioCompletionImpl *multiAioComp = data->m_multiAioCompl;
-  if (0 == comp->pc->ack) delete data;
   multiAioComp->safe_request(rc);
+  data->put();
 }
 
 static void rados_req_read_complete(rados_completion_t c, void *arg)
@@ -425,10 +424,9 @@ static void rados_req_read_complete(rados_completion_t c, void *arg)
     }
     rc = data->m_expectedBytes;
   }
-  librados::AioCompletion *comp = reinterpret_cast<librados::AioCompletion*>(c);
   libradosstriper::MultiAioCompletionImpl * multiAioComp = data->m_multiAioCompl;
-  if (0 == comp->pc->safe) delete data;
   multiAioComp->complete_request(rc);
+  data->put();
 }
 
 int libradosstriper::RadosStriperImpl::aio_read(const std::string& soid,
@@ -481,7 +479,9 @@ int libradosstriper::RadosStriperImpl::aio_read(const std::string& soid,
     }
     // read all extends of a given object in one go
     nc->add_request();
-    RadosReadCompletionData *data = new RadosReadCompletionData(nc, p->length, oid_bl);
+    // we need 2 references on data as both rados_req_read_safe and rados_req_read_complete
+    // will release one
+    RadosReadCompletionData *data = new RadosReadCompletionData(nc, p->length, oid_bl, cct(), 2);
     librados::AioCompletion *rados_completion =
       m_radosCluster.aio_create_completion(data, rados_req_read_complete, rados_req_read_safe);
     r = m_ioCtx.aio_read(p->oid.name, rados_completion, oid_bl, p->length, p->offset);
index 7f51895bbec5ffc491f44c498e0d88eb00849a40..bc0203277fcd012d81798dc47bbab56080d53c7c 100644 (file)
@@ -25,6 +25,7 @@
 #include "include/radosstriper/libradosstriper.hpp"
 
 #include "librados/IoCtxImpl.h"
+#include "common/RefCountedObj.h"
 
 struct libradosstriper::RadosStriperImpl {
 
@@ -99,11 +100,14 @@ struct libradosstriper::RadosStriperImpl {
    * struct handling the data needed to pass to the call back
    * function in asynchronous read operations of a Rados File
    */
-  struct RadosReadCompletionData {
+  struct RadosReadCompletionData : RefCountedObject {
     /// constructor
     RadosReadCompletionData(MultiAioCompletionImpl *multiAioCompl,
                            uint64_t expectedBytes,
-                           bufferlist *bl) :
+                           bufferlist *bl,
+                           CephContext *context,
+                           int n = 1) :
+      RefCountedObject(context, n),
       m_multiAioCompl(multiAioCompl), m_expectedBytes(expectedBytes), m_bl(bl) {};
     /// the multi asynch io completion object to be used
     MultiAioCompletionImpl *m_multiAioCompl;