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

retrying EAGAIN from io_setup in vhost-server #2143

Merged
merged 2 commits into from
Sep 26, 2024
Merged
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
32 changes: 31 additions & 1 deletion cloud/blockstore/vhost-server/backend_aio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cloud/storage/core/libs/common/thread.h>
#include <cloud/storage/core/libs/diagnostics/logging.h>

#include <util/stream/file.h>
#include <util/system/sanitizers.h>

#include <libaio.h>
Expand Down Expand Up @@ -154,6 +155,8 @@ class TAioBackend final: public IBackend
TSimpleStats& queueStats);

void CompletionThreadFunc();

void IoSetup();
};

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -168,6 +171,33 @@ TAioBackend::TAioBackend(
Log = Logging->CreateLog("AIO");
}

void TAioBackend::IoSetup()
{
const auto waitTime = TDuration::MilliSeconds(100);
const int maxIterations = 1000;

int iterations = 0;
int error = 0;

for (; iterations != maxIterations; ++iterations) {
error = io_setup(BatchSize, &Io);
if (error != -EAGAIN) {
break;
}

const auto aioNr = TIFStream("/proc/sys/fs/aio-nr").ReadLine();
const auto aioMaxNr = TIFStream("/proc/sys/fs/aio-max-nr").ReadLine();

STORAGE_WARN(
"retrying EAGAIN from io_setup, BatchSize: "
<< BatchSize << ", aio-nr/aio-max-nr: " << aioNr << "/"
<< aioMaxNr);

Sleep(waitTime);
}
Y_ABORT_UNLESS(!error, "io_setup: %d, iterations: %d", error, iterations);
}

vhd_bdev_info TAioBackend::Init(const TOptions& options)
{
STORAGE_INFO("Initializing AIO backend");
Expand All @@ -176,7 +206,7 @@ vhd_bdev_info TAioBackend::Init(const TOptions& options)
}
BatchSize = options.BatchSize;

Y_ABORT_UNLESS(io_setup(BatchSize, &Io) >= 0, "io_setup");
IoSetup();

for (ui32 i = 0; i < options.QueueCount; i++) {
Batches.emplace_back();
Expand Down
Loading