From: Sage Weil Date: Tue, 29 Sep 2015 02:18:43 +0000 (-0400) Subject: log_writer: conditionally adjust crc X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=19003513862bcd7bc1fe86f196025b4fb8f49ff2;p=rocksdb.git log_writer: conditionally adjust crc --- diff --git a/db/log_writer.cc b/db/log_writer.cc index eeb0844f..aba862c1 100644 --- a/db/log_writer.cc +++ b/db/log_writer.cc @@ -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));