]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlueFS: ignore flush when buffer is small
authorSage Weil <sage@redhat.com>
Mon, 21 Dec 2015 20:07:44 +0000 (15:07 -0500)
committerSage Weil <sage@redhat.com>
Fri, 1 Jan 2016 18:07:20 +0000 (13:07 -0500)
Rocksdb does a flush after every append, each of which is often
less than a full block.  This is very inefficient when our
_flush() will send that to disk (and block).

Avoid this most of the time by ignoring small flush requests
entirely, unless the force flag is set (e.g., by fsync).

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config_opts.h
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h

index 1596d340675124bc4a4f104880b0ec6c55c62b3b..652c31bdd818244d1e9f7503711ed70f4ee55876 100644 (file)
@@ -842,6 +842,7 @@ OPTION(bluefs_min_log_runway, OPT_U64, 1048576)  // alloc when we get this low
 OPTION(bluefs_max_log_runway, OPT_U64, 4194304)  // alloc this much at a time
 OPTION(bluefs_log_compact_min_ratio, OPT_FLOAT, 5.0)      // before we consider
 OPTION(bluefs_log_compact_min_size, OPT_U64, 16*1048576)  // before we consider
+OPTION(bluefs_min_flush_size, OPT_U64, 65536)  // ignore flush until its this big
 
 OPTION(bluestore_bluefs, OPT_BOOL, true)
 OPTION(bluestore_bluefs_env_mirror, OPT_BOOL, false) // mirror to normal Env for debug
index 97db917e713b26e30a8a2c09282674294e93bb65..23f7cee7c3a938a0bb333f4942fe6d2bafe897b7 100644 (file)
@@ -754,7 +754,8 @@ void BlueFS::_compact_log()
   log_file->fnode.size = bl.length();
   log_writer = new FileWriter(log_file, bdev.size());
   log_writer->append(bl);
-  _flush(log_writer);
+  int r = _flush(log_writer, true);
+  assert(r == 0);
 
   dout(10) << __func__ << " writing super" << dendl;
   super.log_fnode = log_file->fnode;
@@ -811,7 +812,7 @@ int BlueFS::_flush_log()
   log_t.seq = 0;  // just so debug output is less confusing
 
   _flush_bdev();
-  int r = _flush(log_writer);
+  int r = _flush(log_writer, true);
   assert(r == 0);
   _flush_bdev();
 
@@ -930,10 +931,17 @@ int BlueFS::_flush_range(FileWriter *h, uint64_t offset, uint64_t length)
   return 0;
 }
 
-int BlueFS::_flush(FileWriter *h)
+int BlueFS::_flush(FileWriter *h, bool force)
 {
   uint64_t length = h->buffer.length();
   uint64_t offset = h->pos;
+  if (!force &&
+      length < g_conf->bluefs_min_flush_size) {
+    dout(10) << __func__ << " " << h << " ignoring, length " << length
+            << " < min_flush_size " << g_conf->bluefs_min_flush_size
+            << dendl;
+    return 0;
+  }
   if (length == 0) {
     if (h->file->dirty) {
       dout(10) << __func__ << " " << h << " no data, flushing metadata on "
@@ -965,7 +973,7 @@ int BlueFS::_truncate(FileWriter *h, uint64_t offset)
     assert(0 == "actually this shouldn't happen");
   }
   if (h->buffer.length()) {
-    int r = _flush(h);
+    int r = _flush(h, true);
     if (r < 0)
       return r;
   }
@@ -984,7 +992,7 @@ int BlueFS::_truncate(FileWriter *h, uint64_t offset)
 void BlueFS::_fsync(FileWriter *h)
 {
   dout(10) << __func__ << " " << h << " " << h->file->fnode << dendl;
-  _flush(h);
+  _flush(h, true);
   if (h->file->dirty) {
     _flush_log();
     assert(!h->file->dirty);
index 7e62d74348545f53f559eb469a39e5fd4b334085..0c9bb6dfc04a97f46dbd5644128b67387b0e3de8 100644 (file)
@@ -191,7 +191,7 @@ private:
 
   int _allocate(unsigned bdev, uint64_t len, vector<bluefs_extent_t> *ev);
   int _flush_range(FileWriter *h, uint64_t offset, uint64_t length);
-  int _flush(FileWriter *h);
+  int _flush(FileWriter *h, bool force);
   void _fsync(FileWriter *h);
 
   int _flush_log();
@@ -290,7 +290,7 @@ public:
 
   void flush(FileWriter *h) {
     Mutex::Locker l(lock);
-    _flush(h);
+    _flush(h, false);
   }
   void flush_range(FileWriter *h, uint64_t offset, uint64_t length) {
     Mutex::Locker l(lock);