Skip to content
Draft
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 docs/ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ These are fundamental asynchronous operations. Many of them are asynchronous ver
- `condy::async_fixed_fd_install()`
- `condy::async_ftruncate()`
- `condy::async_cmd_discard()`
- `condy::async_cmd_zone_reset_all()`
- `condy::async_bind()`
- `condy::async_listen()`
- `condy::async_epoll_ctl()`
Expand Down Expand Up @@ -135,6 +136,7 @@ These asynchronous operations accept the index of a file registered with the ker
- `condy::async_cmd_getsockname()`
- `condy::async_ftruncate()`
- `condy::async_cmd_discard()`
- `condy::async_cmd_zone_reset_all()`
- `condy::async_bind()`
- `condy::async_listen()`

Expand Down
11 changes: 11 additions & 0 deletions include/condy/async_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,17 @@ inline auto async_cmd_discard(Fd fd, uint64_t offset, uint64_t nbytes) {
}
#endif

#if CONDY_URING_VERSION_GE(2, 16) // >= 2.16
/**
* @brief See io_uring_prep_cmd_zone_reset_all
*/
template <FdLike Fd>
inline auto async_cmd_zone_reset_all(Fd fd) {
auto op = detail::make_op_awaiter(io_uring_prep_cmd_zone_reset_all, fd);
return detail::maybe_flag_fixed_fd(std::move(op), fd);
}
#endif

#if CONDY_URING_VERSION_GE(2, 7) // >= 2.7
/**
* @brief See io_uring_prep_bind
Expand Down
3 changes: 3 additions & 0 deletions module/condy.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ using condy::async_cmd_getsockname;
using condy::async_nop128;
using condy::async_uring_cmd128;
#endif
#if CONDY_URING_VERSION_GE(2, 16) // >= 2.16
using condy::async_cmd_zone_reset_all;
#endif

} // namespace condy

Expand Down
45 changes: 45 additions & 0 deletions tests/test_async_operations.4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,51 @@ TEST_CASE("test async_operations - test cmd_discard - fixed fd") {
}
#endif

#if CONDY_URING_VERSION_GE(2, 16) // >= 2.16
TEST_CASE("test async_operations - test cmd_zone_reset_all - basic") {
BlkDevice blkdev;
if (blkdev.path().empty()) {
MESSAGE("Can't create loop device, skipping");
return;
}

int fd = open(blkdev.path().c_str(), O_RDWR);
REQUIRE(fd >= 0);

auto func = [&]() -> condy::Coro<void> {
int r = co_await condy::async_cmd_zone_reset_all(fd);
REQUIRE(r == 0);
};
condy::sync_wait(func());
close(fd);
}
#endif

#if CONDY_URING_VERSION_GE(2, 16) // >= 2.16
TEST_CASE("test async_operations - test cmd_zone_reset_all - fixed fd") {
BlkDevice blkdev;
if (blkdev.path().empty()) {
MESSAGE("Can't create loop device, skipping");
return;
}

int fd = open(blkdev.path().c_str(), O_RDWR);
REQUIRE(fd >= 0);

auto func = [&]() -> condy::Coro<void> {
auto &fd_table = condy::current_runtime().fd_table();
fd_table.init(1);
int r = co_await condy::async_files_update(&fd, 1, 0);
REQUIRE(r == 1);

r = co_await condy::async_cmd_zone_reset_all(condy::fixed(0));
REQUIRE(r == 0);
};
condy::sync_wait(func());
close(fd);
}
#endif

#if CONDY_URING_VERSION_GE(2, 7) // >= 2.7
TEST_CASE("test async_operations - test bind - basic") {
int sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
Expand Down
Loading