From: Sage Weil Date: Thu, 1 Sep 2016 15:43:55 +0000 (-0400) Subject: os/bluestore: make object existence check robust X-Git-Tag: v11.0.1~336^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0210f1fde6f8e17affdd0c49055a71a01f109447;p=ceph.git os/bluestore: make object existence check robust 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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 75c4b683e62..0005ca30a9e 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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) {