Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
19 changes: 17 additions & 2 deletions src/plugins/posix/posix_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ nixlPosixBackendReqH::checkXfer() {

nixl_status_t
nixlPosixBackendReqH::postXfer() {
if (!io_queue_) {
Comment thread
aknvda marked this conversation as resolved.
Outdated
NIXL_ERROR << "POSIX I/O queue is not initialized";
return NIXL_ERR_BACKEND;
}

num_confirmed_ios_ = 0;

for (auto [local_it, remote_it] = std::make_pair(local.begin(), remote.begin());
Expand Down Expand Up @@ -240,6 +245,12 @@ nixlPosixEngine::nixlPosixEngine(const nixlBackendInitParams *init_params)
NIXL_ERROR << "Failed to initialize POSIX backend - no supported io queue type found";
return;
}
if (!io_queue_) {
initErr = true;
NIXL_ERROR << "Failed to initialize POSIX backend - unavailable io queue type requested: "
<< io_queue_type_;
return;
}
NIXL_INFO << absl::StrFormat("POSIX backend initialized using io queue type: %s",
io_queue_type_);
}
Expand Down Expand Up @@ -332,9 +343,13 @@ nixlPosixEngine::checkXfer(nixlBackendReqH *handle) const {

nixl_status_t
nixlPosixEngine::releaseReqH(nixlBackendReqH *handle) const {
if (!handle) {
return NIXL_SUCCESS;
}

try {
auto &posix_handle = castPosixHandle(handle);
posix_handle.~nixlPosixBackendReqH();
(void)castPosixHandle(handle);
Comment thread
aknvda marked this conversation as resolved.
Outdated
delete handle;
return NIXL_SUCCESS;
}
catch (const nixlPosixBackendReqH::exception &e) {
Expand Down
62 changes: 37 additions & 25 deletions test/unit/plugins/posix/meson.build
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Using globally defined has_posix_plugin from the root meson.build
if has_posix_plugin
nixl_posix_app = executable('nixl_posix_test', 'nixl_posix_test.cpp',
dependencies: [nixl_dep, nixl_infra, absl_log_dep],
include_directories: [nixl_inc_dirs, utils_inc_dirs],
install: true)

# Register the test with the test suite
test('posix_plugin_test', nixl_posix_app)
endif
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Using globally defined has_posix_plugin from the root meson.build
if has_posix_plugin
posix_test_compile_defs = []
if has_linux_aio
posix_test_compile_defs += ['-DHAVE_LINUXAIO']
endif
if has_io_uring
posix_test_compile_defs += ['-DHAVE_LIBURING']
endif
Comment thread
aknvda marked this conversation as resolved.
if has_posix_aio
posix_test_compile_defs += ['-DHAVE_POSIXAIO']
endif

nixl_posix_app = executable('nixl_posix_test', 'nixl_posix_test.cpp',
dependencies: [nixl_dep, nixl_infra, absl_log_dep],
include_directories: [nixl_inc_dirs, utils_inc_dirs],
cpp_args: posix_test_compile_defs,
install: true)

# Register the test with the test suite
test('posix_plugin_test', nixl_posix_app)
endif
64 changes: 53 additions & 11 deletions test/unit/plugins/posix/nixl_posix_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,40 @@ namespace {
return std::string((line_width - str.length()) / 2, ' ') + str;
}

bool
has_supported_test_queue(bool use_uring) {
if (use_uring) {
#ifdef HAVE_LIBURING
return true;
#else
return false;
#endif
}

#if defined(HAVE_LINUXAIO) || defined(HAVE_LIBURING)
return true;
#else
return false;
#endif
}

void
print_unsupported_test_queue_error(bool use_uring) {
std::cerr << "Unsupported POSIX test queue configuration: ";
if (use_uring) {
std::cerr << "io_uring was requested, but this build does not include liburing support."
<< std::endl;
} else {
std::cerr << "this build does not include Linux AIO or io_uring support." << std::endl;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
#ifdef HAVE_POSIXAIO
std::cerr
<< "POSIX AIO may be available in the plugin, but this test requires Linux AIO "
"or io_uring."
<< std::endl;
#endif
}
}

constexpr char default_test_files_dir_path[] = "tmp/testfiles";

// Custom deleter for posix_memalign allocated memory
Expand Down Expand Up @@ -217,8 +251,8 @@ read_write_test (int num_transfers,
params["use_uring"] = "true";
params["use_aio"] = "false";
} else {
// Explicitly request AIO
params["use_aio"] = "true";
// Use the backend's compiled default queue. Startup validation rejects POSIX AIO-only
// builds.
params["use_uring"] = "false";
}

Expand All @@ -234,7 +268,7 @@ read_write_test (int num_transfers,
std::cout << absl::StrFormat ("- Total data: %.2f GB\n",
(float (transfer_size) * num_transfers) / gb_size);
std::cout << absl::StrFormat ("- Directory: %s\n", test_files_dir_path_abs_path);
std::cout << absl::StrFormat ("- Backend: %s\n", use_uring ? "io_uring" : "AIO");
std::cout << absl::StrFormat("- Backend: %s\n", use_uring ? "io_uring" : "default");
std::cout << absl::StrFormat ("- Direct I/O: %s\n", use_direct_io ? "enabled" : "disabled");
std::cout << std::endl;
std::cout << line_str << std::endl;
Expand All @@ -246,9 +280,12 @@ read_write_test (int num_transfers,
std::cerr << std::endl << line_str << std::endl;
std::cerr << center_str("ERROR: Backend Creation Failed") << std::endl;
std::cerr << line_str << std::endl;
std::cerr << "Error creating POSIX backend: " << nixlEnumStrings::statusStr(status) << std::endl;
std::cerr << "Error creating POSIX backend: " << nixlEnumStrings::statusStr(status)
<< std::endl;
if (use_uring) {
std::cerr << "io_uring was requested but may not be available. Try running without -U flag to use AIO instead." << std::endl;
std::cerr << "io_uring was requested but may not be available. Try running without -U "
"flag to use the default queue."
<< std::endl;
}
std::cerr << std::endl << line_str << std::endl;
return 1;
Expand Down Expand Up @@ -498,8 +535,8 @@ test_posix_repost (std::string test_files_dir_path_abs_path, bool use_uring) {
params["use_uring"] = "true";
params["use_aio"] = "false";
} else {
// Explicitly request AIO
params["use_aio"] = "true";
// Use the backend's compiled default queue. Startup validation rejects POSIX AIO-only
// builds.
params["use_uring"] = "false";
}

Expand Down Expand Up @@ -779,17 +816,22 @@ main (int argc, char *argv[]) {
" -s transfer_size Size of each transfer in bytes (default: %zu)",
default_transfer_size)
<< std::endl;
std::cout << absl::StrFormat (" -d test_files_dir_path Directory for test files, "
"strongly recommended to use nvme device (default: %s)",
default_test_files_dir_path)
std::cout << absl::StrFormat(" -d test_files_dir_path Directory for test files, "
"strongly recommended to use nvme device (default: %s)",
default_test_files_dir_path)
<< std::endl;
std::cout << absl::StrFormat (" -D Use O_DIRECT for file I/O") << std::endl;
std::cout << absl::StrFormat (" -U Use io_uring backend instead of AIO") << std::endl;
std::cout << absl::StrFormat(" -U Explicitly use the io_uring backend") << std::endl;
std::cout << absl::StrFormat (" -h Show this help message") << std::endl;
return (opt == 'h') ? 0 : 1;
}
}

if (!has_supported_test_queue(use_uring)) {
print_unsupported_test_queue_error(use_uring);
return 1;
}

// Convert directory path to absolute path using std::filesystem
std::filesystem::path test_files_dir_path_obj (test_files_dir_path);
std::filesystem::create_directories (test_files_dir_path_obj);
Expand Down
Loading