From d34444be01a9809340081a9c890373e84bd18e1c Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Mon, 3 Jul 2017 18:48:13 +0800 Subject: [PATCH] os/bluestore/BlueStore: move "onode::exists=true" in _assign_nid. If object has nid, it always set exists =true in get_onode. Signed-off-by: Jianpeng Ma --- src/os/bluestore/BlueStore.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 54cf6d824d3..50fa241137e 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7551,12 +7551,15 @@ int BlueStore::_upgrade_super() void BlueStore::_assign_nid(TransContext *txc, OnodeRef o) { - if (o->onode.nid) + if (o->onode.nid) { + assert(o->exists); return; + } uint64_t nid = ++nid_last; dout(20) << __func__ << " " << nid << dendl; o->onode.nid = nid; txc->last_nid = nid; + o->exists = true; } uint64_t BlueStore::_assign_blobid(TransContext *txc) @@ -9156,7 +9159,6 @@ int BlueStore::_touch(TransContext *txc, { dout(15) << __func__ << " " << c->cid << " " << o->oid << dendl; int r = 0; - o->exists = true; _assign_nid(txc, o); txc->write_onode(o); dout(10) << __func__ << " " << c->cid << " " << o->oid << " = " << r << dendl; @@ -10278,7 +10280,6 @@ int BlueStore::_write(TransContext *txc, dout(15) << __func__ << " " << c->cid << " " << o->oid << " 0x" << std::hex << offset << "~" << length << std::dec << dendl; - o->exists = true; _assign_nid(txc, o); int r = _do_write(txc, c, o, offset, length, bl, fadvise_flags); txc->write_onode(o); @@ -10297,7 +10298,6 @@ int BlueStore::_zero(TransContext *txc, dout(15) << __func__ << " " << c->cid << " " << o->oid << " 0x" << std::hex << offset << "~" << length << std::dec << dendl; - o->exists = true; _assign_nid(txc, o); int r = _do_zero(txc, c, o, offset, length); dout(10) << __func__ << " " << c->cid << " " << o->oid @@ -10775,7 +10775,6 @@ int BlueStore::_clone(TransContext *txc, return -EINVAL; } - newo->exists = true; _assign_nid(txc, newo); // clone data @@ -10960,7 +10959,6 @@ int BlueStore::_clone_range(TransContext *txc, goto out; } - newo->exists = true; _assign_nid(txc, newo); if (length > 0) { -- 2.39.5