Merge pull request #4059 from majianpeng/copyget-digest

Replicated: For COPY_GET, only src has data/omap digest, the dst can do.

Reviewed-by: Sage Weil <sage@redhat.com>
Reviewed-by: Samuel Just <sjust@redhat.com>
This commit is contained in:
Samuel Just 2015-05-29 10:41:12 -07:00
commit 2b28150765

View File

@ -4210,8 +4210,10 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
write_update_size_and_usage(ctx->delta_stats, oi, ctx->modified_ranges,
op.extent.offset, op.extent.length, true);
maybe_create_new_object(ctx);
if (op.extent.offset == 0 && op.extent.length == oi.size)
if (op.extent.offset == 0 && op.extent.length >= oi.size)
obs.oi.set_data_digest(osd_op.indata.crc32c(-1));
else if (op.extent.offset == oi.size && obs.oi.is_data_digest())
obs.oi.set_data_digest(osd_op.indata.crc32c(obs.oi.data_digest));
else
obs.oi.clear_data_digest();
}
@ -6256,10 +6258,11 @@ void ReplicatedPG::process_copy_chunk(hobject_t oid, ceph_tid_t tid, int r)
return;
}
if (cop->omap_data.length())
if (cop->omap_data.length() || cop->omap_header.length())
cop->results.has_omap = true;
if (r >= 0 && pool.info.require_rollback() && cop->omap_data.length()) {
if (r >= 0 && pool.info.require_rollback() &&
(cop->omap_data.length() || cop->omap_header.length())) {
r = -EOPNOTSUPP;
}
cop->objecter_tid = 0;
@ -6320,14 +6323,16 @@ void ReplicatedPG::process_copy_chunk(hobject_t oid, ceph_tid_t tid, int r)
_build_finish_copy_transaction(cop, cop->results.final_tx);
// verify digests?
dout(20) << __func__ << std::hex
<< " got digest: rx data 0x" << cop->results.data_digest
<< " omap 0x" << cop->results.omap_digest
<< ", source: data 0x" << cop->results.source_data_digest
<< " omap 0x" << cop->results.source_omap_digest
<< std::dec
<< " flags " << cop->results.flags
<< dendl;
if (cop->results.is_data_digest() || cop->results.is_omap_digest()) {
dout(20) << __func__ << std::hex
<< " got digest: rx data 0x" << cop->results.data_digest
<< " omap 0x" << cop->results.omap_digest
<< ", source: data 0x" << cop->results.source_data_digest
<< " omap 0x" << cop->results.source_omap_digest
<< std::dec
<< " flags " << cop->results.flags
<< dendl;
}
if (cop->results.is_data_digest() &&
cop->results.data_digest != cop->results.source_data_digest) {
derr << __func__ << std::hex << " data digest 0x" << cop->results.data_digest
@ -6665,6 +6670,11 @@ void ReplicatedPG::finish_promote(int r, CopyResults *results,
}
tctx->new_obs.oi.size = results->object_size;
tctx->new_obs.oi.user_version = results->user_version;
// Don't care src object whether have data or omap digest
if (results->object_size)
tctx->new_obs.oi.set_data_digest(results->data_digest);
if (results->has_omap)
tctx->new_obs.oi.set_omap_digest(results->omap_digest);
if (soid.snap != CEPH_NOSNAP) {
if (!results->snaps.empty()) {