From: runsisi Date: Fri, 1 Apr 2016 12:56:26 +0000 (+0800) Subject: cls_journal: fix -EEXIST checking X-Git-Tag: v10.1.1~32^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F8413%2Fhead;p=ceph.git cls_journal: fix -EEXIST checking Signed-off-by: runsisi --- diff --git a/src/cls/journal/cls_journal.cc b/src/cls/journal/cls_journal.cc index 1b61160a304..6e7d9d56c91 100644 --- a/src/cls/journal/cls_journal.cc +++ b/src/cls/journal/cls_journal.cc @@ -250,9 +250,11 @@ int journal_create(cls_method_context_t hctx, bufferlist *in, bufferlist *out) { bufferlist stored_orderbl; int r = cls_cxx_map_get_val(hctx, HEADER_KEY_ORDER, &stored_orderbl); - if (r != -ENOENT) { + if (r >= 0) { CLS_ERR("journal already exists"); return -EEXIST; + } else if (r != -ENOENT) { + return r; } r = write_key(hctx, HEADER_KEY_ORDER, order); @@ -556,9 +558,11 @@ int journal_client_register(cls_method_context_t hctx, bufferlist *in, std::string key(key_from_client_id(id)); bufferlist stored_clientbl; r = cls_cxx_map_get_val(hctx, key, &stored_clientbl); - if (r != -ENOENT) { + if (r >= 0) { CLS_ERR("duplicate client id: %s", id.c_str()); return -EEXIST; + } else if (r != -ENOENT) { + return r; } cls::journal::Client client(id, data); @@ -866,9 +870,11 @@ int journal_tag_create(cls_method_context_t hctx, bufferlist *in, std::string key(key_from_tag_tid(tag_tid)); bufferlist stored_tag_bl; int r = cls_cxx_map_get_val(hctx, key, &stored_tag_bl); - if (r != -ENOENT) { + if (r >= 0) { CLS_ERR("duplicate tag id: %" PRIu64, tag_tid); return -EEXIST; + } else if (r != -ENOENT) { + return r; } // verify tag tid ordering