]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix clone size mismatch when dedup object is evicted
authormyoungwon oh <ohmyoungwon@gmail.com>
Thu, 19 Nov 2020 07:54:01 +0000 (16:54 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Sat, 12 Dec 2020 12:52:09 +0000 (21:52 +0900)
When evicting deduped object which is cloned,
we try to shrink its size to zero if all chunks are in chunk_map.
However, we did not set clone_size to zero, resulting in
clone size mismatch.

Specifically, build_push_op appends zero data with reference to
copy_set set by clone_size, but actual size in oi.size is zero.

Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/osd/PrimaryLogPG.cc
src/test/librados/tier_cxx.cc

index ff68a8ce9dc50b7b487295b6b94d1d37d78c5b5a..4ee519a20976441549496c3f082e799af2772f34 100644 (file)
@@ -7067,14 +7067,13 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
          chunk_length += p.second.length;
        }
        if (chunk_length == obs.oi.size) {
-         // truncate
          for (auto &p : obs.oi.manifest.chunk_map) {
            p.second.set_flag(chunk_info_t::FLAG_MISSING);
          }
-         t->truncate(obs.oi.soid, 0);
-         ctx->delta_stats.num_bytes -= obs.oi.size;
+         // punch hole
+         t->zero(soid, 0, oi.size);
+         oi.clear_data_digest();
          ctx->delta_stats.num_wr++;
-         oi.size = 0;
          ctx->cache_operation = true;
        }
        osd->logger->inc(l_osd_tier_evict);
index a65e1da205cafa7b43d6533567c91be9f2aae318..c8d6931758bb92713911f13fe9efa9ed92dbce69 100644 (file)
@@ -4608,24 +4608,7 @@ TEST_F(LibRadosTwoPoolsPP, ManifestEvict) {
 
     stat_op.stat(&size, NULL, NULL);
     ASSERT_EQ(0, ioctx.operate("foo", &stat_op, NULL));
-    ASSERT_EQ(0, size);
-  }
-
-  ioctx.snap_set_read(my_snaps[1]);
-  {
-    ObjectReadOperation op, stat_op;
-    uint64_t size;
-    op.tier_evict();
-    librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate(
-       "foo", completion, &op,
-       librados::OPERATION_IGNORE_OVERLAY, NULL));
-    completion->wait_for_complete();
-    ASSERT_EQ(0, completion->get_return_value());
-
-    stat_op.stat(&size, NULL, NULL);
-    ASSERT_EQ(0, ioctx.operate("foo", &stat_op, NULL));
-    ASSERT_EQ(0, size);
+    ASSERT_EQ(10, size);
   }
 
   ioctx.snap_set_read(librados::SNAP_HEAD);