]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/Objecter: add have_map method
authorJohn Spray <john.spray@redhat.com>
Mon, 20 Oct 2014 15:41:29 +0000 (16:41 +0100)
committerJohn Spray <john.spray@redhat.com>
Tue, 16 Dec 2014 20:45:58 +0000 (20:45 +0000)
This is for places we're going to call wait_for_map, so
that we can easily check if we will *probably* get
a true from wait_for_map, and thereby avoid
allocating Contexts we won't need.

Signed-off-by: John Spray <john.spray@redhat.com>
src/osdc/Objecter.cc
src/osdc/Objecter.h

index 3f60c71975e40856cd08677ef98a0ec8130383a1..8f30157418eab3f52dcf84aa5f3c5c1b26aec2e7 100644 (file)
@@ -1457,6 +1457,27 @@ void Objecter::_wait_for_new_map(Context *c, epoch_t epoch, int err)
   assert(r == 0);
 }
 
+
+/**
+ * Use this together with wait_for_map: this is a pre-check to avoid
+ * allocating a Context for wait_for_map if we can see that we definitely
+ * already have the epoch.
+ *
+ * This does *not* replace the need to handle the return value of wait_for_map:
+ * just because we don't have it in this pre-check doesn't mean we won't
+ * have it when calling back into wait_for_map, since the objecter lock
+ * is dropped in between.
+ */
+bool Objecter::have_map(const epoch_t epoch)
+{
+  RWLock::RLocker rl(rwlock);
+  if (osdmap->get_epoch() >= epoch) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
 bool Objecter::wait_for_map(epoch_t epoch, Context *c, int err)
 {
   RWLock::WLocker wl(rwlock);
index 94ca79be7a5ba818f5a347556f000c7cb68df1a7..9a0c614c39357473e2260da0113b09bd2b19bb30 100644 (file)
@@ -1808,6 +1808,7 @@ public:
   int get_client_incarnation() const { return client_inc.read(); }
   void set_client_incarnation(int inc) { client_inc.set(inc); }
 
+  bool have_map(epoch_t epoch);
   /// wait for epoch; true if we already have it
   bool wait_for_map(epoch_t epoch, Context *c, int err=0);
   void _wait_for_new_map(Context *c, epoch_t epoch, int err=0);