]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
log_writer: conditionally adjust crc
authorSage Weil <sage@redhat.com>
Tue, 29 Sep 2015 02:18:43 +0000 (22:18 -0400)
committerSage Weil <sage@redhat.com>
Tue, 29 Sep 2015 02:18:43 +0000 (22:18 -0400)
db/log_writer.cc

index eeb0844fd7d56020ed3fe683e2e9676c54e92dcc..aba862c16ff443ce5b0e900cd28c213af8a8c145 100644 (file)
@@ -93,8 +93,14 @@ Status Writer::EmitPhysicalRecord(RecordType t, const char* ptr, size_t n) {
 
   // Compute the crc of the record type and the payload.
   uint32_t crc = crc32c::Extend(type_crc_[t], ptr, n);
-  crc = crc32c::Mask(crc);                 // Adjust for storage
-  EncodeFixed32(buf, crc);
+  if (db_options_->recycle_log_files) {
+    uint32_t final_crc = crc ^ log_number_;              // XOR in log numb
+    final_crc = crc32c::Mask(final_crc);                 // Adjust for storage
+    EncodeFixed32(buf, final_crc);
+  } else {
+    crc = crc32c::Mask(crc);                 // Adjust for storage
+    EncodeFixed32(buf, crc);
+  }
 
   // Write the header and the payload
   Status s = dest_->Append(Slice(buf, kHeaderSize));