]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ReplicatedPG: Add verify checksum for SPARSE_READ.
authorJianpeng Ma <jianpeng.ma@intel.com>
Mon, 14 Sep 2015 05:53:06 +0000 (13:53 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Fri, 18 Sep 2015 06:44:50 +0000 (14:44 +0800)
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/osd/ReplicatedPG.cc

index ce65cbd1c1c516a98e61a244ffbe5c64defc5a9e..6e3b10155362f3ecb09aa89af2878e641b69bbbf 100644 (file)
@@ -3968,7 +3968,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
       } else {
        // read into a buffer
        bufferlist bl;
-        int total_read = 0;
+        uint32_t total_read = 0;
        int r = osd->store->fiemap(coll, ghobject_t(soid, ghobject_t::NO_GEN,
                                                    info.pgid.shard),
                                   op.extent.offset, op.extent.length, bl);
@@ -4027,6 +4027,22 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
           break;
         }
 
+       // Why SPARSE_READ need checksum? In fact, librbd always use sparse-read. 
+       // Maybe at first, there is no much whole objects. With continued use, more and more whole object exist.
+       // So from this point, for spare-read add checksum make sense.
+       if (total_read == oi.size && oi.is_data_digest()) {
+         uint32_t crc = data_bl.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;
+           break;
+         }
+       }
+
         op.extent.length = total_read;
 
         ::encode(m, osd_op.outdata); // re-encode since it might be modified