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

marking inode 1 inuse for extfs/mkfs #246

Closed
wants to merge 8 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.linux.arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Linux ARM

on:
push:
branches: [ "main" ]
branches: [ "main", "release/*" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "release/*" ]

jobs:
centos8-gcc921-epoll-release:
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/ci.linux.x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Linux x86

on:
push:
branches: [ "main" ]
branches: [ "main", "release/*" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "release/*" ]

jobs:
centos8-gcc921-epoll-release:
Expand Down Expand Up @@ -108,17 +108,14 @@ jobs:
run: |
dnf install -y git gcc-c++ cmake
dnf install -y gcc-toolset-9-gcc-c++
dnf install -y openssl-devel libcurl-devel
dnf install -y epel-release
dnf install -y fuse-devel libgsasl-devel e2fsprogs-devel
dnf install -y autoconf automake libtool

- name: Build
run: |
source /opt/rh/gcc-toolset-9/enable
cmake -B build -D CMAKE_BUILD_TYPE=MinSizeRel \
-D PHOTON_BUILD_DEPENDENCIES=ON -D PHOTON_BUILD_TESTING=ON \
-D PHOTON_ENABLE_SASL=ON -D PHOTON_ENABLE_FUSE=ON \
-D PHOTON_ENABLE_EXTFS=ON \
-D PHOTON_BUILD_DEPENDENCIES=ON \
-D PHOTON_BUILD_TESTING=ON \
-D PHOTON_ENABLE_URING=ON
cmake --build build -j -- VERBOSE=1

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.macos.arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: macOS ARM

on:
push:
branches: [ "main" ]
branches: [ "main", "release/*" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "release/*" ]

jobs:
macOS-clang-debug:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: macOS

on:
push:
branches: [ "main" ]
branches: [ "main", "release/*" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "release/*" ]

jobs:
macOS-12-Monterey-debug:
Expand Down
48 changes: 47 additions & 1 deletion CMake/build-from-src.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Note: Be aware of the differences between CMake project and Makefile project.
# Makefile project is not able to get BINARY_DIR at configuration.

set(actually_built)

Expand Down Expand Up @@ -53,9 +54,12 @@ function(build_from_src [dep])
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON
INSTALL_COMMAND ""
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(POSTFIX "_debug")
endif ()
ExternalProject_Get_Property(gflags BINARY_DIR)
set(GFLAGS_INCLUDE_DIRS ${BINARY_DIR}/include PARENT_SCOPE)
set(GFLAGS_LIBRARIES ${BINARY_DIR}/lib/libgflags.a ${BINARY_DIR}/lib/libgflags_nothreads.a PARENT_SCOPE)
set(GFLAGS_LIBRARIES ${BINARY_DIR}/lib/libgflags${POSTFIX}.a ${BINARY_DIR}/lib/libgflags_nothreads${POSTFIX}.a PARENT_SCOPE)

elseif (dep STREQUAL "googletest")
ExternalProject_Add(
Expand All @@ -70,6 +74,48 @@ function(build_from_src [dep])
set(GOOGLETEST_INCLUDE_DIRS ${SOURCE_DIR}/googletest/include ${SOURCE_DIR}/googlemock/include PARENT_SCOPE)
set(GOOGLETEST_LIBRARIES ${BINARY_DIR}/lib/libgmock.a ${BINARY_DIR}/lib/libgmock_main.a
${BINARY_DIR}/lib/libgtest.a ${BINARY_DIR}/lib/libgtest_main.a PARENT_SCOPE)

elseif (dep STREQUAL "openssl")
set(BINARY_DIR ${PROJECT_BINARY_DIR}/openssl-build)
ExternalProject_Add(
openssl
URL ${PHOTON_OPENSSL_SOURCE}
URL_MD5 bad68bb6bd9908da75e2c8dedc536b29
BUILD_IN_SOURCE ON
CONFIGURE_COMMAND ./config -fPIC no-unit-test no-shared --openssldir=${BINARY_DIR} --prefix=${BINARY_DIR}
BUILD_COMMAND make depend -j ${NumCPU} && make -j ${NumCPU}
INSTALL_COMMAND make install
)
ExternalProject_Get_Property(openssl SOURCE_DIR)
set(OPENSSL_ROOT_DIR ${SOURCE_DIR} PARENT_SCOPE)
set(OPENSSL_INCLUDE_DIRS ${BINARY_DIR}/include PARENT_SCOPE)
set(OPENSSL_LIBRARIES ${BINARY_DIR}/lib/libssl.a ${BINARY_DIR}/lib/libcrypto.a PARENT_SCOPE)

elseif (dep STREQUAL "curl")
if (${OPENSSL_ROOT_DIR} STREQUAL "")
message(FATAL_ERROR "OPENSSL_ROOT_DIR not exist")
endif ()
set(BINARY_DIR ${PROJECT_BINARY_DIR}/curl-build)
ExternalProject_Add(
curl
URL ${PHOTON_CURL_SOURCE}
URL_MD5 a66270f11e3fbfad709600bbd1686704
BUILD_IN_SOURCE ON
CONFIGURE_COMMAND export CC=${CMAKE_C_COMPILER} && export CXX=${CMAKE_CXX_COMPILER} &&
export LD=${CMAKE_LINKER} && export CFLAGS=-fPIC &&
autoreconf -i && ./configure --with-ssl=${OPENSSL_ROOT_DIR}
--without-libssh2 --enable-static --enable-shared=no --enable-optimize
--disable-manual --without-libidn
--disable-ftp --disable-file --disable-ldap --disable-ldaps
--disable-rtsp --disable-dict --disable-telnet --disable-tftp
--disable-pop3 --disable-imap --disable-smb --disable-smtp
--disable-gopher --without-nghttp2 --enable-http
--with-pic=PIC --prefix=${BINARY_DIR}
BUILD_COMMAND make -j ${NumCPU}
INSTALL_COMMAND make install
)
set(CURL_INCLUDE_DIRS ${BINARY_DIR}/include PARENT_SCOPE)
set(CURL_LIBRARIES ${BINARY_DIR}/lib/libcurl.a PARENT_SCOPE)
endif ()

list(APPEND actually_built ${dep})
Expand Down
62 changes: 34 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ option(PHOTON_ENABLE_EXTFS "enable extfs" OFF)
option(PHOTON_BUILD_DEPENDENCIES "" OFF)
set(PHOTON_AIO_SOURCE "https://pagure.io/libaio/archive/libaio-0.3.113/libaio-0.3.113.tar.gz" CACHE STRING "")
set(PHOTON_ZLIB_SOURCE "https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.gz" CACHE STRING "")
set(PHOTON_OPENSSL_SOURCE "" CACHE STRING "")
set(PHOTON_CURL_SOURCE "" CACHE STRING "")
set(PHOTON_OPENSSL_SOURCE "https://github.com/openssl/openssl/archive/refs/heads/OpenSSL_1_0_2-stable.tar.gz" CACHE STRING "")
set(PHOTON_CURL_SOURCE "https://github.com/curl/curl/archive/refs/tags/curl-7_42_1.tar.gz" CACHE STRING "")
set(PHOTON_URING_SOURCE "https://github.com/axboe/liburing/archive/refs/tags/liburing-2.3.tar.gz" CACHE STRING "")
set(PHOTON_FUSE_SOURCE "" CACHE STRING "")
set(PHOTON_GSASL_SOURCE "" CACHE STRING "")
Expand Down Expand Up @@ -96,7 +96,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output)
################################################################################

# There are two ways to handle dependencies:
# 1. Find locally installed packages. (Static lib is suggested)
# 1. Find locally installed packages.
# 2. Build it from source. (Only when PHOTON_BUILD_DEPENDENCIES is set, and PHOTON_XXX_SOURCE is not empty)
#
# The naming conventions MUST obey:
Expand Down Expand Up @@ -196,21 +196,22 @@ endif ()

# An object library compiles source files but does not archive or link their object files.
add_library(photon_obj OBJECT ${PHOTON_SRC})
target_include_directories(photon_obj PUBLIC include ${OPENSSL_INCLUDE_DIRS} ${AIO_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS})
target_include_directories(photon_obj PRIVATE include ${OPENSSL_INCLUDE_DIRS} ${AIO_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS}
)
target_compile_definitions(photon_obj PRIVATE _FILE_OFFSET_BITS=64 FUSE_USE_VERSION=29)
if (PHOTON_ENABLE_URING)
target_include_directories(photon_obj PUBLIC ${URING_INCLUDE_DIRS})
target_include_directories(photon_obj PRIVATE ${URING_INCLUDE_DIRS})
target_compile_definitions(photon_obj PRIVATE PHOTON_URING=on)
endif()
if (PHOTON_ENABLE_MIMIC_VDSO)
target_compile_definitions(photon_obj PRIVATE ENABLE_MIMIC_VDSO=on)
endif()
if (PHOTON_ENABLE_FSTACK_DPDK)
target_include_directories(photon_obj PUBLIC ${FSTACK_INCLUDE_DIRS})
target_include_directories(photon_obj PRIVATE ${FSTACK_INCLUDE_DIRS})
endif()
if (PHOTON_ENABLE_EXTFS)
target_include_directories(photon_obj PUBLIC ${LIBE2FS_INCLUDE_DIRS})
target_include_directories(photon_obj PRIVATE ${LIBE2FS_INCLUDE_DIRS})
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
# This option is enabled by default after -std=c++17
Expand All @@ -226,9 +227,9 @@ endif ()
set(static_deps
easy_weak
fstack_weak
${ZLIB_LIBRARIES}
${OPENSSL_LIBRARIES}
${CURL_LIBRARIES}
${OPENSSL_LIBRARIES}
${ZLIB_LIBRARIES}
)
set(shared_deps
-lpthread
Expand Down Expand Up @@ -256,8 +257,8 @@ if (PHOTON_ENABLE_EXTFS)
list(APPEND static_deps ${E2FS_LIBRARIES})
endif ()

# It's OK to have some `shared_deps` duplicated in `static_deps`.
# Even though .a is suggested, we may still probably find .so in local installed dir.
# Find out dynamic libs and append to `shared_deps`.
# Because if not built from source, we won't know the local packages are static or shared.
# This is for the max compatability.
if (NOT APPLE)
set(suffix "\.so$")
Expand All @@ -271,9 +272,6 @@ foreach (dep ${static_deps})
break()
endif ()
endforeach ()
if (dep MATCHES "\.a$")
list(APPEND static_deps_archive ${dep})
endif ()
endforeach ()

set(version_scripts)
Expand All @@ -284,6 +282,7 @@ list(APPEND version_scripts "-Wl,--version-script=${PROJECT_SOURCE_DIR}/tools/li
# Link photon shared lib
add_library(photon_shared SHARED $<TARGET_OBJECTS:photon_obj>)
set_target_properties(photon_shared PROPERTIES OUTPUT_NAME photon)
target_include_directories(photon_shared PUBLIC include ${CURL_INCLUDE_DIRS})
if (NOT APPLE)
target_link_libraries(photon_shared
PRIVATE ${version_scripts} -Wl,--whole-archive ${static_deps} -Wl,--no-whole-archive
Expand All @@ -299,32 +298,39 @@ endif ()
# Link photon static lib
add_library(photon_static STATIC $<TARGET_OBJECTS:photon_obj>)
set_target_properties(photon_static PROPERTIES OUTPUT_NAME photon_sole)
target_include_directories(photon_static PUBLIC include ${CURL_INCLUDE_DIRS})
target_link_libraries(photon_static
PUBLIC ${shared_deps}
PRIVATE ${static_deps}
)

# Merge static libs into libphoton.a
# Do NOT use this target directly.
# Merge static libs into libphoton.a for manual distribution.
# Do NOT link to this target directly.
if (NOT APPLE)
set(merge_command ar -crT libphoton.a)
add_custom_target(_photon_static_archive ALL
COMMAND rm -rf libphoton.a
COMMAND ar -qcT libphoton.a $<TARGET_FILE:photon_static> $<TARGET_FILE:easy_weak> $<TARGET_FILE:fstack_weak>
COMMAND ar -M < ${PROJECT_SOURCE_DIR}/tools/libphoton.mri
DEPENDS photon_static
WORKING_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
VERBATIM
)
else ()
set(merge_command libtool -static -o libphoton.a)
add_custom_target(_photon_static_archive ALL
COMMAND rm -rf libphoton.a
COMMAND libtool -static -o libphoton.a $<TARGET_FILE:photon_static> $<TARGET_FILE:easy_weak> $<TARGET_FILE:fstack_weak>
DEPENDS photon_static
WORKING_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
VERBATIM
)
endif ()
add_custom_target(_photon_static_archive ALL
COMMAND rm -rf libphoton.a
COMMAND ${merge_command} $<TARGET_FILE:photon_static> $<TARGET_FILE:easy_weak> $<TARGET_FILE:fstack_weak>
DEPENDS photon_static
WORKING_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
VERBATIM
)

# Build test cases
if (PHOTON_BUILD_TESTING)
include(CTest)

set(testing_libs ${GFLAGS_LIBRARIES} ${GOOGLETEST_LIBRARIES})
include_directories(${GFLAGS_INCLUDE_DIRS} ${GOOGLETEST_INCLUDE_DIRS})
include_directories(photon_static ${GFLAGS_INCLUDE_DIRS} ${GOOGLETEST_INCLUDE_DIRS})
link_libraries(${GFLAGS_LIBRARIES} ${GOOGLETEST_LIBRARIES})

add_subdirectory(examples)
add_subdirectory(common/checksum/test)
Expand Down
4 changes: 1 addition & 3 deletions common/checksum/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
include_directories(${CMAKE_SOURCE_DIR}/include)
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
SET(TEST_WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/)
ADD_DEFINITIONS(-w -DDATA_DIR=${TEST_WORKING_DIR})

add_executable(test-checksum test_checksum.cpp)
target_link_libraries(test-checksum PRIVATE photon_shared ${testing_libs})
target_link_libraries(test-checksum PRIVATE photon_shared)
add_test(NAME test-checksum COMMAND $<TARGET_FILE:test-checksum>)
8 changes: 2 additions & 6 deletions common/estring.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,8 @@ class rstring_view // relative string_view, that stores values relative
}

public:
constexpr rstring_view() = default; // note: don't give _offset or _length
// an initial value and do not
// assigned them in default ctor()
// it would caused verb_init() error
rstring_view(uint64_t offset, uint64_t length)
{
constexpr rstring_view() = default;
constexpr rstring_view(uint64_t offset, uint64_t length) {
assert(offset <= std::numeric_limits<OffsetType>::max());
assert(length <= std::numeric_limits<LengthType>::max());
_offset = (OffsetType)offset;
Expand Down
2 changes: 1 addition & 1 deletion common/identity-pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void IdentityPoolBase::put(void* obj)
m_mtx.lock();
}
--m_refcnt;
m_cvar.notify_all();
}
m_cvar.notify_all();
assert(m_size <= m_capacity);
}

Expand Down
16 changes: 7 additions & 9 deletions common/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
include_directories(${CMAKE_SOURCE_DIR}/include)
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
SET(TEST_WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/)
ADD_DEFINITIONS(-w -DDATA_DIR=${TEST_WORKING_DIR})

add_executable(test-objcache test_objcache.cpp)
target_link_libraries(test-objcache PRIVATE photon_shared ${testing_libs})
target_link_libraries(test-objcache PRIVATE photon_shared)
add_test(NAME test-objcache COMMAND $<TARGET_FILE:test-objcache>)

add_executable(test-common test.cpp)
target_link_libraries(test-common PRIVATE photon_shared ${testing_libs})
target_link_libraries(test-common PRIVATE photon_shared)
add_test(NAME test-common COMMAND $<TARGET_FILE:test-common>)

add_executable(test-scalepool test_scalepool.cpp)
target_link_libraries(test-scalepool PRIVATE photon_shared ${testing_libs})
target_link_libraries(test-scalepool PRIVATE photon_shared)
add_test(NAME test-scalepool COMMAND $<TARGET_FILE:test-scalepool>)

add_executable(test-throttle test_throttle.cpp)
target_link_libraries(test-throttle PRIVATE photon_shared ${testing_libs})
target_link_libraries(test-throttle PRIVATE photon_shared)
add_test(NAME test-throttle COMMAND $<TARGET_FILE:test-throttle>)

add_executable(test-constexprstr test_constexprstr.cpp)
target_link_libraries(test-constexprstr PRIVATE photon_shared ${testing_libs})
target_link_libraries(test-constexprstr PRIVATE photon_shared)
add_test(NAME test-constexprstr COMMAND $<TARGET_FILE:test-constexprstr>)

#add_executable(test-lockfree test_lockfree.cpp)
#target_link_libraries(test-lockfree PRIVATE photon_shared ${testing_libs})
#target_link_libraries(test-lockfree PRIVATE photon_shared)
#add_test(NAME test-lockfree COMMAND $<TARGET_FILE:test-lockfree>)

add_executable(test-alog test_alog.cpp x.cpp)
target_link_libraries(test-alog PRIVATE photon_shared ${testing_libs})
target_link_libraries(test-alog PRIVATE photon_shared)
add_test(NAME test-alog COMMAND $<TARGET_FILE:test-alog>)
Loading