Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old ioring log device #158

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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