diff --git a/src/blockstore_flush.cpp b/src/blockstore_flush.cpp index 50f4f4c6..1a2322bb 100644 --- a/src/blockstore_flush.cpp +++ b/src/blockstore_flush.cpp @@ -19,7 +19,6 @@ journal_flusher_t::journal_flusher_t(blockstore_impl_t *bs) syncing_flushers = 0; // FIXME: allow to configure flusher_start_threshold and journal_trim_interval flusher_start_threshold = bs->dsk.journal_block_size / sizeof(journal_entry_stable); - journal_trim_interval = 512; journal_trim_counter = bs->journal.flush_journal ? 1 : 0; trim_wanted = bs->journal.flush_journal ? 1 : 0; journal_superblock = bs->journal.inmemory ? bs->journal.buffer : memalign_or_die(MEM_ALIGNMENT, bs->dsk.journal_block_size); @@ -584,7 +583,8 @@ resume_2: flusher->sync_to_repeat.erase(repeat_it); trim_journal: // Clear unused part of the journal every flushes - if (!((++flusher->journal_trim_counter) % flusher->journal_trim_interval) || flusher->trim_wanted > 0) + if (bs->journal_trim_interval && !((++flusher->journal_trim_counter) % bs->journal_trim_interval) || + flusher->trim_wanted > 0) { resume_26: resume_27: diff --git a/src/blockstore_flush.h b/src/blockstore_flush.h index 819c3326..14f5c67c 100644 --- a/src/blockstore_flush.h +++ b/src/blockstore_flush.h @@ -107,7 +107,7 @@ class journal_flusher_t blockstore_impl_t *bs; friend class journal_flusher_co; - int journal_trim_counter, journal_trim_interval; + int journal_trim_counter; bool trimming; void* journal_superblock; diff --git a/src/blockstore_impl.h b/src/blockstore_impl.h index c1b88638..ca7998a9 100644 --- a/src/blockstore_impl.h +++ b/src/blockstore_impl.h @@ -253,6 +253,7 @@ class blockstore_impl_t bool inmemory_meta = false; // Maximum and minimum flusher count unsigned max_flusher_count, min_flusher_count; + unsigned journal_trim_interval; // Maximum queue depth unsigned max_write_iodepth = 128; // Enable small (journaled) write throttling, useful for the SSD+HDD case diff --git a/src/blockstore_open.cpp b/src/blockstore_open.cpp index 1bfbd064..7980f11e 100644 --- a/src/blockstore_open.cpp +++ b/src/blockstore_open.cpp @@ -13,6 +13,7 @@ void blockstore_impl_t::parse_config(blockstore_config_t & config, bool init) max_flusher_count = strtoull(config["flusher_count"].c_str(), NULL, 10); } min_flusher_count = strtoull(config["min_flusher_count"].c_str(), NULL, 10); + journal_trim_interval = strtoull(config["journal_trim_interval"].c_str(), NULL, 10); max_write_iodepth = strtoull(config["max_write_iodepth"].c_str(), NULL, 10); throttle_small_writes = config["throttle_small_writes"] == "true" || config["throttle_small_writes"] == "1" || config["throttle_small_writes"] == "yes"; throttle_target_iops = strtoull(config["throttle_target_iops"].c_str(), NULL, 10); @@ -31,6 +32,10 @@ void blockstore_impl_t::parse_config(blockstore_config_t & config, bool init) { min_flusher_count = 1; } + if (!journal_trim_interval) + { + journal_trim_interval = 512; + } if (!max_write_iodepth) { max_write_iodepth = 128;