]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls_journal: fix -EEXIST checking 8413/head
authorrunsisi <runsisi@hust.edu.cn>
Fri, 1 Apr 2016 12:56:26 +0000 (20:56 +0800)
committerrunsisi <runsisi@hust.edu.cn>
Fri, 1 Apr 2016 12:56:26 +0000 (20:56 +0800)
Signed-off-by: runsisi <runsisi@zte.com.cn>
src/cls/journal/cls_journal.cc

index 1b61160a3046a7134766583885f4d523e6624ae5..6e7d9d56c91af64cd824b359fb93765b738b0ff0 100644 (file)
@@ -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