Skip to content

Commit

Permalink
Remove old ioring log device (#158)
Browse files Browse the repository at this point in the history
* Delete obsolete files.

* Add more metrics to IoRingLogDevice2 and verify them in the sim test.
  • Loading branch information
tonyastolfi authored Aug 1, 2024
1 parent 758d7ee commit 82c299c
Show file tree
Hide file tree
Showing 57 changed files with 222 additions and 6,366 deletions.
7 changes: 7 additions & 0 deletions src/llfs/confirm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@
#ifndef LLFS_CONFIRM_HPP
#define LLFS_CONFIRM_HPP

#include <ostream>

namespace llfs {

enum struct ConfirmThisWillEraseAllMyData : bool {
kNo = false,
kYes = true,
};

inline std::ostream& operator<<(std::ostream& out, const ConfirmThisWillEraseAllMyData& t)
{
return out << (bool)t;
}

} // namespace llfs

#endif // LLFS_CONFIRM_HPP
54 changes: 0 additions & 54 deletions src/llfs/ioring_log_config.cpp

This file was deleted.

110 changes: 0 additions & 110 deletions src/llfs/ioring_log_config.hpp

This file was deleted.

23 changes: 23 additions & 0 deletions src/llfs/ioring_log_config2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

#include <llfs/log_device_config2.hpp>

#include <batteries/checked_cast.hpp>
#include <batteries/math.hpp>

namespace llfs {

//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
Expand All @@ -27,4 +30,24 @@ namespace llfs {
};
}

//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
//
/*static*/ IoRingLogConfig2 IoRingLogConfig2::from_logical_size(u64 logical_size,
Optional<u64> opt_device_page_size,
Optional<u64> opt_data_alignment)
{
const u64 device_page_size = opt_device_page_size.value_or(Self::kDefaultDevicePageSize);
const u64 data_alignment = opt_data_alignment.value_or(Self::kDefaultDataAlignment);

const i32 device_page_size_log2 = batt::log2_ceil(device_page_size);
const i32 data_alignment_log2 = batt::log2_ceil(data_alignment);

return IoRingLogConfig2{
.control_block_offset = 0,
.log_capacity = batt::round_up_bits(data_alignment_log2, logical_size),
.device_page_size_log2 = BATT_CHECKED_CAST(u16, device_page_size_log2),
.data_alignment_log2 = BATT_CHECKED_CAST(u16, data_alignment_log2),
};
}

} //namespace llfs
30 changes: 29 additions & 1 deletion src/llfs/ioring_log_config2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,35 @@

#include <llfs/file_offset_ptr.hpp>
#include <llfs/int_types.hpp>
#include <llfs/ioring_log_config2.hpp>
#include <llfs/interval.hpp>

namespace llfs {

struct PackedLogDeviceConfig2;

struct IoRingLogConfig2 {
using Self = IoRingLogConfig2;

//+++++++++++-+-+--+----- --- -- - - - -

static constexpr usize kDefaultDevicePageSize = 512;
static constexpr usize kDefaultDataAlignment = 4096;

static constexpr u16 kDefaultDevicePageSizeLog2 = 9 /*=log2(512)*/;
static constexpr u16 kDefaultDataAlignmentLog2 = 12 /*=log2(4096)*/;

static_assert((usize{1} << Self::kDefaultDevicePageSizeLog2) == Self::kDefaultDevicePageSize);
static_assert((usize{1} << Self::kDefaultDataAlignmentLog2) == Self::kDefaultDataAlignment);

//+++++++++++-+-+--+----- --- -- - - - -

static IoRingLogConfig2 from_packed(
const FileOffsetPtr<const PackedLogDeviceConfig2&>& packed_config);

static IoRingLogConfig2 from_logical_size(u64 logical_size,
Optional<u64> opt_device_page_size = None,
Optional<u64> opt_data_alignment = None);

//+++++++++++-+-+--+----- --- -- - - - -

i64 control_block_offset;
Expand All @@ -38,6 +57,15 @@ struct IoRingLogConfig2 {
{
return i64{1} << this->data_alignment_log2;
}

Interval<i64> offset_range() const noexcept
{
return Interval<i64>{
.lower_bound = this->control_block_offset,
.upper_bound = this->control_block_offset + this->control_block_size() +
static_cast<i64>(this->log_capacity),
};
}
};

} //namespace llfs
Expand Down
20 changes: 0 additions & 20 deletions src/llfs/ioring_log_device.cpp

This file was deleted.

Loading

0 comments on commit 82c299c

Please sign in to comment.