]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/cas: replace bool get() with void get()
authormyoungwon oh <ohmyoungwon@gmail.com>
Sat, 20 Jun 2020 06:04:46 +0000 (15:04 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Sat, 20 Jun 2020 06:33:58 +0000 (15:33 +0900)
Since we allow multiple hoject_t to store in refs_t
due to supporting snapshot, bool is not necessary.

Signed-off-by: Myoungwon Oh <ohmyoungwon@gmail.com>
src/cls/cas/cls_cas.cc
src/cls/cas/cls_cas_internal.h
src/test/cls_cas/test_cls_cas.cc

index 0df07bcf5616f91367badb7eda313a5cc019723b..e7b9bec7dcd58448dbf679bac7d40fd6121fc310 100644 (file)
@@ -107,15 +107,7 @@ static int chunk_create_or_get_ref(cls_method_context_t hctx,
     CLS_LOG(10, "inc ref oid=%s\n",
            op.source.oid.name.c_str());
 
-    if (!objr.get(op.source)) {
-      // we could perhaps return -EEXIST here, but instead we will
-      // behave in an idempotent fashion, since we know that it is possible
-      // for references to be leaked.  If A has a ref, tries to drop it and
-      // fails (leaks), and then later tries to take it again, we should
-      // simply succeed if we know we already have it.  This will serve to
-      // silently correct the mistake.
-      return 0;
-    }
+    objr.get(op.source);
 
     ret = chunk_set_refcount(hctx, objr);
     if (ret < 0) {
@@ -148,15 +140,7 @@ static int chunk_get_ref(cls_method_context_t hctx,
   // existing chunk; inc ref
   CLS_LOG(10, "oid=%s\n", op.source.oid.name.c_str());
   
-  if (!objr.get(op.source)) {
-    // we could perhaps return -EEXIST here, but instead we will
-    // behave in an idempotent fashion, since we know that it is possible
-    // for references to be leaked.  If A has a ref, tries to drop it and
-    // fails (leaks), and then later tries to take it again, we should
-    // simply succeed if we know we already have it.  This will serve to
-    // silently correct the mistake.
-    return 0;
-  }
+  objr.get(op.source);
 
   ret = chunk_set_refcount(hctx, objr);
   if (ret < 0) {
index 1fdb949266590df917404caffb03fc2e419e061d..14d3119a9d247b34c8da71d7d9e8be275314b1da 100644 (file)
@@ -39,7 +39,7 @@ struct chunk_refs_t {
     virtual uint8_t get_type() const = 0;
     virtual bool empty() const = 0;
     virtual uint64_t count() const = 0;
-    virtual bool get(const hobject_t& o) = 0;
+    virtual void get(const hobject_t& o) = 0;
     virtual bool put(const hobject_t& o) = 0;
     virtual void dump(Formatter *f) const = 0;
     virtual std::string describe_encoding() const {
@@ -72,8 +72,8 @@ struct chunk_refs_t {
     return r->count();
   }
 
-  bool get(const hobject_t& o) {
-    return r->get(o);
+  void get(const hobject_t& o) {
+    r->get(o);
   }
   bool put(const hobject_t& o) {
     bool ret = r->put(o);
@@ -115,9 +115,8 @@ struct chunk_refs_by_object_t : public chunk_refs_t::refs_t {
   uint64_t count() const override {
     return by_object.size();
   }
-  bool get(const hobject_t& o) override {
+  void get(const hobject_t& o) override {
     by_object.insert(o);
-    return true;
   }
   bool put(const hobject_t& o) override {
     auto p = by_object.find(o);
@@ -196,10 +195,9 @@ struct chunk_refs_by_hash_t : public chunk_refs_t::refs_t {
   uint64_t count() const override {
     return total;
   }
-  bool get(const hobject_t& o) override {
+  void get(const hobject_t& o) override {
     by_hash[make_pair(o.pool, o.get_hash() & mask())]++;
     ++total;
-    return true;
   }
   bool put(const hobject_t& o) override {
     auto p = by_hash.find(make_pair(o.pool, o.get_hash() & mask()));
@@ -286,10 +284,9 @@ struct chunk_refs_by_pool_t : public chunk_refs_t::refs_t {
   uint64_t count() const override {
     return total;
   }
-  bool get(const hobject_t& o) override {
+  void get(const hobject_t& o) override {
     ++by_pool[o.pool];
     ++total;
-    return true;
   }
   bool put(const hobject_t& o) override {
     auto p = by_pool.find(o.pool);
@@ -364,9 +361,8 @@ struct chunk_refs_count_t : public chunk_refs_t::refs_t {
   uint64_t count() const override {
     return total;
   }
-  bool get(const hobject_t& o) override {
+  void get(const hobject_t& o) override {
     ++total;
-    return true;
   }
   bool put(const hobject_t& o) override {
     if (!total) {
index 870b573fb06f1b612e91f7080f6da2e2df172f37..01db8a32be6ad3a821b1b23bd9cde6263b273f96 100644 (file)
@@ -310,8 +310,7 @@ TEST(chunk_refs_t, size)
   for (size_t i = 1; i <= max; ++i) {
     hobject_t h(sobject_t(object_t("foo"s + stringify(i)), i));
     h.pool = i > pool_cutoff ? i : (i & pool_mask);
-    bool ret = r.get(h);
-    ASSERT_TRUE(ret);
+    r.get(h);
     if (count_bits(i) <= 2) {
       bufferlist bl;
       r.dynamic_encode(bl, 512);