From e80d3f7a891af99ba0d4cfe99e5530016ca867ac Mon Sep 17 00:00:00 2001 From: Yin Congmin Date: Mon, 23 Mar 2020 10:27:55 +0800 Subject: [PATCH] os/bluestore: Optimizing the lock of bluestore writing process Unlock global lock and use FileWriter lock to improve performance and tail latency Signed-off-by: Yin Congmin --- src/os/bluestore/BlueFS.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 16a5b223f56..c765556a6ab 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -703,6 +703,7 @@ void BlueFS::umount() int BlueFS::prepare_new_device(int id, const bluefs_layout_t& layout) { + std::unique_lock l(lock); dout(1) << __func__ << dendl; if(id == BDEV_NEWDB) { @@ -1551,6 +1552,7 @@ int BlueFS::device_migrate_to_existing( int dev_target, const bluefs_layout_t& layout) { + std::unique_lock l(lock); vector buf; bool buffered = cct->_conf->bluefs_buffered_io; @@ -1691,6 +1693,7 @@ int BlueFS::device_migrate_to_new( int dev_target, const bluefs_layout_t& layout) { + std::unique_lock l(lock); vector buf; bool buffered = cct->_conf->bluefs_buffered_io; @@ -2813,11 +2816,15 @@ int BlueFS::_flush_range(FileWriter *h, uint64_t offset, uint64_t length) uint64_t x_len = std::min(p->length - x_off, length); bufferlist t; t.substr_of(bl, bloff, x_len); + h->lock.lock(); + lock.unlock(); if (cct->_conf->bluefs_sync_write) { bdev[p->bdev]->write(p->offset + x_off, t, buffered, h->write_hint); } else { bdev[p->bdev]->aio_write(p->offset + x_off, t, h->iocv[p->bdev], buffered, h->write_hint); } + lock.lock(); + h->lock.unlock(); h->dirty_devs[p->bdev] = true; if (p->bdev == BDEV_SLOW) { bytes_written_slow += t.length(); -- 2.39.5