]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: don't allow for io_id to complete more than once
authorYehuda Sadeh <yehuda@redhat.com>
Mon, 6 Nov 2017 22:56:12 +0000 (14:56 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 10 Apr 2018 15:05:39 +0000 (08:05 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_coroutine.cc
src/rgw/rgw_coroutine.h
src/rgw/rgw_http_client.h

index cbdeecd84cdd28cb30397999ccf4b7b0a4cca007..4e3fed07d8d4ecb011428d9c78259b32dddfb4c3 100644 (file)
@@ -62,7 +62,10 @@ void RGWCompletionManager::_complete(RGWAioCompletionNotifier *cn, const rgw_io_
     cns.erase(cn);
   }
 
-#warning shouldn't have more than one entry in complete_reqs per io_id
+  if (complete_reqs_set.find(io_id) != complete_reqs_set.end()) {
+    /* already have completion for this io_id, don't allow multiple completions for it */
+    return;
+  }
   complete_reqs.push_back(io_completion{io_id, user_info});
   cond.Signal();
 }
@@ -77,6 +80,7 @@ int RGWCompletionManager::get_next(io_completion *io)
     cond.Wait(lock);
   }
   *io = complete_reqs.front();
+  complete_reqs_set.erase(io->io_id);
   complete_reqs.pop_front();
   return 0;
 }
@@ -88,6 +92,7 @@ bool RGWCompletionManager::try_get_next(io_completion *io)
     return false;
   }
   *io = complete_reqs.front();
+  complete_reqs_set.erase(io->io_id);
   complete_reqs.pop_front();
   return true;
 }
index a7b2797264c9c0fe740bc55384b3f717c168cf07..d61b40aae9ba56dc20fb4b18cd62b635716e87bc 100644 (file)
@@ -43,6 +43,7 @@ class RGWCompletionManager : public RefCountedObject {
     void *user_info;
   };
   list<io_completion> complete_reqs;
+  set<rgw_io_id> complete_reqs_set;
   using NotifierRef = boost::intrusive_ptr<RGWAioCompletionNotifier>;
   set<NotifierRef> cns;
 
index 9c64feb19aa73b0631ee3d5de9dec9c2e9182496..127e9e81ad1e35f9604223fa0991c9b31353862d 100644 (file)
@@ -41,6 +41,14 @@ struct rgw_io_id {
   bool intersects(const rgw_io_id& rhs) {
     return (id == rhs.id && ((channels | rhs.channels) != 0));
   }
+
+  bool operator<(const rgw_io_id& rhs) const {
+    if (id < rhs.id) {
+      return true;
+    }
+    return (id == rhs.id &&
+            channels < rhs.channels);
+  }
 };
 
 class RGWIOProvider