env: do not convert all Flush() calls into fsync() on macOS
env: do not convert all Flush() calls into fsync() on macOS

On Linux, we don't expect sync_file_range() to actually provide durability;
we use it to tell the kernel to start writing back dirty pages while we go
off and do other work. That is, it must be followed up with an fsync() if
durability is actually desired.

To that end, let's only convert Flush() to fsync() if a synchronous flush
was requested. Even then I'm not sure it makes sense (sync_file_range()
explicitly does NOT guarantee durability, even if SYNC_FILE_RANGE_WAIT_AFTER
was used), but at least callers will get the "only return when all dirty
pages have been written out" behavior they probably wanted.

I also snuck in a change to add SYNC_FILE_RANGE_WAIT_BEFORE to the
FLUSH_SYNC case on Linux. It's largely academic (since FLUSH_SYNC is never
actually used), but it's safer if it is ever used for data integrity.

Change-Id: I01bdd8dbaaad0205c0795a87dd973c8bf0fb87dc
Reviewed-on: http://gerrit.cloudera.org:8080/5457
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <864f6b82bd94e8dda64141d4274519ee66e0102e@cloudera.com>

cloudera/kudu,cloudera/kudu,andrwng/kudu,helifu/kudu,cloudera/kudu,andrwng/kudu,InspurUSA/kudu,helifu/kudu,InspurUSA/kudu,EvilMcJerkface/kudu,helifu/kudu,cloudera/kudu,andrwng/kudu,InspurUSA/kudu,EvilMcJerkface/kudu,cloudera/kudu,InspurUSA/kudu,InspurUSA/kudu,InspurUSA/kudu,helifu/kudu,helifu/kudu,andrwng/kudu,cloudera/kudu,EvilMcJerkface/kudu,cloudera/kudu,helifu/kudu,EvilMcJerkface/kudu,EvilMcJerkface/kudu,helifu/kudu,andrwng/kudu,EvilMcJerkface/kudu,EvilMcJerkface/kudu,InspurUSA/kudu,cloudera/kudu,helifu/kudu,andrwng/kudu,EvilMcJerkface/kudu,andrwng/kudu,andrwng/kudu,EvilMcJerkface/kudu,InspurUSA/kudu,InspurUSA/kudu,andrwng/kudu,helifu/kudu,cloudera/kudu