From: myoungwon oh Date: Thu, 19 Nov 2020 07:54:01 +0000 (+0900) Subject: osd: fix clone size mismatch when dedup object is evicted X-Git-Tag: v16.1.0~158^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7ea895171bea928c140333259d4e5989d5601c5e;p=ceph.git osd: fix clone size mismatch when dedup object is evicted 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 --- diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index ff68a8ce9dc5..4ee519a20976 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -7067,14 +7067,13 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& 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); diff --git a/src/test/librados/tier_cxx.cc b/src/test/librados/tier_cxx.cc index a65e1da205ca..c8d6931758bb 100644 --- a/src/test/librados/tier_cxx.cc +++ b/src/test/librados/tier_cxx.cc @@ -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);