Skip to content

Commit

Permalink
IoUringBackend: refactor IoSqe::BackendCb to take io_uring_cqe directly
Browse files Browse the repository at this point in the history
Summary: Refactor only with no logic change. This will be needed in subsequent diffs that add a new queueRecvZc() method.

Reviewed By: yfeldblum

Differential Revision: D69950465

fbshipit-source-id: 761ca347249a675ff3a3fda0313062cb45cbca63
  • Loading branch information
spikeh authored and facebook-github-bot committed Feb 21, 2025
1 parent 5d5a6cc commit 864c17e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
14 changes: 4 additions & 10 deletions folly/io/async/IoUringBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,23 +508,17 @@ FOLLY_ALWAYS_INLINE void IoUringBackend::setProcessSignals() {
}

void IoUringBackend::processPollIoSqe(
IoUringBackend* backend, IoSqe* ioSqe, int res, uint32_t flags) {
backend->processPollIo(ioSqe, res, flags);
IoUringBackend* backend, IoSqe* ioSqe, const io_uring_cqe* cqe) {
backend->processPollIo(ioSqe, cqe->res, cqe->flags);
}

void IoUringBackend::processTimerIoSqe(
IoUringBackend* backend,
IoSqe* /*sqe*/,
int /*res*/,
uint32_t /* flags */) {
IoUringBackend* backend, IoSqe* /*sqe*/, const io_uring_cqe* /*cqe*/) {
backend->setProcessTimers();
}

void IoUringBackend::processSignalReadIoSqe(
IoUringBackend* backend,
IoSqe* /*sqe*/,
int /*res*/,
uint32_t /* flags */) {
IoUringBackend* backend, IoSqe* /*sqe*/, const io_uring_cqe* /*cqe*/) {
backend->setProcessSignals();
}

Expand Down
20 changes: 7 additions & 13 deletions folly/io/async/IoUringBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,17 +496,11 @@ class IoUringBackend : public EventBaseBackendBase {
struct IoSqe;

static void processPollIoSqe(
IoUringBackend* backend, IoSqe* ioSqe, int res, uint32_t flags);
IoUringBackend* backend, IoSqe* ioSqe, const io_uring_cqe* cqe);
static void processTimerIoSqe(
IoUringBackend* backend,
IoSqe* /*sqe*/,
int /*res*/,
uint32_t /* flags */);
IoUringBackend* backend, IoSqe* /*sqe*/, const io_uring_cqe* /*cqe*/);
static void processSignalReadIoSqe(
IoUringBackend* backend,
IoSqe* /*sqe*/,
int /*res*/,
uint32_t /* flags */);
IoUringBackend* backend, IoSqe* /*sqe*/, const io_uring_cqe* /*cqe*/);

// signal handling
void addSignalEvent(Event& event);
Expand Down Expand Up @@ -556,15 +550,15 @@ class IoUringBackend : public EventBaseBackendBase {
};

struct IoSqe : public IoSqeBase {
using BackendCb = void(IoUringBackend*, IoSqe*, int, uint32_t);
using BackendCb = void(IoUringBackend*, IoSqe*, const io_uring_cqe*);
explicit IoSqe(
IoUringBackend* backend = nullptr,
bool poolAlloc = false,
bool persist = false)
: backend_(backend), poolAlloc_(poolAlloc), persist_(persist) {}

void callback(const io_uring_cqe* cqe) noexcept override {
backendCb_(backend_, this, cqe->res, cqe->flags);
backendCb_(backend_, this, cqe);
}
void callbackCancelled(const io_uring_cqe*) noexcept override { release(); }
virtual void release() noexcept;
Expand Down Expand Up @@ -1093,8 +1087,8 @@ class IoUringBackend : public EventBaseBackendBase {
void processFileOp(IoSqe* ioSqe, int res) noexcept;

static void processFileOpCB(
IoUringBackend* backend, IoSqe* ioSqe, int res, uint32_t) {
static_cast<IoUringBackend*>(backend)->processFileOp(ioSqe, res);
IoUringBackend* backend, IoSqe* ioSqe, const io_uring_cqe* cqe) {
static_cast<IoUringBackend*>(backend)->processFileOp(ioSqe, cqe->res);
}

IoUringBackend::IoSqe* allocNewIoSqe(const EventCallback& /*cb*/) {
Expand Down

0 comments on commit 864c17e

Please sign in to comment.