summaryrefslogtreecommitdiffstats
path: root/src/librbd
diff options
context:
space:
mode:
authorJason Dillaman <dillaman@redhat.com>2019-06-12 19:36:24 +0200
committerJason Dillaman <dillaman@redhat.com>2019-06-19 16:38:53 +0200
commit172ad649fb8a2410bdc078a5752b2ca09dc03ac2 (patch)
tree5fdc47742a9fa49b9c6ebfa4a7b0e3e1960d42df /src/librbd
parentjournal: support dynamically updating recorder flush options (diff)
downloadceph-172ad649fb8a2410bdc078a5752b2ca09dc03ac2.tar.xz
ceph-172ad649fb8a2410bdc078a5752b2ca09dc03ac2.zip
librbd: new rbd_journal_object_writethrough_until_flush option
When set to true, the journal will not attempt to batch appends until after it receives the the first flush request from the user. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
Diffstat (limited to 'src/librbd')
-rw-r--r--src/librbd/Journal.cc30
-rw-r--r--src/librbd/Journal.h4
-rw-r--r--src/librbd/io/ImageRequest.cc1
3 files changed, 31 insertions, 4 deletions
diff --git a/src/librbd/Journal.cc b/src/librbd/Journal.cc
index 11b2f23fa0f..66abdf90207 100644
--- a/src/librbd/Journal.cc
+++ b/src/librbd/Journal.cc
@@ -715,6 +715,26 @@ void Journal<I>::flush_commit_position(Context *on_finish) {
}
template <typename I>
+void Journal<I>::user_flushed() {
+ if (m_state == STATE_READY && !m_user_flushed.exchange(true) &&
+ m_image_ctx.config.template get_val<bool>("rbd_journal_object_writethrough_until_flush")) {
+ Mutex::Locker locker(m_lock);
+ if (m_state == STATE_READY) {
+ CephContext *cct = m_image_ctx.cct;
+ ldout(cct, 5) << this << " " << __func__ << dendl;
+
+ ceph_assert(m_journaler != nullptr);
+ m_journaler->set_append_batch_options(
+ m_image_ctx.config.template get_val<uint64_t>("rbd_journal_object_flush_interval"),
+ m_image_ctx.config.template get_val<Option::size_t>("rbd_journal_object_flush_bytes"),
+ m_image_ctx.config.template get_val<double>("rbd_journal_object_flush_age"));
+ } else {
+ m_user_flushed = false;
+ }
+ }
+}
+
+template <typename I>
uint64_t Journal<I>::append_write_event(uint64_t offset, size_t length,
const bufferlist &bl,
bool flush_entry) {
@@ -1172,10 +1192,12 @@ void Journal<I>::start_append() {
m_journaler->start_append(
m_image_ctx.config.template get_val<uint64_t>("rbd_journal_object_max_in_flight_appends"));
- m_journaler->set_append_batch_options(
- m_image_ctx.config.template get_val<uint64_t>("rbd_journal_object_flush_interval"),
- m_image_ctx.config.template get_val<Option::size_t>("rbd_journal_object_flush_bytes"),
- m_image_ctx.config.template get_val<double>("rbd_journal_object_flush_age"));
+ if (!m_image_ctx.config.template get_val<bool>("rbd_journal_object_writethrough_until_flush")) {
+ m_journaler->set_append_batch_options(
+ m_image_ctx.config.template get_val<uint64_t>("rbd_journal_object_flush_interval"),
+ m_image_ctx.config.template get_val<Option::size_t>("rbd_journal_object_flush_bytes"),
+ m_image_ctx.config.template get_val<double>("rbd_journal_object_flush_age"));
+ }
transition_state(STATE_READY, 0);
}
diff --git a/src/librbd/Journal.h b/src/librbd/Journal.h
index 88979b6252b..e63cc4a7137 100644
--- a/src/librbd/Journal.h
+++ b/src/librbd/Journal.h
@@ -130,6 +130,8 @@ public:
void flush_commit_position(Context *on_finish);
+ void user_flushed();
+
uint64_t append_write_event(uint64_t offset, size_t length,
const bufferlist &bl,
bool flush_entry);
@@ -291,6 +293,8 @@ private:
uint64_t m_event_tid;
Events m_events;
+ std::atomic<bool> m_user_flushed = false;
+
std::atomic<uint64_t> m_op_tid = { 0 };
TidToFutures m_op_futures;
diff --git a/src/librbd/io/ImageRequest.cc b/src/librbd/io/ImageRequest.cc
index ce064f1f07a..166c8702308 100644
--- a/src/librbd/io/ImageRequest.cc
+++ b/src/librbd/io/ImageRequest.cc
@@ -686,6 +686,7 @@ void ImageFlushRequest<I>::send_request() {
ceph_assert(image_ctx.journal != NULL);
journal_tid = image_ctx.journal->append_io_event(
journal::EventEntry(journal::AioFlushEvent()), 0, 0, false, 0);
+ image_ctx.journal->user_flushed();
}
auto object_dispatch_spec = ObjectDispatchSpec::create_flush(