From: Radoslaw Zarzynski Date: Thu, 28 Jan 2021 12:15:56 +0000 (+0100) Subject: blk: avoid temporary bptrs on aio paths; use ptr_node instead. X-Git-Tag: v17.1.0~3113^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F39132%2Fhead;p=ceph.git 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 --- diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index d93279965970..d41cda05b63d 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;