From bb97d3b60d2ddefead580ad2be39533abbc178fc Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 17 Jun 2008 20:56:19 -0700 Subject: [PATCH] objectcacher: fix writeback logic to be less braindead --- src/config.cc | 4 +++- src/config.h | 1 + src/osdc/ObjectCacher.cc | 22 +++++++++++++++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/config.cc b/src/config.cc index f6d9f834055f..2a0b70122d96 100644 --- a/src/config.cc +++ b/src/config.cc @@ -295,7 +295,9 @@ md_config_t g_conf = { // --- objectcacher --- client_oc: true, client_oc_size: 1024*1024* 64, // MB * n - client_oc_max_dirty: 1024*1024* 32, // MB * n (dirty OR tx) + client_oc_max_dirty: 1024*1024* 48, // MB * n (dirty OR tx.. bigish) + client_oc_target_dirty: 1024*1024* 8, // target dirty (keep this smallish) + // note: the max amount of "in flight" dirty data is roughly (max - target) client_oc_max_sync_write: 128*1024, // sync writes >= this use wrlock // --- objecter --- diff --git a/src/config.h b/src/config.h index be12340b7554..e8171ce534fe 100644 --- a/src/config.h +++ b/src/config.h @@ -162,6 +162,7 @@ struct md_config_t { bool client_oc; int client_oc_size; int client_oc_max_dirty; + int client_oc_target_dirty; size_t client_oc_max_sync_write; // objecter diff --git a/src/osdc/ObjectCacher.cc b/src/osdc/ObjectCacher.cc index e2fe09ad8ae9..195e0a26984d 100644 --- a/src/osdc/ObjectCacher.cc +++ b/src/osdc/ObjectCacher.cc @@ -918,6 +918,8 @@ int ObjectCacher::writex(Objecter::OSDWrite *wr, inodeno_t ino) bool ObjectCacher::wait_for_write(size_t len, Mutex& lock) { int blocked = 0; + + // wait for writeback? while (get_stat_dirty() + get_stat_tx() >= g_conf.client_oc_max_dirty) { dout(10) << "wait_for_write waiting on " << len << ", dirty|tx " << (get_stat_dirty() + get_stat_tx()) @@ -930,6 +932,13 @@ bool ObjectCacher::wait_for_write(size_t len, Mutex& lock) blocked++; dout(10) << "wait_for_write woke up" << dendl; } + + // start writeback anyway? + if (get_stat_dirty() > g_conf.client_oc_target_dirty) { + dout(10) << "wait_for_write " << get_stat_dirty() << " > target " + << g_conf.client_oc_target_dirty << ", nudging flusher" << dendl; + flusher_cond.Signal(); + } return blocked; } @@ -945,14 +954,17 @@ void ObjectCacher::flusher_entry() << get_stat_tx() << " tx, " << get_stat_rx() << " rx, " << get_stat_clean() << " clean, " - << get_stat_dirty() << " / " << g_conf.client_oc_max_dirty << " dirty" + << get_stat_dirty() << " dirty (" + << g_conf.client_oc_target_dirty << " target, " + << g_conf.client_oc_max_dirty << " max)" << dendl; - if (get_stat_dirty() > g_conf.client_oc_max_dirty) { + if (get_stat_dirty() > g_conf.client_oc_target_dirty) { // flush some dirty pages dout(10) << "flusher " - << get_stat_dirty() << " / " << g_conf.client_oc_max_dirty << " dirty," - << " flushing some dirty bhs" << dendl; - flush(get_stat_dirty() - g_conf.client_oc_max_dirty); + << get_stat_dirty() << " dirty > target " + << g_conf.client_oc_target_dirty + << ", flushing some dirty bhs" << dendl; + flush(get_stat_dirty() - g_conf.client_oc_target_dirty); } else { // check tail of lru for old dirty items -- 2.47.3