From 4667280f8afe6cd68dfffea61d7530581f3dd0eb Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Tue, 17 Oct 2017 20:23:05 +0800 Subject: [PATCH] osd/PrimaryLogPG: trigger auto-repair on full-object-size CRC error There are still FileStore users and the full-object CRC might be able to catch silently returned data errors. Since we support auto-repair now, let's trigger an auto-repair process instead. Signed-off-by: xie xingguo --- src/osd/PrimaryLogPG.cc | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 99a4230da78..5778bdb54b2 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -4744,6 +4744,17 @@ int PrimaryLogPG::do_read(OpContext *ctx, OSDOp& osd_op) { } else { int r = pgbackend->objects_read_sync( soid, op.extent.offset, op.extent.length, op.flags, &osd_op.outdata); + // whole object? can we verify the checksum? + if (r >= 0 && op.extent.length == oi.size && oi.is_data_digest()) { + uint32_t crc = osd_op.outdata.crc32c(-1); + if (oi.data_digest != crc) { + osd->clog->error() << info.pgid << std::hex + << " full-object read crc 0x" << crc + << " != expected 0x" << oi.data_digest + << std::dec << " on " << soid; + r = -EIO; // try repair later + } + } if (r == -EIO) { r = rep_repair_primary_object(soid, ctx->op); } @@ -4755,19 +4766,6 @@ int PrimaryLogPG::do_read(OpContext *ctx, OSDOp& osd_op) { } dout(10) << " read got " << r << " / " << op.extent.length << " bytes from obj " << soid << dendl; - - // whole object? can we verify the checksum? - if (op.extent.length == oi.size && oi.is_data_digest()) { - uint32_t crc = osd_op.outdata.crc32c(-1); - if (oi.data_digest != crc) { - osd->clog->error() << info.pgid << std::hex - << " full-object read crc 0x" << crc - << " != expected 0x" << oi.data_digest - << std::dec << " on " << soid; - // FIXME fall back to replica or something? - result = -EIO; - } - } } // XXX the op.extent.length is the requested length for async read