From ea100ac7151c5d11b788ffd503a78e89714fa5d8 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Thu, 16 Oct 2014 10:03:42 +0800 Subject: [PATCH] KeyValueStore: Add clone op detect to promote error Signed-off-by: Haomai Wang --- src/os/KeyValueStore.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/os/KeyValueStore.cc b/src/os/KeyValueStore.cc index daa8b059bcae3..59e9eb2b58551 100644 --- a/src/os/KeyValueStore.cc +++ b/src/os/KeyValueStore.cc @@ -1182,6 +1182,7 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction, Transaction::iterator i = transaction.begin(); uint64_t op_num = 0; + bool exist_clone = false; while (i.have_op()) { if (handle) @@ -1302,6 +1303,7 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction, coll_t cid = i.decode_cid(); ghobject_t oid = i.decode_oid(); ghobject_t noid = i.decode_oid(); + exist_clone = true; r = _clone(cid, oid, noid, t); } break; @@ -1313,6 +1315,7 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction, ghobject_t noid = i.decode_oid(); uint64_t off = i.decode_length(); uint64_t len = i.decode_length(); + exist_clone = true; r = _clone_range(cid, oid, noid, off, len, off, t); } break; @@ -1325,6 +1328,7 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction, uint64_t srcoff = i.decode_length(); uint64_t len = i.decode_length(); uint64_t dstoff = i.decode_length(); + exist_clone = true; r = _clone_range(cid, oid, noid, srcoff, len, dstoff, t); } break; @@ -1514,18 +1518,20 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction, if (r < 0) { bool ok = false; + if (r == -ENOENT && !(op == Transaction::OP_CLONERANGE || + op == Transaction::OP_CLONE || + op == Transaction::OP_CLONERANGE2)) + // -ENOENT is normally okay + // ...including on a replayed OP_RMCOLL with checkpoint mode + ok = true; if (r == -ENODATA) ok = true; if (!ok) { const char *msg = "unexpected error code"; - if (op == Transaction::OP_CLONERANGE || - op == Transaction::OP_CLONE || - op == Transaction::OP_CLONERANGE2) { + if (exist_clone) { dout(0) << "BUG: clone failed will lead to paritial transaction applied" << dendl; - if (r == -ENOENT) - msg = "ENOENT on clone suggests osd bug"; } if (r == -ENOSPC) -- 2.39.5