]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/Newstore: flush_commit return true on STATE_KV_DONE
authorXiaoxi Chen <xiaoxi.chen@intel.com>
Wed, 29 Apr 2015 05:45:52 +0000 (13:45 +0800)
committerSage Weil <sage@redhat.com>
Tue, 1 Sep 2015 17:39:41 +0000 (13:39 -0400)
There is a racing condition here, if the flush_commit() call
happened after _txc_finish_kv and before next state, the context
was pushed to on_commits but no one will handle the context since
we already pass _txc_finish_kv. This bug can be easily reproduce
by putting a sleep(5) after _txc_finish_kv, and trigger the bug by
ceph-osd -i 0 --mkfs.

Fix this bug by return true directly when state >= STATE_KV_DONE(instead
of > in previous code). We already persist the data in STATE_KV_DONE so
it's safe for us to do this.

Signed-off-by: Xiaoxi Chen <xiaoxi.chen@intel.com>
src/os/newstore/NewStore.h

index ce6dfac17d04b586996f2e1cd2a7670bf1d8a2cb..95122a1c4662b434183d96478b24492d343e77fd 100644 (file)
@@ -304,10 +304,10 @@ public:
        return true;
       }
       TransContext *txc = &q.back();
-      if (txc->state > TransContext::STATE_KV_DONE) {
+      if (txc->state >= TransContext::STATE_KV_DONE) {
        return true;
       }
-      assert(txc->state <= TransContext::STATE_KV_DONE);
+      assert(txc->state < TransContext::STATE_KV_DONE);
       txc->oncommits.push_back(c);
       return false;
     }