read_write_util.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. //
  6. // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  7. // Use of this source code is governed by a BSD-style license that can be
  8. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  9. #include "file/read_write_util.h"
  10. #include <sstream>
  11. #include "test_util/sync_point.h"
  12. namespace ROCKSDB_NAMESPACE {
  13. IOStatus NewWritableFile(FileSystem* fs, const std::string& fname,
  14. std::unique_ptr<FSWritableFile>* result,
  15. const FileOptions& options) {
  16. TEST_SYNC_POINT_CALLBACK("NewWritableFile::FileOptions.temperature",
  17. const_cast<Temperature*>(&options.temperature));
  18. IOStatus s = fs->NewWritableFile(fname, options, result, nullptr);
  19. TEST_KILL_RANDOM_WITH_WEIGHT("NewWritableFile:0", REDUCE_ODDS2);
  20. return s;
  21. }
  22. #ifndef NDEBUG
  23. bool IsFileSectorAligned(const size_t off, size_t sector_size) {
  24. return off % sector_size == 0;
  25. }
  26. #endif // NDEBUG
  27. } // namespace ROCKSDB_NAMESPACE