From 73da4e199aa0bb002ae5526587cf5d1e6baa3387 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 17 May 2017 09:38:51 -0400 Subject: [PATCH] os/bluestore/KernelDevice: helpful warning when aio limit exhausted Suggested-by: Dan Van Der Ster Signed-off-by: Sage Weil --- src/os/bluestore/KernelDevice.cc | 15 +++++++++++---- src/os/fs/aio.h | 9 ++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index 52cab96bbdd4f..54795efd416ee 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -145,15 +145,17 @@ int KernelDevice::open(const string& p) } } + r = _aio_start(); + if (r < 0) { + goto out_fail; + } + fs = FS::create_by_fd(fd_direct); assert(fs); // round size down to an even block size &= ~(block_size - 1); - r = _aio_start(); - assert(r == 0); - dout(1) << __func__ << " size " << size << " (0x" << std::hex << size << std::dec << ", " @@ -308,7 +310,12 @@ int KernelDevice::_aio_start() dout(10) << __func__ << dendl; int r = aio_queue.init(); if (r < 0) { - derr << __func__ << " failed: " << cpp_strerror(r) << dendl; + if (r == -EAGAIN) { + derr << __func__ << " io_setup(2) failed with EAGAIN; " + << "try increasing /proc/sys/fs/aio-max-nr" << dendl; + } else { + derr << __func__ << " io_setup(2) failed: " << cpp_strerror(r) << dendl; + } return r; } aio_thread.create("bstore_aio"); diff --git a/src/os/fs/aio.h b/src/os/fs/aio.h index 35d99f2c94f56..c4757158cc90a 100644 --- a/src/os/fs/aio.h +++ b/src/os/fs/aio.h @@ -65,7 +65,14 @@ struct aio_queue_t { int init() { assert(ctx == 0); - return io_setup(max_iodepth, &ctx); + int r = io_setup(max_iodepth, &ctx); + if (r < 0) { + if (ctx) { + io_destroy(ctx); + ctx = 0; + } + } + return r; } void shutdown() { if (ctx) { -- 2.39.5