From 9cb879ad2b4aabee90fc51d443a511049525b88e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 7 Nov 2016 17:51:01 -0500 Subject: [PATCH] os/fs: uninline aio methods Signed-off-by: Sage Weil --- src/os/fs/FS.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ src/os/fs/FS.h | 40 ++-------------------------------------- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/src/os/fs/FS.cc b/src/os/fs/FS.cc index 187217087a3e0..d2a9f350d343f 100644 --- a/src/os/fs/FS.cc +++ b/src/os/fs/FS.cc @@ -182,3 +182,46 @@ int FS::zero(int fd, uint64_t offset, uint64_t length) out: return r; } + +// --------------- + +int FS::aio_queue_t::submit(aio_t &aio, int *retries) +{ + // 2^16 * 125us = ~8 seconds, so max sleep is ~16 seconds + int attempts = 16; + int delay = 125; + iocb *piocb = &aio.iocb; + while (true) { + int r = io_submit(ctx, 1, &piocb); + if (r < 0) { + if (r == -EAGAIN && attempts-- > 0) { + usleep(delay); + delay *= 2; + (*retries)++; + continue; + } + return r; + } + assert(r == 1); + break; + } + return 0; +} + +int FS::aio_queue_t::get_next_completed(int timeout_ms, aio_t **paio, int max) +{ + io_event event[max]; + struct timespec t = { + timeout_ms / 1000, + (timeout_ms % 1000) * 1000 * 1000 + }; + int r = io_getevents(ctx, 1, max, event, &t); + if (r <= 0) { + return r; + } + for (int i=0; irval = event[i].res; + } + return r; +} diff --git a/src/os/fs/FS.h b/src/os/fs/FS.h index 63cd05f0b6b7f..27b4334f364dd 100644 --- a/src/os/fs/FS.h +++ b/src/os/fs/FS.h @@ -109,44 +109,8 @@ public: } } - int submit(aio_t &aio, int *retries) { - // 2^16 * 125us = ~8 seconds, so max sleep is ~16 seconds - int attempts = 16; - int delay = 125; - iocb *piocb = &aio.iocb; - while (true) { - int r = io_submit(ctx, 1, &piocb); - if (r < 0) { - if (r == -EAGAIN && attempts-- > 0) { - usleep(delay); - delay *= 2; - (*retries)++; - continue; - } - return r; - } - assert(r == 1); - break; - } - return 0; - } - - int get_next_completed(int timeout_ms, aio_t **paio, int max) { - io_event event[max]; - struct timespec t = { - timeout_ms / 1000, - (timeout_ms % 1000) * 1000 * 1000 - }; - int r = io_getevents(ctx, 1, max, event, &t); - if (r <= 0) { - return r; - } - for (int i=0; irval = event[i].res; - } - return r; - } + int submit(aio_t &aio, int *retries); + int get_next_completed(int timeout_ms, aio_t **paio, int max); }; #endif }; -- 2.39.5