IMPALA-5873: Check for existence of sync_file_range() On some legacy platforms, the system call sync_file_range() is not defined. Some Kudu code calls it unconditionally on Linux platforms. Let's check for its existence and use the workaround already defined for non-Linux platforms.
Testing done: ran packaging build on Centos55. Failed consistently before. Change-Id: I9e398085ebd00c23fd1f29f9253d9c257e0c5442 Reviewed-on: http://gerrit.cloudera.org:8080/7923 Reviewed-by: Michael Ho <[email protected]> Tested-by: Impala Public Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/b20f4596 Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/b20f4596 Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/b20f4596 Branch: refs/heads/master Commit: b20f45962c5ccbc4e1006c0cad2cdda646527fa6 Parents: b66af03 Author: Michael Ho <[email protected]> Authored: Thu Aug 31 11:42:49 2017 -0700 Committer: Impala Public Jenkins <[email protected]> Committed: Fri Sep 1 00:35:51 2017 +0000 ---------------------------------------------------------------------- be/CMakeLists.txt | 1 + be/src/common/config.h.in | 1 + be/src/kudu/util/env_posix.cc | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/b20f4596/be/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index 7bf9e0c..5b0d89d 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -312,6 +312,7 @@ EXECUTE_PROCESS(COMMAND ln ${MORE_ARGS} -sf ${BUILD_OUTPUT_ROOT_DIRECTORY} INCLUDE(CheckFunctionExists) CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU) CHECK_FUNCTION_EXISTS(pipe2 HAVE_PIPE2) +CHECK_FUNCTION_EXISTS(sync_file_range HAVE_SYNC_FILE_RANGE) # linux/fs.h defines HAVE_FALLOCATE whether or not the function is available, # which is why we use IMPALA_HAVE_FALLOCATE here. http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/b20f4596/be/src/common/config.h.in ---------------------------------------------------------------------- diff --git a/be/src/common/config.h.in b/be/src/common/config.h.in index 8f638a9..9d6d247 100644 --- a/be/src/common/config.h.in +++ b/be/src/common/config.h.in @@ -29,5 +29,6 @@ #cmakedefine HAVE_MAGIC_H #cmakedefine HAVE_KRB5_IS_CONFIG_PRINCIPAL #cmakedefine HAVE_KRB5_GET_INIT_CREDS_OPT_SET_OUT_CCACHE +#cmakedefine HAVE_SYNC_FILE_RANGE #endif http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/b20f4596/be/src/kudu/util/env_posix.cc ---------------------------------------------------------------------- diff --git a/be/src/kudu/util/env_posix.cc b/be/src/kudu/util/env_posix.cc index 6f9c9ff..173092d 100644 --- a/be/src/kudu/util/env_posix.cc +++ b/be/src/kudu/util/env_posix.cc @@ -626,7 +626,7 @@ class PosixWritableFile : public WritableFile { Status::IOError(Env::kInjectedFailureStatusMsg)); TRACE_EVENT1("io", "PosixWritableFile::Flush", "path", filename_); ThreadRestrictions::AssertIOAllowed(); -#if defined(__linux__) +#if defined(HAVE_SYNC_FILE_RANGE) int flags = SYNC_FILE_RANGE_WRITE; if (mode == FLUSH_SYNC) { flags |= SYNC_FILE_RANGE_WAIT_BEFORE; @@ -762,7 +762,7 @@ class PosixRWFile : public RWFile { Status::IOError(Env::kInjectedFailureStatusMsg)); TRACE_EVENT1("io", "PosixRWFile::Flush", "path", filename_); ThreadRestrictions::AssertIOAllowed(); -#if defined(__linux__) +#if defined(HAVE_SYNC_FILE_RANGE) int flags = SYNC_FILE_RANGE_WRITE; if (mode == FLUSH_SYNC) { flags |= SYNC_FILE_RANGE_WAIT_AFTER;
