Skip to content

Commit

Permalink
Handoff checksum Implementation (#7523)
Browse files Browse the repository at this point in the history
Summary:
in PR facebook/rocksdb#7419 , we introduce the new Append and PositionedAppend APIs to WritableFile at File System, which enable RocksDB to pass the data verification information (e.g., checksum of the data) to the lower layer. In this PR, we use the new API in WritableFileWriter, such that the file created via WritableFileWrite can pass the checksum to the storage layer. To control which types file should apply the checksum handoff, we add checksum_handoff_file_types to DBOptions. User can use this option to control which file types (Currently supported file tyes: kLogFile, kTableFile, kDescriptorFile.) should use the new Append and PositionedAppend APIs to handoff the verification information.

Pull Request resolved: facebook/rocksdb#7523

Test Plan: add new unit test, pass make check/ make asan_check

Reviewed By: pdillinger

Differential Revision: D24313271

Pulled By: zhichao-cao

fbshipit-source-id: aafd69091ae85c3318e3e17cbb96fe7338da11d0
Signed-off-by: Changlong Chen <levisonchen@live.cn>
  • Loading branch information
zhichao-cao authored and Changlong Chen committed Jun 18, 2021
1 parent 9d2963d commit 9455135
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions include/rocksdb/file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma once

#include <stdint.h>

#include <chrono>
#include <cstdarg>
#include <functional>
Expand All @@ -25,9 +26,11 @@
#include <sstream>
#include <string>
#include <vector>

#include "rocksdb/env.h"
#include "rocksdb/io_status.h"
#include "rocksdb/options.h"
#include "rocksdb/table.h"
#include "rocksdb/thread_status.h"

namespace ROCKSDB_NAMESPACE {
Expand Down Expand Up @@ -97,16 +100,22 @@ struct FileOptions : EnvOptions {
// to be issued for the file open/creation
IOOptions io_options;

FileOptions() : EnvOptions() {}
// The checksum type that is used to calculate the checksum value for
// handoff during file writes.
ChecksumType handoff_checksum_type;

FileOptions() : EnvOptions(), handoff_checksum_type(ChecksumType::kCRC32c) {}

FileOptions(const DBOptions& opts)
: EnvOptions(opts) {}
: EnvOptions(opts), handoff_checksum_type(ChecksumType::kCRC32c) {}

FileOptions(const EnvOptions& opts)
: EnvOptions(opts) {}
: EnvOptions(opts), handoff_checksum_type(ChecksumType::kCRC32c) {}

FileOptions(const FileOptions& opts)
: EnvOptions(opts), io_options(opts.io_options) {}
: EnvOptions(opts),
io_options(opts.io_options),
handoff_checksum_type(opts.handoff_checksum_type) {}

FileOptions& operator=(const FileOptions& opts) = default;
};
Expand Down Expand Up @@ -740,10 +749,14 @@ class FSWritableFile {
virtual IOStatus Append(const Slice& data, const IOOptions& options,
IODebugContext* dbg) = 0;

// EXPERIMENTAL / CURRENTLY UNUSED
// Append data with verification information
// Append data with verification information.
// Note that this API change is experimental and it might be changed in
// the future. Currently, RocksDB does not use this API.
// the future. Currently, RocksDB only generates crc32c based checksum for
// the file writes when the checksum handoff option is set.
// Expected behavior: if the handoff_checksum_type in FileOptions (currently,
// ChecksumType::kCRC32C is set as default) is not supported by this
// FSWritableFile, the information in DataVerificationInfo can be ignored
// (i.e. does not perform checksum verification).
virtual IOStatus Append(const Slice& data, const IOOptions& options,
const DataVerificationInfo& /* verification_info */,
IODebugContext* dbg) {
Expand Down Expand Up @@ -777,10 +790,14 @@ class FSWritableFile {
return IOStatus::NotSupported("PositionedAppend");
}

// EXPERIMENTAL / CURRENTLY UNUSED
// PositionedAppend data with verification information.
// Note that this API change is experimental and it might be changed in
// the future. Currently, RocksDB does not use this API.
// the future. Currently, RocksDB only generates crc32c based checksum for
// the file writes when the checksum handoff option is set.
// Expected behavior: if the handoff_checksum_type in FileOptions (currently,
// ChecksumType::kCRC32C is set as default) is not supported by this
// FSWritableFile, the information in DataVerificationInfo can be ignored
// (i.e. does not perform checksum verification).
virtual IOStatus PositionedAppend(
const Slice& /* data */, uint64_t /* offset */,
const IOOptions& /*options*/,
Expand Down

0 comments on commit 9455135

Please sign in to comment.