diff options
author | Jianpeng Ma <jianpeng.ma@intel.com> | 2019-06-11 10:41:44 +0200 |
---|---|---|
committer | Jianpeng Ma <jianpeng.ma@intel.com> | 2019-06-11 10:41:44 +0200 |
commit | 9400c850ac0f5c2ecf29351b6faadb3e6f3596b9 (patch) | |
tree | fc864c1b1abede9eb874aa895f45f5fcdad7a7df /src/os | |
parent | Merge pull request #23312 from sylvia0409/master (diff) | |
download | ceph-9400c850ac0f5c2ecf29351b6faadb3e6f3596b9.tar.xz ceph-9400c850ac0f5c2ecf29351b6faadb3e6f3596b9.zip |
os/objectstore: add new op OP_CREATE for create a new object.
For OP_CREATE in bluestore mean node didn't exist, so skip search form kvdb.
This function merged in 22f73ba. But because compatible problem,
it revert in 491c254.
This commit fix the compatible problem
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
Diffstat (limited to 'src/os')
-rw-r--r-- | src/os/Transaction.cc | 10 | ||||
-rw-r--r-- | src/os/Transaction.h | 15 | ||||
-rw-r--r-- | src/os/bluestore/BlueStore.cc | 14 | ||||
-rw-r--r-- | src/os/bluestore/BlueStore.h | 2 | ||||
-rw-r--r-- | src/os/filestore/FileStore.cc | 1 | ||||
-rw-r--r-- | src/os/kstore/KStore.cc | 2 | ||||
-rw-r--r-- | src/os/memstore/MemStore.cc | 1 |
7 files changed, 40 insertions, 5 deletions
diff --git a/src/os/Transaction.cc b/src/os/Transaction.cc index 5a5ae0cb6a2..d3a04579dda 100644 --- a/src/os/Transaction.cc +++ b/src/os/Transaction.cc @@ -56,6 +56,16 @@ void Transaction::dump(ceph::Formatter *f) case Transaction::OP_NOP: f->dump_string("op_name", "nop"); break; + case Transaction::OP_CREATE: + { + coll_t cid = i.get_cid(op->cid); + ghobject_t oid = i.get_oid(op->oid); + f->dump_string("op_name", "create"); + f->dump_stream("collection") << cid; + f->dump_stream("oid") << oid; + } + break; + case Transaction::OP_TOUCH: { coll_t cid = i.get_cid(op->cid); diff --git a/src/os/Transaction.h b/src/os/Transaction.h index 5c8111779a7..20d554819c2 100644 --- a/src/os/Transaction.h +++ b/src/os/Transaction.h @@ -106,6 +106,7 @@ class Transaction { public: enum { OP_NOP = 0, + OP_CREATE = 7, // cid, oid OP_TOUCH = 9, // cid, oid OP_WRITE = 10, // cid, oid, offset, len, bl OP_ZERO = 11, // cid, oid, offset, len @@ -400,6 +401,7 @@ public: case OP_NOP: break; + case OP_CREATE: case OP_TOUCH: case OP_REMOVE: case OP_SETATTR: @@ -792,6 +794,19 @@ public: data.ops++; } /** + * create + * + * create an object that does not yet exist + * (behavior is undefined if the object already exists) + */ + void create(const coll_t& cid, const ghobject_t& oid) { + Op* _op = _get_next_op(); + _op->op = OP_CREATE; + _op->cid = _get_coll_id(cid); + _op->oid = _get_object_id(oid); + data.ops++; + } + /** * touch * * Ensure the existance of an object in a collection. Create an diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 5db054135e1..f96caa7e6b0 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -3504,7 +3504,8 @@ uint64_t BlueStore::Collection::make_blob_unshared(SharedBlob *sb) BlueStore::OnodeRef BlueStore::Collection::get_onode( const ghobject_t& oid, - bool create) + bool create, + bool is_createop) { ceph_assert(create ? lock.is_wlocked() : lock.is_locked()); @@ -3528,9 +3529,12 @@ BlueStore::OnodeRef BlueStore::Collection::get_onode( << pretty_binary_string(key) << dendl; bufferlist v; - int r = store->db->get(PREFIX_OBJ, key.c_str(), key.size(), &v); - ldout(store->cct, 20) << " r " << r << " v.len " << v.length() << dendl; + int r = -ENOENT; Onode *on; + if (!is_createop) { + r = store->db->get(PREFIX_OBJ, key.c_str(), key.size(), &v); + ldout(store->cct, 20) << " r " << r << " v.len " << v.length() << dendl; + } if (v.length() == 0) { ceph_assert(r == -ENOENT); if (!store->cct->_conf->bluestore_debug_misc && @@ -11186,6 +11190,7 @@ void BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t) // these operations implicity create the object bool create = false; if (op->op == Transaction::OP_TOUCH || + op->op == Transaction::OP_CREATE || op->op == Transaction::OP_WRITE || op->op == Transaction::OP_ZERO) { create = true; @@ -11196,7 +11201,7 @@ void BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t) OnodeRef &o = ovec[op->oid]; if (!o) { ghobject_t oid = i.get_oid(op->oid); - o = c->get_onode(oid, create); + o = c->get_onode(oid, create, op->op == Transaction::OP_CREATE); } if (!create && (!o || !o->exists)) { dout(10) << __func__ << " op " << op->op << " got ENOENT on " @@ -11206,6 +11211,7 @@ void BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t) } switch (op->op) { + case Transaction::OP_CREATE: case Transaction::OP_TOUCH: r = _touch(txc, c, o); break; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 227716dfe3c..4f33010da27 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1396,7 +1396,7 @@ public: pool_opts_t pool_opts; ContextQueue *commit_queue; - OnodeRef get_onode(const ghobject_t& oid, bool create); + OnodeRef get_onode(const ghobject_t& oid, bool create, bool is_createop=false); // the terminology is confusing here, sorry! // diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index e72f0cc3095..ac7c6157075 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -2788,6 +2788,7 @@ void FileStore::_do_transaction( case Transaction::OP_NOP: break; case Transaction::OP_TOUCH: + case Transaction::OP_CREATE: { const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); diff --git a/src/os/kstore/KStore.cc b/src/os/kstore/KStore.cc index 2cf82e5efd0..eab11add1a2 100644 --- a/src/os/kstore/KStore.cc +++ b/src/os/kstore/KStore.cc @@ -2315,6 +2315,7 @@ void KStore::_txc_add_transaction(TransContext *txc, Transaction *t) // these operations implicity create the object bool create = false; if (op->op == Transaction::OP_TOUCH || + op->op == Transaction::OP_CREATE || op->op == Transaction::OP_WRITE || op->op == Transaction::OP_ZERO) { create = true; @@ -2333,6 +2334,7 @@ void KStore::_txc_add_transaction(TransContext *txc, Transaction *t) switch (op->op) { case Transaction::OP_TOUCH: + case Transaction::OP_CREATE: r = _touch(txc, c, o); break; diff --git a/src/os/memstore/MemStore.cc b/src/os/memstore/MemStore.cc index dc1d5ff55ab..02bbf62395f 100644 --- a/src/os/memstore/MemStore.cc +++ b/src/os/memstore/MemStore.cc @@ -670,6 +670,7 @@ void MemStore::_do_transaction(Transaction& t) case Transaction::OP_NOP: break; case Transaction::OP_TOUCH: + case Transaction::OP_CREATE: { coll_t cid = i.get_cid(op->cid); ghobject_t oid = i.get_oid(op->oid); |