]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: make object existence check robust
authorSage Weil <sage@redhat.com>
Thu, 1 Sep 2016 15:43:55 +0000 (11:43 -0400)
committerSage Weil <sage@redhat.com>
Thu, 1 Sep 2016 15:45:36 +0000 (11:45 -0400)
We may have the OnodeRef defined but the object may have
exists==false.  Move the check out of the lookup block
so that we get the right behavior.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc

index 75c4b683e62d290cf2b0f800e3f8e871c5385254..0005ca30a9ed6237c72592144f874bd346dc82ab 100644 (file)
@@ -5553,27 +5553,26 @@ void BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t)
       assert(0 == "unexpected error");
     }
 
+    // these operations implicity create the object
+    bool create = false;
+    if (op->op == Transaction::OP_TOUCH ||
+       op->op == Transaction::OP_WRITE ||
+       op->op == Transaction::OP_ZERO) {
+      create = true;
+    }
+
     // object operations
     RWLock::WLocker l(c->lock);
     OnodeRef &o = ovec[op->oid];
     if (!o) {
-      // these operations implicity create the object
-      bool create = false;
-      if (op->op == Transaction::OP_TOUCH ||
-         op->op == Transaction::OP_WRITE ||
-         op->op == Transaction::OP_ZERO) {
-       create = true;
-      }
       ghobject_t oid = i.get_oid(op->oid);
       o = c->get_onode(oid, create);
-      if (!create) {
-       if (!o || !o->exists) {
-         dout(10) << __func__ << " op " << op->op << " got ENOENT on "
-                  << oid << dendl;
-         r = -ENOENT;
-         goto endop;
-       }
-      }
+    }
+    if (!create && (!o || !o->exists)) {
+      dout(10) << __func__ << " op " << op->op << " got ENOENT on "
+              << i.get_oid(op->oid) << dendl;
+      r = -ENOENT;
+      goto endop;
     }
 
     switch (op->op) {