Coverage Report

Created: 2026-08-14 08:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rocksdb/file/read_write_util.cc
Line
Count
Source
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
10
#include "file/read_write_util.h"
11
12
#include <cassert>
13
#include <sstream>
14
15
#include "test_util/sync_point.h"
16
17
namespace ROCKSDB_NAMESPACE {
18
19
IOStatus NewWritableFile(FileSystem* fs, const std::string& fname,
20
                         std::unique_ptr<FSWritableFile>* result,
21
140k
                         const FileOptions& options) {
22
140k
  TEST_SYNC_POINT_CALLBACK("NewWritableFile::FileOptions.temperature",
23
140k
                           const_cast<Temperature*>(&options.temperature));
24
140k
  IOStatus s = fs->NewWritableFile(fname, options, result, nullptr);
25
140k
  TEST_KILL_RANDOM_WITH_WEIGHT("NewWritableFile:0", REDUCE_ODDS2);
26
140k
  return s;
27
140k
}
28
29
IOStatus GetFileSizeFromOpenFileOrPath(
30
    FSRandomAccessFile* file, FileSystem* fs, const std::string& fname,
31
    uint64_t* file_size, IODebugContext* dbg, FileSizeFallback fallback,
32
121k
    BeforePathFileSizeFallback before_path_fallback) {
33
121k
  assert(file != nullptr);
34
121k
  assert(fs != nullptr);
35
121k
  assert(file_size != nullptr);
36
37
121k
  IOStatus s = file->GetFileSize(file_size);
38
121k
  if (s.ok()) {
39
121k
    return s;
40
121k
  }
41
42
18.4E
  if (fallback == FileSizeFallback::kAnyOpenFileError || s.IsNotSupported()) {
43
0
    if (before_path_fallback != nullptr) {
44
0
      before_path_fallback();
45
0
    }
46
0
    return fs->GetFileSize(fname, IOOptions(), file_size, dbg);
47
0
  }
48
49
18.4E
  return s;
50
18.4E
}
51
52
#ifndef NDEBUG
53
bool IsFileSectorAligned(const size_t off, size_t sector_size) {
54
  return off % sector_size == 0;
55
}
56
#endif  // NDEBUG
57
}  // namespace ROCKSDB_NAMESPACE