Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ a8/
CMakeUserPresets.json
src/CMakeUserPresets.json
__pycache__/
compile_commands.json
.cache/
2 changes: 1 addition & 1 deletion conan.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "0.5",
"requires": [
"batteries/0.62.0",
"batteries/0.63.0",
"boost/1.88.0",
"bzip2/1.0.8",
"cli11/2.5.0",
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def requirements(self):
VISIBLE = self.cor.VISIBLE
OVERRIDE = self.cor.OVERRIDE

self.requires("batteries/[>=0.62.0 <1]", **VISIBLE)
self.requires("batteries/[>=0.63.0 <1]", **VISIBLE)
self.requires("boost/[>=1.88.0 <2]", **VISIBLE)
self.requires("cli11/[>=2.5.0 <3]", **VISIBLE)
self.requires("glog/[>=0.7.1 <1]", **VISIBLE)
Expand Down
58 changes: 40 additions & 18 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ cmake_minimum_required(VERSION 3.20)

macro(LLFS_CollectHeaders TARGET_NAME TARGET_SRCDIR)

file(GLOB_RECURSE ${TARGET_NAME}_Headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ./${TARGET_SRCDIR}/*.hpp ./${TARGET_SRCDIR}/*.ipp)

file(GLOB_RECURSE ${TARGET_NAME}_Headers
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
./${TARGET_SRCDIR}/*.hpp
./${TARGET_SRCDIR}/*.ipp)

foreach(_header IN LISTS ${TARGET_NAME}_Headers)
get_filename_component(_destination "${_header}" PATH)
install(FILES "${_header}" DESTINATION include/${_destination})
Expand All @@ -23,7 +26,7 @@ endmacro()
macro(LLFS_DefineLibrary TARGET_NAME TARGET_SRCDIR)

set(TARGET_DEPS ${ARGN})

file(GLOB ${TARGET_NAME}_LibSources
./${TARGET_SRCDIR}/*.cpp
./${TARGET_SRCDIR}/*/*.cpp
Expand All @@ -41,7 +44,7 @@ macro(LLFS_DefineLibrary TARGET_NAME TARGET_SRCDIR)
./${TARGET_SRCDIR}/*/*/*.test.cpp
./${TARGET_SRCDIR}/*/*/*/*.test.cpp
)

foreach (_file "FORCE_LIST_NOT_EMPTY;${${TARGET_NAME}_TestSources}")
list(REMOVE_ITEM ${TARGET_NAME}_LibSources ${_file})
endforeach ()
Expand All @@ -51,18 +54,11 @@ macro(LLFS_DefineLibrary TARGET_NAME TARGET_SRCDIR)
add_library(${TARGET_NAME} ${${TARGET_NAME}_LibSources})
target_link_libraries(${TARGET_NAME} ${TARGET_DEPS})

# Define unit test target
#
add_executable(${TARGET_NAME}_Test ${${TARGET_NAME}_TestSources} ./common/test_environment.cpp)
target_link_libraries(
${TARGET_NAME}_Test
${TARGET_NAME}
${TARGET_DEPS}
set(EXTRA_TEST_DEPS
GTest::gtest
GTest::gtest_main
GTest::gmock
GTest::gmock_main
libfuse::libfuse
OpenSSL::Crypto
Boost::context
Boost::stacktrace_backtrace
Expand All @@ -71,6 +67,20 @@ macro(LLFS_DefineLibrary TARGET_NAME TARGET_SRCDIR)
dl
stdc++fs)

if (LINUX)
set(EXTRA_TEST_DEPS ${EXTRA_TEST_DEPS} libfuse::libfuse)
endif()

# Define unit test target
#
add_executable(${TARGET_NAME}_Test ${${TARGET_NAME}_TestSources} ./common/test_environment.cpp)
target_link_libraries(
${TARGET_NAME}_Test
${TARGET_NAME}
${TARGET_DEPS}
${EXTRA_TEST_DEPS}
)

add_test(NAME ${TARGET_NAME}_Test
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
COMMAND ${TARGET_NAME}_Test)
Expand Down Expand Up @@ -100,12 +110,18 @@ endmacro()
# Library definitions.
#

LLFS_DefineLibrary(llfs ./llfs
set(LLFS_Deps
batteries::batteries
liburing::liburing
OpenSSL::Crypto
xxHash::xxhash
)
)

if (LINUX)
set(LLFS_Deps ${LLFS_Deps} liburing::liburing)
endif()


LLFS_DefineLibrary(llfs ./llfs ${LLFS_Deps})

#=#=#==#==#===============+=+=+=+=++=++++++++++++++-++-+--+-+----+---------------

Expand Down Expand Up @@ -149,14 +165,20 @@ file(GLOB llfs_fuse_Sources

add_executable(llfs_fuse ${llfs_fuse_Sources})

target_link_libraries(llfs_fuse
set(LLFS_TestDeps
llfs
libfuse::libfuse
batteries::batteries
Boost::context
Boost::stacktrace_backtrace
libbacktrace::libbacktrace
OpenSSL::Crypto
CLI11::CLI11
dl
stdc++fs)
stdc++fs
)

if (LINUX)
set(LLFS_TestDeps ${LLFS_TestDeps} libfuse::libfuse)
endif()

target_link_libraries(llfs_fuse ${LLFS_TestDeps})
132 changes: 132 additions & 0 deletions src/llfs/page_allocate_options.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
//#=##=##=#==#=#==#===#+==#+==========+==+=+=+=+=+=++=+++=+++++=-++++=-+++++++++++
//
// Part of the LLFS Project, under Apache License v2.0.
// See https://www.apache.org/licenses/LICENSE-2.0 for license information.
// SPDX short identifier: Apache-2.0
//
//+++++++++++-+-+--+----- --- -- - - - -

#pragma once
#define LLFS_PAGE_ALLOCATE_OPTIONS_HPP

#include <llfs/config.hpp>
//
#include <llfs/optional.hpp>
#include <llfs/page_cache_insert_options.hpp>
#include <llfs/page_layout_id.hpp>

#include <batteries/async/cancel_token.hpp>
#include <batteries/async/types.hpp>

#include <batteries/operators.hpp>

#include <memory>

namespace llfs {

struct PageAllocateOptions : PageCacheInsertOptions {
using Self = PageAllocateOptions;
using Super = PageCacheInsertOptions;

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

static const batt::CancelToken& no_cancel_token()
{
static const batt::CancelToken token_{None};
return token_;
}

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

Optional<PageLayoutId> page_layout_id_ = None;

batt::WaitForResource wait_for_resource_ = batt::WaitForResource::kFalse;

const batt::CancelToken* cancel_token_ = std::addressof(Self::no_cancel_token());

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

/** \brief Constructs a PageAllocateOptions with default values.
*/
PageAllocateOptions() = default;

/** \brief Constructs a copy of the given options.
*/
PageAllocateOptions(const PageAllocateOptions&) = default;

/** \brief Copies the passed options to *this, overwriting all set values.
*/
PageAllocateOptions& operator=(const PageAllocateOptions&) = default;

/** \brief Constructs a PageAllocateOptions object from typed arguments; these may be in any
* order.
*/
template <typename... Args, typename = batt::EnableIfNoShadow<Self, Args...>>
explicit PageAllocateOptions(Args&&... args) noexcept
: Super{BATT_FORWARD(args)...}
, page_layout_id_{batt::get_typed_arg(Optional<PageLayoutId>{None}, BATT_FORWARD(args)...)}
, wait_for_resource_{batt::get_typed_arg(batt::WaitForResource::kFalse,
BATT_FORWARD(args)...)}
, cancel_token_{std::addressof(batt::get_typed_arg<const batt::CancelToken&>(
Self::no_cancel_token(), BATT_FORWARD(args)...))}
{
static_assert(decltype(batt::has_typed_arg<PageLayoutId>(BATT_FORWARD(args)...)){});
static_assert(decltype(batt::has_typed_arg<batt::WaitForResource>(BATT_FORWARD(args)...)){});
}

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

/** \brief Returns a copy of this.
*/
Self clone() const
{
return *this;
}

//----- --- -- - - - -

Self& page_layout_id(const Optional<PageLayoutId>& opt_layout)
{
this->page_layout_id_ = opt_layout;
return *this;
}

const PageLayoutId& page_layout_id() const
{
BATT_CHECK(this->page_layout_id_);
return *this->page_layout_id_;
}

//----- --- -- - - - -

Self& wait_for_resource(batt::WaitForResource val)
{
this->wait_for_resource_ = val;
return *this;
}

batt::WaitForResource wait_for_resource() const
{
return this->wait_for_resource_;
}

//----- --- -- - - - -

Self& cancel_token(const batt::CancelToken& val)
{
this->cancel_token_ = std::addressof(val);
return *this;
}

const batt::CancelToken& cancel_token() const
{
return *this->cancel_token_;
}
};

//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -

BATT_OBJECT_PRINT_IMPL((inline), PageAllocateOptions,
(wait_for_resource(), page_size(), page_layout_id(), lru_priority()))

} // namespace llfs
Loading