]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: drop async cr reference on simple cr completion
authorYehuda Sadeh <yehuda@redhat.com>
Sun, 17 Apr 2016 18:14:39 +0000 (11:14 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 18 Apr 2016 00:03:13 +0000 (17:03 -0700)
Added a new callback for simple cr that is called anyway when done. Then
drop the reference to the async operation there and not at the destructor.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_coroutine.cc
src/rgw/rgw_coroutine.h
src/rgw/rgw_cr_rados.cc
src/rgw/rgw_cr_rados.h

index ef28ae21fa0ce1e8217d85ba94ca4de35b597861..a09afc85532cb044db8ad02417711b301913c402 100644 (file)
@@ -803,6 +803,19 @@ void RGWCoroutine::dump(Formatter *f) const {
   }
 }
 
+RGWSimpleCoroutine::~RGWSimpleCoroutine()
+{
+  if (!called_cleanup) {
+    request_cleanup();
+  }
+}
+
+void RGWSimpleCoroutine::call_cleanup()
+{
+  called_cleanup = true;
+  request_cleanup();
+}
+
 int RGWSimpleCoroutine::operate()
 {
   int ret = 0;
@@ -812,6 +825,7 @@ int RGWSimpleCoroutine::operate()
     yield return state_request_complete();
     yield return state_all_complete();
     drain_all();
+    call_cleanup();
     return set_state(RGWCoroutine_Done, ret);
   }
   return 0;
@@ -821,6 +835,7 @@ int RGWSimpleCoroutine::state_init()
 {
   int ret = init();
   if (ret < 0) {
+    call_cleanup();
     return set_state(RGWCoroutine_Error, ret);
   }
   return 0;
@@ -830,6 +845,7 @@ int RGWSimpleCoroutine::state_send_request()
 {
   int ret = send_request();
   if (ret < 0) {
+    call_cleanup();
     return set_state(RGWCoroutine_Error, ret);
   }
   return io_block(0);
@@ -839,6 +855,7 @@ int RGWSimpleCoroutine::state_request_complete()
 {
   int ret = request_complete();
   if (ret < 0) {
+    call_cleanup();
     return set_state(RGWCoroutine_Error, ret);
   }
   return 0;
@@ -848,6 +865,7 @@ int RGWSimpleCoroutine::state_all_complete()
 {
   int ret = finish();
   if (ret < 0) {
+    call_cleanup();
     return set_state(RGWCoroutine_Error, ret);
   }
   return 0;
index b27d3e74a4612f9610af01a443e01e15009b2678..11addf68b2300dbe29939cd1f6e0cf5793be26f2 100644 (file)
@@ -564,6 +564,8 @@ public:
 };
 
 class RGWSimpleCoroutine : public RGWCoroutine {
+  bool called_cleanup;
+
   int operate();
 
   int state_init();
@@ -571,14 +573,17 @@ class RGWSimpleCoroutine : public RGWCoroutine {
   int state_request_complete();
   int state_all_complete();
 
+  void call_cleanup();
+
 public:
-  RGWSimpleCoroutine(CephContext *_cct) : RGWCoroutine(_cct) {}
+  RGWSimpleCoroutine(CephContext *_cct) : RGWCoroutine(_cct), called_cleanup(false) {}
+  ~RGWSimpleCoroutine();
 
   virtual int init() { return 0; }
   virtual int send_request() = 0;
   virtual int request_complete() = 0;
   virtual int finish() { return 0; }
-
+  virtual void request_cleanup() {}
 };
 
 #endif
index 4b91acf3d18312389296cdec1e72f11e964a1623..398433c3df419174b0c7b694e1d1d5e1d49511e1 100644 (file)
@@ -305,7 +305,7 @@ RGWSimpleRadosLockCR::RGWSimpleRadosLockCR(RGWAsyncRadosProcessor *_async_rados,
   s << "rados lock dest=" << pool << "/" << oid << " lock=" << lock_name << " cookie=" << cookie << " duration=" << duration;
 }
 
-RGWSimpleRadosLockCR::~RGWSimpleRadosLockCR()
+void RGWSimpleRadosLockCR::request_cleanup()
 {
   if (req) {
     req->finish();
@@ -341,7 +341,7 @@ RGWSimpleRadosUnlockCR::RGWSimpleRadosUnlockCR(RGWAsyncRadosProcessor *_async_ra
   set_description() << "rados unlock dest=" << pool << "/" << oid << " lock=" << lock_name << " cookie=" << cookie;
 }
 
-RGWSimpleRadosUnlockCR::~RGWSimpleRadosUnlockCR()
+void RGWSimpleRadosUnlockCR::request_cleanup()
 {
   if (req) {
     req->finish();
@@ -635,7 +635,7 @@ RGWStatObjCR::RGWStatObjCR(RGWAsyncRadosProcessor *async_rados, RGWRados *store,
 {
 }
 
-RGWStatObjCR::~RGWStatObjCR()
+void RGWStatObjCR::request_cleanup()
 {
   if (req) {
     req->finish();
index f320076f9e3ec13e50eff989ca2707660037db9d..2459e78732638baa0ac94430b5e37054c18f0fa7 100644 (file)
@@ -9,7 +9,6 @@ class RGWAsyncRadosRequest : public RefCountedObject {
   RGWCoroutine *caller;
   RGWAioCompletionNotifier *notifier;
 
-  void *user_info;
   int retcode;
 
   bool done;
@@ -19,15 +18,18 @@ class RGWAsyncRadosRequest : public RefCountedObject {
 protected:
   virtual int _send_request() = 0;
 public:
-  RGWAsyncRadosRequest(RGWCoroutine *_caller, RGWAioCompletionNotifier *_cn) : caller(_caller), notifier(_cn),
+  RGWAsyncRadosRequest(RGWCoroutine *_caller, RGWAioCompletionNotifier *_cn) : caller(_caller), notifier(_cn), retcode(0),
                                                                                done(false), lock("RGWAsyncRadosRequest::lock") {
+    notifier->get();
     caller->get();
   }
   virtual ~RGWAsyncRadosRequest() {
+    notifier->put();
     caller->put();
   }
 
   void send_request() {
+    get();
     retcode = _send_request();
     {
       Mutex::Locker l(lock);
@@ -35,6 +37,7 @@ public:
         notifier->cb();
       }
     }
+    put();
   }
 
   int get_ret_status() { return retcode; }
@@ -195,7 +198,7 @@ public:
                                                result(_result),
                                                 req(NULL) { }
                                                          
-  ~RGWSimpleRadosReadCR() {
+  void request_cleanup() {
     if (req) {
       req->finish();
     }
@@ -270,7 +273,7 @@ public:
                                                 pattrs(_pattrs),
                                                 req(NULL) { }
                                                          
-  ~RGWSimpleRadosReadAttrsCR() {
+  void request_cleanup() {
     if (req) {
       req->finish();
     }
@@ -302,7 +305,7 @@ public:
     ::encode(_data, bl);
   }
 
-  ~RGWSimpleRadosWriteCR() {
+  void request_cleanup() {
     if (req) {
       req->finish();
     }
@@ -342,7 +345,7 @@ public:
                                                 attrs(_attrs), req(NULL) {
   }
 
-  ~RGWSimpleRadosWriteAttrsCR() {
+  void request_cleanup() {
     if (req) {
       req->finish();
     }
@@ -374,6 +377,7 @@ public:
   RGWRadosSetOmapKeysCR(RGWRados *_store,
                      rgw_bucket& _pool, const string& _oid,
                      map<string, bufferlist>& _entries);
+
   ~RGWRadosSetOmapKeysCR();
 
   int send_request();
@@ -400,6 +404,7 @@ public:
                      const rgw_bucket& _pool, const string& _oid,
                      const string& _marker,
                      map<string, bufferlist> *_entries, int _max_entries);
+
   ~RGWRadosGetOmapKeysCR();
 
   int send_request();
@@ -426,7 +431,7 @@ public:
                      const rgw_bucket& _pool, const string& _oid, const string& _lock_name,
                      const string& _cookie,
                      uint32_t _duration);
-  ~RGWSimpleRadosLockCR();
+  void request_cleanup();
 
   int send_request();
   int request_complete();
@@ -447,7 +452,7 @@ public:
   RGWSimpleRadosUnlockCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
                      const rgw_bucket& _pool, const string& _oid, const string& _lock_name,
                      const string& _cookie);
-  ~RGWSimpleRadosUnlockCR();
+  void request_cleanup();
 
   int send_request();
   int request_complete();
@@ -518,7 +523,7 @@ public:
                          async_rados(_async_rados), lock(_lock), cond(_cond), secs(_secs), req(NULL) {
   }
 
-  ~RGWWaitCR() {
+  void request_cleanup() {
     wakeup();
     if (req) {
       req->finish();
@@ -616,7 +621,7 @@ public:
                         RGWBucketInfo *_bucket_info) : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), store(_store),
                                                        bucket_name(_bucket_name), bucket_id(_bucket_id),
                                                        bucket_info(_bucket_info), req(NULL) {}
-  ~RGWGetBucketInstanceInfoCR() {
+  void request_cleanup() {
     if (req) {
       req->finish();
     }
@@ -693,7 +698,7 @@ public:
                                        copy_if_newer(_if_newer), req(NULL) {}
 
 
-  ~RGWFetchRemoteObjCR() {
+  void request_cleanup() {
     if (req) {
       req->finish();
     }
@@ -808,7 +813,7 @@ public:
     }
   }
 
-  ~RGWRemoveObjCR() {
+  void request_cleanup() {
     if (req) {
       req->finish();
     }
@@ -931,7 +936,7 @@ class RGWStatObjCR : public RGWSimpleCoroutine {
          const rgw_obj& obj, uint64_t *psize = nullptr,
          real_time* pmtime = nullptr, uint64_t *pepoch = nullptr,
          RGWObjVersionTracker *objv_tracker = nullptr);
-  ~RGWStatObjCR();
+  void request_cleanup();
 
   int send_request() override;
   int request_complete() override;