From abf7c43ae363c7d7dde4ca98f3a155203c9c4692 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Thu, 28 Jan 2021 13:15:56 +0100 Subject: [PATCH] blk: avoid temporary bptrs on aio paths; use ptr_node instead. This is a slight optimization for the `HAVE_LIBAIO` paths of the kernel-based `BlockDevice` implementation. The overall idea is to squeeze temporary, short-living instances of `ceph::bufferptr` as `ceph::bufferlist` actually aggregates `ptr_node` (`bufferptr` with the extra `next` pointer field to form a list). It can be created directly and this commit switches to exactly this behavior. Signed-off-by: Radoslaw Zarzynski --- src/blk/kernel/KernelDevice.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index d932799659706..d41cda05b63d4 100644 --- a/src/blk/kernel/KernelDevice.cc +++ b/src/blk/kernel/KernelDevice.cc @@ -958,8 +958,8 @@ int KernelDevice::aio_write( ioc->pending_aios.push_back(aio_t(ioc, choose_fd(false, write_hint))); ++ioc->num_pending; auto& aio = ioc->pending_aios.back(); - bufferptr p = ceph::buffer::create_small_page_aligned(len); - aio.bl.append(std::move(p)); + aio.bl.push_back( + ceph::buffer::ptr_node::create(ceph::buffer::create_small_page_aligned(len))); aio.bl.prepare_iov(&aio.iov); aio.preadv(off, len); ++injecting_crash; @@ -1092,8 +1092,8 @@ int KernelDevice::aio_read( ioc->pending_aios.push_back(aio_t(ioc, fd_directs[WRITE_LIFE_NOT_SET])); ++ioc->num_pending; aio_t& aio = ioc->pending_aios.back(); - bufferptr p = ceph::buffer::create_small_page_aligned(len); - aio.bl.append(std::move(p)); + aio.bl.push_back( + ceph::buffer::ptr_node::create(ceph::buffer::create_small_page_aligned(len))); aio.bl.prepare_iov(&aio.iov); aio.preadv(off, len); dout(30) << aio << dendl; -- 2.39.5