summaryrefslogtreecommitdiffstats
path: root/src/blk/kernel
diff options
context:
space:
mode:
authorRadoslaw Zarzynski <rzarzyns@redhat.com>2021-01-28 16:42:34 +0100
committerRadoslaw Zarzynski <rzarzyns@redhat.com>2022-01-12 21:35:50 +0100
commit67ce52f5f9612bde8180203bdcbb6d9e733e5108 (patch)
tree1f1c7cccaf4c9b1724292d18dc4ee181e1e92213 /src/blk/kernel
parentblk, os/bluestore: introduce a cache bypassing to IOContext and BlueStore. (diff)
downloadceph-67ce52f5f9612bde8180203bdcbb6d9e733e5108.tar.xz
ceph-67ce52f5f9612bde8180203bdcbb6d9e733e5108.zip
blk: make the buffer alignment configurable in KernelDevice.
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
Diffstat (limited to 'src/blk/kernel')
-rw-r--r--src/blk/kernel/KernelDevice.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc
index ebd387aa17e..d5251411dcd 100644
--- a/src/blk/kernel/KernelDevice.cc
+++ b/src/blk/kernel/KernelDevice.cc
@@ -1041,6 +1041,22 @@ int KernelDevice::discard(uint64_t offset, uint64_t len)
return r;
}
+
+// create a buffer basing on user-configurable. it's intended to make
+// our buffers THP-able.
+static ceph::unique_leakable_ptr<buffer::raw> create_custom_aligned(
+ CephContext* const cct,
+ const size_t len)
+{
+ // just to preserve the logic of create_small_page_aligned().
+ if (len < CEPH_PAGE_SIZE) {
+ return ceph::buffer::create_small_page_aligned(len);
+ } else {
+ const size_t custom_alignment = cct->_conf->bdev_read_buffer_alignment;
+ return ceph::buffer::create_aligned(len, custom_alignment);
+ }
+}
+
int KernelDevice::read(uint64_t off, uint64_t len, bufferlist *pbl,
IOContext *ioc,
bool buffered)
@@ -1054,7 +1070,7 @@ int KernelDevice::read(uint64_t off, uint64_t len, bufferlist *pbl,
auto start1 = mono_clock::now();
- auto p = ceph::buffer::ptr_node::create(ceph::buffer::create_small_page_aligned(len));
+ auto p = ceph::buffer::ptr_node::create(create_custom_aligned(cct, len));
int r = ::pread(choose_fd(buffered, WRITE_LIFE_NOT_SET),
p->c_str(), len, off);
auto age = cct->_conf->bdev_debug_aio_log_age;
@@ -1106,7 +1122,7 @@ int KernelDevice::aio_read(
++ioc->num_pending;
aio_t& aio = ioc->pending_aios.back();
aio.bl.push_back(
- ceph::buffer::ptr_node::create(ceph::buffer::create_small_page_aligned(len)));
+ ceph::buffer::ptr_node::create(create_custom_aligned(cct, len)));
aio.bl.prepare_iov(&aio.iov);
aio.preadv(off, len);
dout(30) << aio << dendl;