### Run SPDK Examples Source: https://github.com/alibaba/photonlibos/blob/main/examples/spdk/README.md Commands to execute bdev and NVMe examples, requiring root privileges. ```shell # run bdev example sudo ./build/examples-output/bdev-example --json ./examples/spdk/bdev.json # run nvme example # change trid to yours sudo ./build/examples-output/nvme-example "trtype:pcie traddr:0000:86:00.0" sudo ./build/examples-output/nvme-example "trtype:tcp adrfam:ipv4 traddr:127.0.0.1 trsvcid:4420 subnqn:nqn.2016-06.io.spdk:cnode1" # for nvmf ``` -------------------------------- ### Install Dependencies Source: https://github.com/alibaba/photonlibos/blob/main/doc/README.md Install Node.js and Yarn, then install project-specific dependencies within the doc directory. ```bash $ brew install node yarn # Configure npm mirror/registry in advance $ cd doc/ $ npm install ``` -------------------------------- ### Install System Prerequisites Source: https://github.com/alibaba/photonlibos/blob/main/AGENTS.md Commands to install necessary development libraries and tools on Debian/Ubuntu, RHEL/CentOS/Fedora, and macOS. ```bash sudo apt-get install git cmake libssl-dev libcurl4-openssl-dev libaio-dev zlib1g-dev libgtest-dev libgmock-dev libgflags-dev libfuse-dev libgsasl7-dev nasm ``` ```bash sudo dnf install git cmake openssl-devel libcurl-devel libaio-devel zlib-devel gtest-devel gmock-devel gflags-devel fuse-devel gsasl-devel nasm ``` ```bash brew install cmake openssl@1.1 pkg-config gflags googletest gsasl nasm ``` -------------------------------- ### Build and Install DPDK Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-29-photon-dpdk.md Compile and install DPDK with Mellanox PMD support enabled. ```shell CONFIG_RTE_LIBRTE_MLX5_PMD=y meson -Denable_kmods=true -Dtests=false build cd build ninja ninja install ``` -------------------------------- ### Start Local Development Server Source: https://github.com/alibaba/photonlibos/blob/main/doc/README.md Launch the local development server to preview changes with live reloading. ```bash $ yarn start ``` -------------------------------- ### Configure HTTP and RPC Examples Source: https://github.com/alibaba/photonlibos/blob/main/examples/CMakeLists.txt Defines build targets for HTTP client/server and RPC client/server examples. ```cmake add_executable(http-perf-client perf/http/http-client.cpp) target_link_libraries(http-perf-client PRIVATE photon_static) add_executable(http-perf-server perf/http/http-server.cpp) target_link_libraries(http-perf-server PRIVATE photon_static) add_executable(rpc-example-client rpc/client.cpp rpc/client_main.cpp) target_link_libraries(rpc-example-client PRIVATE photon_static) add_executable(rpc-example-server rpc/server.cpp rpc/server_main.cpp) target_link_libraries(rpc-example-server PRIVATE photon_static) ``` -------------------------------- ### Build and Run Photon DPDK Demo Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-29-photon-dpdk.md Compile the PhotonLibOS DPDK example and execute the demo application. ```shell cd PhotonLibOS git checkout release/0.8 cmake -B build -D PHOTON_BUILD_TESTING=1 -D PHOTON_ENABLE_FSTACK_DPDK=1 -D CMAKE_BUILD_TYPE=Release cmake --build build -j 32 -t fstack-dpdk-demo ./build/output/fstack-dpdk-demo ``` -------------------------------- ### Build and Install F-Stack Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-29-photon-dpdk.md Configure environment variables and build F-Stack libraries. ```bash export FF_PATH=/root/f-stack-1.22.1 # Change to your own dir export REGULAR_PKG_CONFIG_DIR=/usr/lib64/pkgconfig/ export DPDK_PKG_CONFIG_DIR=/usr/local/lib64/pkgconfig/ export PKG_CONFIG_PATH=$(pkg-config --variable=pc_path pkg-config):${REGULAR_PKG_CONFIG_DIR}:${DPDK_PKG_CONFIG_DIR} cd f-stack-1.22/lib make -j make install ``` ```bash export FF_PATH=/root/f-stack-1.22.1 # Change to your own dir cd f-stack-1.22/lib make -j make install ``` -------------------------------- ### Usage examples for thread_create11 Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/thread.md Examples showing how to use thread_create11 with global functions, functors, and member functions. ```cpp double func(int a, char b); auto th = photon::thread_create11(func, 1, '2'); ``` ```cpp int a = 1; char b = '2'; auto th = photon::thread_create11([&] { // Access a and b }); ``` ```cpp class A { void func(int a, char b); void run() { photon::thread_create11(&A::func, this, 1, '2'); } }; ``` -------------------------------- ### Install build dependencies Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/introduction/how-to-build.md Install required system packages for building the project on different operating systems. ```bash dnf install git gcc-c++ cmake dnf install openssl-devel libcurl-devel libaio-devel zlib-devel ``` ```bash apt install git cmake apt install libssl-dev libcurl4-openssl-dev libaio-dev zlib1g-dev ``` ```bash brew install cmake openssl@1.1 pkg-config ``` -------------------------------- ### Configure CMakeLists.txt for Photon Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/introduction/how-to-integrate.md Initial setup for integrating the Photon repository using FetchContent or a local submodule. ```cmake cmake_minimum_required(VERSION 3.14 FATAL_ERROR) # Suppose this is your existing project project(my_project) # Set some options internally used in Photon set(PHOTON_ENABLE_URING OFF CACHE INTERNAL "Enable iouring") set(PHOTON_CXX_STANDARD 14 CACHE INTERNAL "C++ standard") # 1. Fetch Photon repo with specific tag or branch include(FetchContent) FetchContent_Declare( photon GIT_REPOSITORY https://github.com/alibaba/PhotonLibOS.git GIT_TAG main ) FetchContent_MakeAvailable(photon) # 2. Submodule add_subdirectory(photon) ``` -------------------------------- ### Configure installation rules for headers and libraries Source: https://github.com/alibaba/photonlibos/blob/main/CMakeLists.txt Specifies the destination directories for header files, static archives, and shared objects during the installation process. ```cmake install(DIRECTORY ${PROJECT_BINARY_DIR}/include/ DESTINATION include) install(FILES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libphoton.a DESTINATION lib) install(PROGRAMS ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libphoton.so DESTINATION lib) ``` -------------------------------- ### Verify Mellanox Driver Installation Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-29-photon-dpdk.md Starts the MST service and verifies device status and VF configuration. ```shell # Start Mellanox Software Tools Service mst start # Show device name and port mapping mst status ibdev2netdev # Check firmware capabilities mlxconfig -d /dev/mst/mt4117_pciconf0 query | grep NUM_OF_VFS # Set VF number. Should succeed now echo 4 > /sys/class/net/enp3s0f0/device/sriov_numvfs lspci -nn | grep 'Ethernet controller' ``` -------------------------------- ### Build and run tests Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/introduction/how-to-build.md Install testing dependencies, enable testing during the build process, and execute the test suite. ```bash # Install additional dependencies # Note that for the latest RHEL-like OS, libgsasl-devel has changed to cyrus-sasl-devel dnf install epel-release dnf config-manager --set-enabled powertools dnf install gtest-devel gmock-devel gflags-devel fuse-devel libgsasl-devel nasm # Build examples and test code cmake -B build -D PHOTON_BUILD_TESTING=ON cmake --build build -j 8 # Run all test cases cd build ctest ``` ```bash # Install additional dependencies apt install libgtest-dev libgmock-dev libgflags-dev libfuse-dev libgsasl7-dev nasm # Build examples and test code cmake -B build -D PHOTON_BUILD_TESTING=ON cmake --build build -j 8 # Run all test cases cd build ctest ``` ```bash # Install additional dependencies brew install gflags googletest gsasl nasm # Build examples and test code cmake -B build -D OPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 -D PHOTON_BUILD_TESTING=ON cmake --build build -j 8 # Run all test cases cd build ctest ``` -------------------------------- ### Configure Synchronization and VDMA Examples Source: https://github.com/alibaba/photonlibos/blob/main/examples/CMakeLists.txt Defines build targets for synchronization primitives and VDMA transfer examples. ```cmake add_executable(sync-primitive sync-primitive/sync-primitive.cpp) target_link_libraries(sync-primitive PRIVATE photon_static) add_executable(vdma-example vdma-transfer/vdma-example.cpp) target_link_libraries(vdma-example PRIVATE photon_static) ``` -------------------------------- ### Configure GFlags and Basic Executables Source: https://github.com/alibaba/photonlibos/blob/main/examples/CMakeLists.txt Sets up GFlags dependencies and defines the basic simple example executable. ```cmake link_libraries(${GFLAGS_LIBRARIES}) include_directories(${GFLAGS_INCLUDE_DIRS}) add_executable(simple-example simple/simple.cpp) target_link_libraries(simple-example PRIVATE photon_static) ``` -------------------------------- ### Install Dependencies Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-29-photon-dpdk.md Installs required packages for building and managing Mellanox drivers. ```shell yum install python-devel tcl tk elfutils-libelf-devel createrepo_c ``` -------------------------------- ### Configure F-Stack DPDK and SPDK Examples Source: https://github.com/alibaba/photonlibos/blob/main/examples/CMakeLists.txt Defines conditional build targets for F-Stack DPDK and SPDK-based storage examples. ```cmake if (PHOTON_ENABLE_FSTACK_DPDK) add_executable(fstack-dpdk-demo fstack-dpdk/fstack-dpdk-demo.cpp) target_link_libraries(fstack-dpdk-demo PRIVATE ${DPDK_LIBRARIES} ${FSTACK_LIBRARIES} photon_static) endif () if (PHOTON_ENABLE_SPDK) add_executable(bdev-example spdk/bdev_read_write.cpp) target_link_libraries(bdev-example PRIVATE ${DPDK_LIBRARIES} ${SPDK_LIBRARIES} photon_static) add_executable(nvme-example spdk/nvme_read_write.cpp) target_link_libraries(nvme-example PRIVATE ${DPDK_LIBRARIES} ${SPDK_LIBRARIES} photon_static) add_executable(bdev_photon_server spdk/bdev_module/bdev_photon_server_main.cpp spdk/bdev_module/bdev_photon_server.cpp) target_link_libraries(bdev_photon_server PRIVATE ${DPDK_LIBRARIES} ${SPDK_LIBRARIES} photon_static) endif () ``` -------------------------------- ### Create a TCP Socket Server Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/introduction/write-first-example.md Sets up a TCP server with a handler to process incoming socket streams and starts the event loop. ```cpp #include auto server = photon::net::new_tcp_socket_server(); if (server == nullptr) { LOG_ERRNO_RETURN(0, -1, "failed to create tcp server"); } DEFER(delete server); auto handler = [&](photon::net::ISocketStream* stream) -> int { char buf[1024]; ssize_t ret = stream->recv(buf, 1024); if (ret <= 0) { LOG_ERRNO_RETURN(0, -1, "failed to read socket"); } return 0; }; server->set_handler(handler); server->bind_v4localhost(9527); server->listen(); LOG_INFO("Server is listening for port ` ...", 9527); server->start_loop(true); ``` -------------------------------- ### Run the TCP echo server Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/performance/network-performance.md Starts the performance test server on the specified port with a defined buffer size. ```bash ./build/output/net-perf -port 9527 -buf_size 512 ``` -------------------------------- ### C++ Standard and Platform Setup Source: https://github.com/alibaba/photonlibos/blob/main/CMakeLists.txt Configures C++ standard requirements and defines a custom Linux flag. ```cmake set(CMAKE_CXX_STANDARD ${PHOTON_CXX_STANDARD}) if (WIN32) set(CMAKE_CXX_STANDARD 17) endif () set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) # CMake has no built-in LINUX flag (unlike WIN32 / APPLE) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") set(LINUX TRUE) endif () ``` -------------------------------- ### Build and Install MLNX_OFED Driver Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-29-photon-dpdk.md Installs the Mellanox OFED driver with DPDK support and updates the initramfs. ```shell cd MLNX_OFED_LINUX-5.4-3.6.8.1-rhel7.2-x86_64/ ./mlnxofedinstall --skip-distro-check --add-kernel-support --without-mlnx-nvme --dpdk # Update initramfs dracut -f # There will be rdma-core, rdma-core-devel, librdmacm and librdmacm-utils. rpm -qa | grep rdma ``` -------------------------------- ### Sequence Generator Implementation Source: https://github.com/alibaba/photonlibos/blob/main/doc/static/blog-20241014/stackful-coroutine-made-fast.html Example of a generator function and its consumer using the GPromise and Generator abstractions. ```cpp u64 seq(GCTX* fp, u64 c) { GPromise gp(fp); while(c) gp.yield(c--); return 0; } u64 sum_seq(u64 c) { u64 sum = 0; Generator g(&seq, c); for (; g; g.resume()) sum += g.value(); return sum; } ``` -------------------------------- ### Example of creating multiple coroutines Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/thread.md Demonstrates creating 2000 sleeping coroutines to show memory usage behavior. ```cpp int main() { photon::init(); for (int i = 0; i < 2000; ++i) { photon::thread_create11([]{ photon::thread_usleep(-1UL); }); } photon::thread_usleep(-1UL); } ``` -------------------------------- ### Initialize Photon WorkPool Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/std-compatible-api.md Demonstrates the initialization and cleanup of the Photon environment and a global WorkPool using the std-compatible API. ```cpp int main() { photon::init(event_engine, io_engine); DEFER(photon::fini()); photon_std::work_pool_init(8, event_engine, io_engine); DEFER(photon_std::work_pool_fini()); } ``` -------------------------------- ### Install DPDK Dependencies Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-29-photon-dpdk.md Install required packages for DPDK compilation on CentOS 7 or Debian 10. ```bash cd f-stack-1.22.1/dpdk/ yum install python3-pip yum install pkg-config numactl-devel zlib-devel ninja pip3 install meson ``` ```bash cd f-stack-1.22.1/dpdk/ pip3 install ninja meson apt install pkg-config python3-pyelftools libnuma-dev ``` -------------------------------- ### Initialize Photon Environment Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/introduction/write-first-example.md Initializes the Photon environment and ensures cleanup using the DEFER macro. ```cpp #include #include int main() { int ret = photon::init(photon::INIT_EVENT_DEFAULT, photon::INIT_IO_NONE); if (ret != 0) { return -1; } DEFER(photon::fini()); // ... } ``` -------------------------------- ### Build Photon with Ecosystem Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/ecosystem/overview.md Commands to configure and build the project with the ecosystem modules enabled. ```bash cmake -B build -D PHOTON_BUILD_TESTING=ON -D PHOTON_ENABLE_ECOSYSTEM=ON cmake --build build -j 8 ``` -------------------------------- ### Compile Photon with SPDK Source: https://github.com/alibaba/photonlibos/blob/main/examples/spdk/README.md Commands to configure and build the project with SPDK and testing enabled. ```shell cd /path/to/photon cmake -B build -DPHOTON_ENABLE_SPDK=ON -DPHOTON_BUILD_TESTING=ON make -C build -j 8 ``` -------------------------------- ### Invoking a Delegate Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/delegate_callback.md Example of a function that processes files by invoking a provided delegate. ```cpp void ProcessFiles(vector fileNames, OpenCallback opencb) { for (auto& fileName : fileNames) { auto file = opencb(fileName, "r"); // invoke the delegate // ... delete file; } } ``` -------------------------------- ### Defining a Delegate Type Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/delegate_callback.md Example of defining a specific delegate type for file operations. ```cpp class File; using OpenCallback = Delegate ; ``` -------------------------------- ### Get thread vCPU Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/thread.md Retrieves the vCPU associated with the specified thread, defaulting to the current thread. ```cpp vcpu_base* get_vcpu(thread* th = CURRENT); ``` -------------------------------- ### Build Project Source: https://github.com/alibaba/photonlibos/blob/main/AGENTS.md Command to compile the project using the configured build directory. ```bash cmake --build build -j 8 # Output: build/output/ ``` -------------------------------- ### Create Thread Pools Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/thread.md Demonstrates creating thread pools using both heap and stack allocation. ```cpp // on heap auto p1 = photon::ThreadPoolBase::new_thread_pool(100); auto th1 = p1->thread_create(&func, nullptr); // on stack photon::ThreadPool<400> p2; auto th2 = p2.thread_create(&func, nullptr); ``` -------------------------------- ### Initialize libcurl IO Engine Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/network.md Required initialization step to enable libcurl as an IO engine for asynchronous HTTP requests. ```cpp photon::init(INIT_EVENT_DEFAULT, INIT_IO_LIBCURL); ``` -------------------------------- ### Create Local Filesystem Adaptors Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/filesystem-and-io.md Factory functions for initializing local filesystem instances and opening files with specific I/O engines. ```cpp IFileSystem* new_localfs_adaptor(const char* root_path, int io_engine_type); IFile* open_localfile_adaptor(const char* filename, int flags, mode_t mode, int io_engine_type); ``` -------------------------------- ### Statically build all third-party libraries Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/introduction/how-to-build.md Configures a build that compiles all dependencies from source to ensure portability of the resulting binary. ```bash cmake -B build -D CMAKE_BUILD_TYPE=RelWithDebInfo \ -D PHOTON_BUILD_TESTING=ON \ -D PHOTON_BUILD_DEPENDENCIES=ON \ -D PHOTON_ENABLE_URING=ON \ -D PHOTON_AIO_SOURCE=https://pagure.io/libaio/archive/libaio-0.3.113/libaio-0.3.113.tar.gz \ -D PHOTON_ZLIB_SOURCE=https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.gz \ -D PHOTON_URING_SOURCE=https://github.com/axboe/liburing/archive/refs/tags/liburing-2.3.tar.gz \ -D PHOTON_CURL_SOURCE=https://github.com/curl/curl/releases/download/curl-7_88_1/curl-7.88.1.tar.gz \ -D PHOTON_OPENSSL_SOURCE=https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz \ -D PHOTON_GFLAGS_SOURCE=https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz \ -D PHOTON_GOOGLETEST_SOURCE=https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz \ -D PHOTON_BUILD_OCF_CACHE=ON ``` -------------------------------- ### Remove Existing RDMA Packages Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-29-photon-dpdk.md Lists and removes existing RDMA-related RPM packages to prevent installation conflicts. ```shell rpm -qa | grep rdma rpm -e ... ``` -------------------------------- ### new_extfs Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/filesystem-and-io.md Creates a userspace ext2/ext3/ext4 filesystem instance. ```APIDOC ## IFileSystem* new_extfs(IFile* underlying_file) ### Description Creates a userspace ext filesystem instance backed by an underlying file. ### Parameters - **underlying_file** (IFile*) - Required - The file object providing the underlying storage. ``` -------------------------------- ### Run Tests Source: https://github.com/alibaba/photonlibos/blob/main/AGENTS.md Command to execute the test suite from the build directory. ```bash cd build && ctest ``` -------------------------------- ### Interleaved CRC32C Calculation Source: https://github.com/alibaba/photonlibos/blob/main/common/checksum/crc.md Example of dividing input data into three portions to utilize instruction pipelining for CRC32C. ```text c1 = CRC32C(0, 'a'); c2 = CRC32C(0, 'Q'); c3 = CRC32C(0, 'w'); c1 = CRC32C(c1, 'b'); c2 = CRC32C(c2, 'W'); c3 = CRC32C(c3, 'x'); c1 = CRC32C(c1, 'c'); c2 = CRC32C(c2, 'E'); c3 = CRC32C(c3, 'y'); c1 = CRC32C(c1, 'c'); c2 = CRC32C(c2, 'R'); c3 = CRC32C(c3, 'y'); return shift(c1, 8*8) xor shift(c2, 4*8) xor c3; ``` -------------------------------- ### Initialize Photon Environment Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/env.md Initializes the coroutine stack on the current vCPU. Blocking function calls should be avoided after initialization. ```cpp int photon::init(uint64_t event_engine = INIT_EVENT_DEFAULT, uint64_t io_engine = INIT_IO_DEFAULT); ``` -------------------------------- ### Get WorkPool vCPU count Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/vcpu-and-multicore.md Retrieve the number of vCPUs managed by the WorkPool, excluding the main OS thread. ```cpp int get_vcpu_num(); ``` -------------------------------- ### Create and use localfs adaptor in C++ Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/filesystem-and-io.md Initializes a local filesystem adaptor and performs file operations using the provided interface. ```cpp auto fs = photon::fs::new_localfs_adaptor(".", photon::fs::ioengine_psync); if (!fs) { LOG_ERRNO_RETURN(0, -1, "failed to create fs"); } DEFER(delete fs); auto file = fs->open("test-file", O_WRONLY | O_CREAT | O_TRUNC, 0644); if (!file) { LOG_ERRNO_RETURN(0, -1, "failed to open file"); } DEFER(delete file); ssize_t n_written = file->write(buf, 4096); ``` -------------------------------- ### Verify GCC and Kernel Version Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-29-photon-dpdk.md Checks the installed GCC version and kernel version to ensure compatibility with driver compilation. ```shell gcc --version cat /proc/version ``` -------------------------------- ### Migrate thread to vCPU manually Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/vcpu-and-multicore.md Initialize the Photon environment within a new OS thread and migrate a specific thread to a target vCPU. ```cpp std::thread([]{ photon::init(); DEFER(photon::fini()); auto th = photon::thread_create11(func); photon::thread_migrate(th, vcpu); }).detach(); ``` -------------------------------- ### Include Photon HTTP Headers Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/network.md Header files for the native, dependency-free Photon HTTP framework. ```cpp #include #include ``` -------------------------------- ### Configure Persistent Network Interface Names Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-29-photon-dpdk.md Defines udev rules to ensure network interface names remain consistent after driver installation. ```text # PCI device 15b3:1019 (mlx5_core) # NAME:="some name" , := is used to make sure that device name will be persistent. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:02:c9:fa:c3:50", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME:="eth0" SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:02:c9:fa:c3:51", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME:="eth1" ``` -------------------------------- ### Initialize Project and Requirements Source: https://github.com/alibaba/photonlibos/blob/main/CMakeLists.txt Sets the minimum CMake version and defines the project name, version, and supported languages. ```cmake cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project( photon VERSION 0.8 LANGUAGES C CXX ASM ) # for CMake 4.x compatible set(CMAKE_POLICY_VERSION_MINIMUM 3.5) ``` -------------------------------- ### Standard C++ thread_local usage Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-28-thread-local.md A basic example demonstrating the standard C++11 thread_local keyword behavior where variables are isolated per thread. ```c++ #include static thread_local int i = 0; int main() { auto th = std::thread([]{ i = 1; }); th.join(); assert(i == 0); } ``` -------------------------------- ### Configure Project with CMake Source: https://github.com/alibaba/photonlibos/blob/main/AGENTS.md CMake configuration commands for Linux and macOS environments. ```bash # Linux cmake -B build -D PHOTON_BUILD_TESTING=ON -D CMAKE_BUILD_TYPE=MinSizeRel # macOS cmake -B build -D PHOTON_BUILD_TESTING=ON -D CMAKE_BUILD_TYPE=MinSizeRel -D PHOTON_CXX_STANDARD=17 -D OPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 ``` -------------------------------- ### Create Photon Threads Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/introduction/write-first-example.md Demonstrates various methods for spawning threads using photon_std::thread, including global functions, lambdas, and class member functions. ```cpp // Global function int func(int a, char* b) {} // Use global function to create a thread. // Will be automatically joined when thread object destructed, unless been detached. photon_std::thread th(func, 1, '2'); th.detach(); // Create a thread with anonymous function (lambda) photon_std::thread th([&] { // Access variables directly in the context }); // Create a thread with class member function class A { void f() { new photon_std::thread(&A::g, this, 1, '2'); } void g(int a, char* b) {} }; ``` -------------------------------- ### Run Photon IO performance test Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/performance/file-io-performance.md Executes the Photon IO performance test program on a specified disk device. ```bash ./io-perf --disk_path=/dev/nvme0n1 --disk_size=3000000000000 --io_depth=128 --io_size=4096 --io_uring ``` -------------------------------- ### Build Static Content Source: https://github.com/alibaba/photonlibos/blob/main/doc/README.md Generate the static website files in the build directory for production hosting. ```bash $ yarn build ``` -------------------------------- ### photon::init Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/env.md Initializes the coroutine stack on the current vCPU and configures event and IO engines. ```APIDOC ## int photon::init(uint64_t event_engine, uint64_t io_engine) ### Description Initialize the coroutine stack on current vCPU. After calling this, you can create multiple Photon threads and migrate them to other vCPUs. Blocking function calls should not be invoked after initialization. ### Parameters - **event_engine** (uint64_t) - Optional - The event engine to use (e.g., INIT_EVENT_DEFAULT, INIT_EVENT_EPOLL, INIT_EVENT_IOURING, INIT_EVENT_KQUEUE). - **io_engine** (uint64_t) - Optional - The IO engine to use (e.g., INIT_IO_NONE, INIT_IO_LIBAIO, INIT_IO_LIBCURL, INIT_IO_SOCKET_EDGE_TRIGGER, INIT_IO_EXPORTFS, INIT_IO_FSTACK_DPDK). ### Return - Returns 0 on success, -1 on error. ``` -------------------------------- ### Configure Build Testing and Dependencies Source: https://github.com/alibaba/photonlibos/blob/main/CMakeLists.txt Sets up runtime output directories, includes CTest, and defines library dependencies for test components when PHOTON_BUILD_TESTING is enabled. ```cmake if (PHOTON_BUILD_TESTING) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/examples-output) add_subdirectory(examples) include(CTest) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output) include(generate-ctest-packed-script) add_library(ci-tools OBJECT test/ci-tools.cpp) target_include_directories(ci-tools PRIVATE include) target_include_directories(photon_shared PUBLIC ${CURL_INCLUDE_DIRS} ${GFLAGS_INCLUDE_DIRS} ${GOOGLETEST_INCLUDE_DIRS}) target_link_libraries(photon_shared PUBLIC ${CURL_LIBRARIES} ${GFLAGS_LIBRARIES} ${GOOGLETEST_LIBRARIES}) target_compile_definitions(photon_obj PRIVATE CURL_STATICLIB) link_libraries(ci-tools) add_subdirectory(common/checksum/test) add_subdirectory(common/test) add_subdirectory(common/memory-stream/test) add_subdirectory(common/executor/test) add_subdirectory(fs/test) add_subdirectory(io/test) add_subdirectory(net/test) add_subdirectory(net/http/test) add_subdirectory(rpc/test) add_subdirectory(thread/test) add_subdirectory(net/security-context/test) if (NOT APPLE) add_subdirectory(fs/cache/test) endif() if (PHOTON_ENABLE_ECOSYSTEM) add_subdirectory(ecosystem/test) endif () if (PHOTON_ENABLE_EXTFS) add_subdirectory(fs/extfs/test) endif () if (PHOTON_ENABLE_RSOCKET) add_subdirectory(net/rsocket/test) endif () GenerateStandaloneCTestScript(${CMAKE_SOURCE_DIR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CTestTestfile.cmake) endif () ``` -------------------------------- ### Configure Checksum Test Executable Source: https://github.com/alibaba/photonlibos/blob/main/common/checksum/test/CMakeLists.txt Sets up the test-checksum executable with platform-specific assembly files and links the photon_shared library. ```cmake set(TEST_WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/) add_definitions(-DDATA_DIR=${TEST_WORKING_DIR}) if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) enable_language(ASM_NASM) add_executable(test-checksum test_checksum.cpp crc32_iscsi_00.asm crc64_ecma_refl_by8.asm) else() add_executable(test-checksum test_checksum.cpp crc32_iscsi_crc_ext.S crc64_ecma_refl_pmull.S) endif() target_link_libraries(test-checksum PRIVATE photon_shared) add_test(NAME test-checksum COMMAND $) ``` -------------------------------- ### Run fio performance test Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/performance/file-io-performance.md Executes the fio benchmark tool to measure random read performance on a raw device partition. ```bash fio --filename=/dev/nvme0n1p1 --direct=1 --ioengine=libaio --iodepth=128 --rw=randread --bs=4k --size=100% --group_reporting --name=randread --numjobs=1 ``` -------------------------------- ### Configure PhotonLibOS Source Files Source: https://github.com/alibaba/photonlibos/blob/main/CMakeLists.txt Collects core source files and conditionally appends platform-specific I/O implementations and optional feature modules. ```cmake file(GLOB PHOTON_SRC RELATIVE "${PROJECT_SOURCE_DIR}" photon.cpp common/*.cpp common/checksum/*.cpp common/executor/*.cpp common/memory-stream/*.cpp fs/aligned-file.cpp fs/async_filesystem.cpp fs/exportfs.cpp fs/filecopy.cpp fs/localfs.cpp fs/path.cpp fs/subfs.cpp fs/throttled-file.cpp fs/virtual-file.cpp fs/xfile.cpp fs/httpfs/*.cpp io/reset_handle.cpp net/*.cpp net/http/*.cpp net/http/huffman/*.cpp net/http/websocket.cpp net/security-context/tls-stream.cpp net/vdma/*.cpp rpc/*.cpp thread/*.cpp ) if (APPLE) list(APPEND PHOTON_SRC io/kqueue.cpp io/signal.cpp) elseif (WIN32) list(APPEND PHOTON_SRC io/iocp.cpp) else () file(GLOB CACHE_SRC fs/cache/*.cpp fs/cache/full_file_cache/*.cpp fs/cache/persistent_cache/*.cpp ) list(APPEND PHOTON_SRC io/aio-wrapper.cpp io/epoll.cpp io/epoll-ng.cpp io/signal.cpp ${CACHE_SRC} ) if (PHOTON_ENABLE_URING) list(APPEND PHOTON_SRC io/iouring-wrapper.cpp) endif () endif () if (PHOTON_ENABLE_FUSE STREQUAL "ON" OR PHOTON_ENABLE_FUSE STREQUAL "2" OR PHOTON_ENABLE_FUSE STREQUAL "3") file(GLOB FUSE_ADAPTOR_SRC fs/fuse_adaptor/*.cpp) list(APPEND PHOTON_SRC ${FUSE_ADAPTOR_SRC}) endif () if (PHOTON_ENABLE_SASL) list(APPEND PHOTON_SRC net/security-context/sasl-stream.cpp) endif () if (PHOTON_ENABLE_FSTACK_DPDK) list(APPEND PHOTON_SRC io/fstack-dpdk.cpp) endif () if (PHOTON_ENABLE_SPDK) list(APPEND PHOTON_SRC io/spdkbdev-wrapper.cpp io/spdknvme-wrapper.cpp) endif () if (PHOTON_ENABLE_EXTFS) file(GLOB EXTFS_SRC fs/extfs/*.cpp) if (NOT PHOTON_ENABLE_RESIZE) list(REMOVE_ITEM EXTFS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/fs/extfs/resize.cpp") endif() list(APPEND PHOTON_SRC ${EXTFS_SRC}) endif () if (PHOTON_ENABLE_ECOSYSTEM) file(GLOB ECOSYSTEM_SRC ecosystem/*.cpp) list(APPEND PHOTON_SRC ${ECOSYSTEM_SRC}) endif () if (NOT PHOTON_ENABLE_KCP) list(REMOVE_ITEM PHOTON_SRC net/kcp.cpp) endif () if (PHOTON_ENABLE_RSOCKET) list(APPEND PHOTON_SRC net/rsocket/rsocket.cpp) endif () if (NOT ${PHOTON_ENABLE_LIBCURL}) list(REMOVE_ITEM PHOTON_SRC net/curl.cpp fs/httpfs/httpfs.cpp) endif () if (PHOTON_BUILD_OCF_CACHE) add_subdirectory(fs/cache/ocf_cache) endif() ``` -------------------------------- ### Configure Build Options Source: https://github.com/alibaba/photonlibos/blob/main/CMakeLists.txt Defines various build-time options and feature toggles for the Photon library. ```cmake set(PHOTON_CXX_STANDARD "14" CACHE STRING "C++ standard") option(PHOTON_BUILD_TESTING "enable build testing" OFF) option(PHOTON_BUILD_WITH_ASAN "build with asan" OFF) option(PHOTON_ENABLE_URING "enable io_uring function" OFF) set(PHOTON_ENABLE_FUSE "OFF" CACHE STRING "enable fuse version, OFF for disable, ON/2 for libfuse2, 3 for libfuse3") option(PHOTON_GLOBAL_INIT_OPENSSL "Turn this off if any of your third-party libs inits old-version OpenSSL as well, because Photon will register coroutine locks for crypto. But don't bother if you have latest OpenSSL >= 1.1.0" ON) option(PHOTON_ENABLE_SASL "enable sasl" OFF) option(PHOTON_ENABLE_MIMIC_VDSO "enable mimic vdso" OFF) option(PHOTON_ENABLE_FSTACK_DPDK "Use f-stack + DPDK as the event engine" OFF) option(PHOTON_ENABLE_SPDK "Use SPDK bdev && nvme concept" OFF) option(PHOTON_ENABLE_EXTFS "enable extfs" OFF) option(PHOTON_ENABLE_RESIZE "enable resize_extfs (requires external resize_fs)" OFF) option(PHOTON_ENABLE_ECOSYSTEM "enable ecosystem" OFF) option(PHOTON_ENABLE_RSOCKET "enable rsocket" OFF) option(PHOTON_ENABLE_LIBCURL "enable libcurl" ON) set(PHOTON_DEFAULT_LOG_LEVEL "0" CACHE STRING "default log level") option(PHOTON_BUILD_OCF_CACHE "enable ocf cache" OFF) option(PHOTON_ENABLE_KCP "enable kcp" OFF) ``` -------------------------------- ### photon::fs::new_localfs_adaptor Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/filesystem-and-io.md Creates a new local filesystem adaptor instance. ```APIDOC ## photon::fs::new_localfs_adaptor ### Description Creates a new local filesystem adaptor for the specified root directory using the provided IO engine. ### Signature `photon::fs::IFileSystem* new_localfs_adaptor(const char* root, ioengine_t engine)` ### Parameters - **root** (const char*) - Required - The root directory path for the filesystem. - **engine** (ioengine_t) - Required - The IO engine to use (e.g., photon::fs::ioengine_psync). ``` -------------------------------- ### Build the network performance test program Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/performance/network-performance.md Configures and builds the net-perf executable using CMake with io_uring support enabled. ```cmake cmake -B build -D PHOTON_BUILD_TESTING=1 -D PHOTON_ENABLE_URING=1 -D CMAKE_BUILD_TYPE=Release cmake --build build -j 8 -t net-perf ``` -------------------------------- ### Create a TCP Socket Client Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/introduction/write-first-example.md Initializes a TCP client, connects to a specified endpoint, and sends data through the stream. ```cpp #include auto client = photon::net::new_tcp_socket_client(); if (client == nullptr) { LOG_ERRNO_RETURN(0, -1, "failed to create tcp client"); } DEFER(delete client); photon::net::EndPoint ep("127.0.0.1:9527"); auto stream = client->connect(ep); if (!stream) { LOG_ERRNO_RETURN(0, -1, "failed to connect server"); } DEFER(delete stream); // Send data to socket char buf[1024]; if (stream->send(buf, 1024) != 1024) { LOG_ERRNO_RETURN(0, -1, "failed to write socket"); } ``` -------------------------------- ### Build the project Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/introduction/how-to-build.md Compile the project using CMake. Note that macOS requires specifying the OpenSSL root directory. ```bash cd PhotonLibOS cmake -B build cmake --build build -j 8 ``` ```bash cd PhotonLibOS cmake -B build -D OPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 cmake --build build -j 8 ``` -------------------------------- ### Deploy to GitHub Pages Source: https://github.com/alibaba/photonlibos/blob/main/doc/README.md Deploy the site to GitHub Pages using either SSH or a specified GitHub user. ```bash $ USE_SSH=true yarn deploy ``` ```bash $ GIT_USER=photonlibos yarn deploy ``` -------------------------------- ### Link Photon to Libraries Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/introduction/how-to-integrate.md Patterns for integrating Photon into static or shared library projects. ```cmake add_library(my_lib STATIC ${SOURCES}) target_link_libraries(my_lib PRIVATE photon_static) ``` ```cmake add_library(my_lib SHARED ${SOURCES}) target_link_libraries(my_lib PRIVATE -Wl,--whole-archive libphoton.a -Wl,--no-whole-archive) ``` -------------------------------- ### Build Optimization and Environment Settings Source: https://github.com/alibaba/photonlibos/blob/main/CMakeLists.txt Sets optimization levels and project-wide build properties. ```cmake set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -DNDEBUG -g") set(CMAKE_CXX_FLAGS_MINSIZEREL "-O2 -march=native") # Only for CI test set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_BUILD_RPATH_USE_ORIGIN ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) ``` -------------------------------- ### Define Photon Static Library Source: https://github.com/alibaba/photonlibos/blob/main/CMakeLists.txt Creates the photon_static library from object files and configures its include directories and link dependencies. ```cmake add_library(photon_static STATIC $) 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 PRIVATE ${static_deps} PUBLIC ${shared_deps} ) ``` -------------------------------- ### photon_std::work_pool_init Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/std-compatible-api.md Initializes a global WorkPool for managing threads across vCPUs. ```APIDOC ## work_pool_init ### Description Initializes a global WorkPool to manage thread execution across multiple vCPUs. ### Usage `photon_std::work_pool_init(size_t n, event_engine_t* ev, io_engine_t* io);` ``` -------------------------------- ### Enable IOMMU on Debian 10 Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-29-photon-dpdk.md Configures GRUB to enable IOMMU for SR-IOV support on Debian 10 systems. ```bash # Edit /etc/default/grub # Expand GRUB_CMDLINE_LINUX with 'intel_iommu=on iommu=pt' grub-mkconfig -o /boot/grub/grub.cfg reboot ``` -------------------------------- ### Clone the repository Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/introduction/how-to-build.md Download the source code from the official GitHub repository. ```bash git clone https://github.com/alibaba/PhotonLibOS.git ``` -------------------------------- ### Enable IOMMU on CentOS 7 Source: https://github.com/alibaba/photonlibos/blob/main/doc/blog/2023-07-29-photon-dpdk.md Configures GRUB to enable IOMMU for SR-IOV support on CentOS 7 systems. ```bash # Edit /etc/default/grub # Expand GRUB_CMDLINE_LINUX with 'intel_iommu=on iommu=pt pci=realloc' grub2-mkconfig -o /boot/grub2/grub.cfg reboot ``` -------------------------------- ### Include Photon Headers Source: https://github.com/alibaba/photonlibos/blob/main/AGENTS.md Standard practice for including PhotonLibOS headers in C++ source files. ```cpp #include #include #include #include ``` -------------------------------- ### Raw IO Wrappers Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/filesystem-and-io.md Direct IO operations for libaio, posixaio, and io_uring. ```APIDOC ## Raw IO Wrappers ### Description Low-level wrappers for asynchronous IO operations including libaio, posixaio, and io_uring. ### libaio/posixaio - `libaio_pread(int fd, void *buf, size_t count, off_t offset)` - `libaio_pwrite(int fd, const void *buf, size_t count, off_t offset)` - `posixaio_pread(int fd, void *buf, size_t count, off_t offset)` - `posixaio_pwrite(int fd, const void *buf, size_t count, off_t offset)` ### io_uring - `iouring_pread(int fd, void* buf, size_t count, off_t offset, uint64_t timeout)` - `iouring_pwrite(int fd, const void* buf, size_t count, off_t offset, uint64_t timeout)` - `iouring_send(int fd, const void* buf, size_t len, int flags, uint64_t timeout)` - `iouring_recv(int fd, void* buf, size_t len, int flags, uint64_t timeout)` - `iouring_open(const char* path, int flags, mode_t mode)` ``` -------------------------------- ### Select Photon Thread Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/miscellaneous/debugging.md Switch the currently selected thread context using photon_fr. ```gdb (gdb) photon_fr 3 [Switching to Thread 3, 0xaaab0ed44030 (SLEEP) vCPU 1 (0xaaab0e9b4e00)] (gdb) photon_fr Current selected thread: 3 ``` -------------------------------- ### Resolve and Build Dependencies Source: https://github.com/alibaba/photonlibos/blob/main/CMakeLists.txt Iterates through the dependency list to either find pre-installed packages or build them from source. ```cmake FOREACH (dep ${dependencies}) message(STATUS "Checking dependency ${dep}") string(TOUPPER ${dep} DEP) set(source_url "${PHOTON_${DEP}_SOURCE}") if (dep STREQUAL "kcp") message(STATUS "Will build ${dep} from source") message(STATUS " URL: ${source_url}") build_from_src(dep) elseif (PHOTON_BUILD_DEPENDENCIES AND (NOT source_url STREQUAL "")) message(STATUS "Will build ${dep} from source") message(STATUS " URL: ${source_url}") build_from_src(dep) else () message(STATUS "Will find ${dep}") find_package(${dep} REQUIRED) endif () endforeach () ``` -------------------------------- ### WorkPool Constructor Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/vcpu-and-multicore.md Initialize a WorkPool to manage multiple vCPUs with specified event and IO engines. ```cpp WorkPool(size_t vcpu_num, int ev_engine = 0, int io_engine = 0, int thread_mod = -1); ``` -------------------------------- ### Perform File I/O Operations Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/introduction/write-first-example.md Initializes a local file system adaptor and performs write operations on a file. ```cpp #include auto fs = photon::fs::new_localfs_adaptor(".", photon::fs::ioengine_psync); if (!fs) { LOG_ERRNO_RETURN(0, -1, "failed to create fs"); } DEFER(delete fs); auto file = fs->open("test-file", O_WRONLY | O_CREAT | O_TRUNC, 0644); if (!file) { LOG_ERRNO_RETURN(0, -1, "failed to open file"); } DEFER(delete file); ssize_t n_written = file->write(buf, 4096); ``` -------------------------------- ### Load Photon GDB Extension Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/miscellaneous/debugging.md Load the extension script within a GDB session to enable custom Photon-specific commands. ```gdb (gdb) source /tools/photongdb.py INFO Photon-GDB-extension v2 loaded INFO Commands: photon_ls, photon_fr , photon_bt [n], photon_ps, photon_current INFO Use photon_fr to select thread, then photon_bt to show its backtrace ``` -------------------------------- ### Configure OCF Environment Library Source: https://github.com/alibaba/photonlibos/blob/main/fs/cache/ocf_cache/CMakeLists.txt Initializes the OCF cache package dependency and logs the source directory path. ```cmake find_package(ocfcache REQUIRED) message(STATUS "ocf_lib_SOURCE_DIR: ${ocf_lib_SOURCE_DIR}") ``` -------------------------------- ### Raw AIO wrapper functions in C++ Source: https://github.com/alibaba/photonlibos/blob/main/doc/docs/api/filesystem-and-io.md Provides direct access to libaio and posixaio operations. Note that file descriptors must be opened with O_DIRECT and buffers must be aligned for libaio. ```cpp // `fd` must be opened with O_DIRECT, and the buffers must be aligned ssize_t libaio_pread(int fd, void *buf, size_t count, off_t offset); ssize_t libaio_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset); ssize_t libaio_pwrite(int fd, const void *buf, size_t count, off_t offset); ssize_t libaio_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset); static int libaio_fsync(int fd) { return 0; } ssize_t posixaio_pread(int fd, void *buf, size_t count, off_t offset); ssize_t posixaio_pwrite(int fd, const void *buf, size_t count, off_t offset); int posixaio_fsync(int fd); int posixaio_fdatasync(int fd); ```