We need to flush any new writes on any fsync(). Notably, this includes
the rocksdb log. However, previously _fsync was only doing a bdev flush if
we also had a dirty bluefs journal and called into _sync_and_flush_journal.
If we didn't, we weren't doing a flush() at all, which could lead to
corrupted data.
Fix this by moving the first flush_bdev *out* of _sync_and_flush_log. (The
second one is there to flush the bluefs journal; the first one was to
ensure prior writes are stable.) Instead, flush prior writes in all of the
callers prior to calling _sync_and_flush_log. This includes _fsync (and
fixes the bug by covering the non-journal-flush path) as well as several
other callers.
Fixes: http://tracker.ceph.com/issues/19250 Signed-off-by: Sage Weil <sage@redhat.com>