Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
36 changes: 0 additions & 36 deletions env/env_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1655,42 +1655,6 @@ void GenerateFilesAndRequest(Env* env, const std::string& fname,
}
}

TEST_F(EnvPosixTest, MultiReadIOUringError) {
// In this test we don't do aligned read, so we can't do direct I/O.
EnvOptions soptions;
soptions.use_direct_reads = soptions.use_direct_writes = false;
std::string fname = test::PerThreadDBPath(env_, "testfile");

std::vector<std::string> scratches;
std::vector<ReadRequest> reqs;
GenerateFilesAndRequest(env_, fname, &reqs, &scratches);
// Query the data
std::unique_ptr<RandomAccessFile> file;
ASSERT_OK(env_->NewRandomAccessFile(fname, &file, soptions));

bool io_uring_wait_cqe_called = false;
SyncPoint::GetInstance()->SetCallBack(
"PosixRandomAccessFile::MultiRead:io_uring_wait_cqe:return",
[&](void* arg) {
if (!io_uring_wait_cqe_called) {
io_uring_wait_cqe_called = true;
ssize_t& ret = *(static_cast<ssize_t*>(arg));
ret = 1;
}
});
SyncPoint::GetInstance()->EnableProcessing();

Status s = file->MultiRead(reqs.data(), reqs.size());
if (io_uring_wait_cqe_called) {
ASSERT_NOK(s);
} else {
s.PermitUncheckedError();
}

SyncPoint::GetInstance()->DisableProcessing();
SyncPoint::GetInstance()->ClearAllCallBacks();
}

TEST_F(EnvPosixTest, MultiReadIOUringError2) {
// In this test we don't do aligned read, so we can't do direct I/O.
EnvOptions soptions;
Expand Down
21 changes: 14 additions & 7 deletions env/fs_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ class PosixFileSystem : public FileSystem {
options
#if defined(ROCKSDB_IOURING_PRESENT)
,
!IsIOUringEnabled() ? nullptr : thread_local_io_urings_.get()
!IsIOUringEnabled() ? nullptr
: thread_local_async_read_io_urings_.get(),
!IsIOUringEnabled() ? nullptr
: thread_local_multi_read_io_urings_.get()
#endif
));
}
Expand Down Expand Up @@ -1087,8 +1090,9 @@ class PosixFileSystem : public FileSystem {
#if defined(ROCKSDB_IOURING_PRESENT)
// io_uring_queue_init.
struct io_uring* iu = nullptr;
if (thread_local_io_urings_) {
iu = static_cast<struct io_uring*>(thread_local_io_urings_->Get());
if (thread_local_async_read_io_urings_) {
iu = static_cast<struct io_uring*>(
thread_local_async_read_io_urings_->Get());
}

// Init failed, platform doesn't support io_uring.
Expand Down Expand Up @@ -1161,8 +1165,9 @@ class PosixFileSystem : public FileSystem {
#if defined(ROCKSDB_IOURING_PRESENT)
// io_uring_queue_init.
struct io_uring* iu = nullptr;
if (thread_local_io_urings_) {
iu = static_cast<struct io_uring*>(thread_local_io_urings_->Get());
if (thread_local_async_read_io_urings_) {
iu = static_cast<struct io_uring*>(
thread_local_async_read_io_urings_->Get());
}

// Init failed, platform doesn't support io_uring.
Expand Down Expand Up @@ -1277,7 +1282,8 @@ class PosixFileSystem : public FileSystem {

#if defined(ROCKSDB_IOURING_PRESENT)
// io_uring instance
std::unique_ptr<ThreadLocalPtr> thread_local_io_urings_;
std::unique_ptr<ThreadLocalPtr> thread_local_async_read_io_urings_;
std::unique_ptr<ThreadLocalPtr> thread_local_multi_read_io_urings_;
#endif

size_t page_size_;
Expand Down Expand Up @@ -1337,7 +1343,8 @@ PosixFileSystem::PosixFileSystem()
// io_uring can be created.
struct io_uring* new_io_uring = CreateIOUring();
if (new_io_uring != nullptr) {
thread_local_io_urings_.reset(new ThreadLocalPtr(DeleteIOUring));
thread_local_async_read_io_urings_.reset(new ThreadLocalPtr(DeleteIOUring));
thread_local_multi_read_io_urings_.reset(new ThreadLocalPtr(DeleteIOUring));
delete new_io_uring;
}
#endif
Expand Down
Loading
Loading