From 6a2b4fcb805c4bf3c8ec283a45100ca5ff352f82 Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Thu, 11 Feb 2016 17:00:01 -0800 Subject: [PATCH] Add flag to forcibly disable fallocate Summary: see https://github.com/facebook/rocksdb/issues/977; there are issues with fallocate() on certain filesystems/kernel versions that can lead it to pre- allocating blocks but never freeing them, even if they're unused. Test Plan: verified build commands omit DROCKSDB_FALLOCATE_PRESENT when this env variable is set. without disabling it: $ ROCKSDB_NO_FBCODE=1 make -n env_test | grep -q DROCKSDB_FALLOCATE_PRESENT ; echo $? 0 with disabling it: $ ROCKSDB_NO_FBCODE=1 DISABLE_FALLOCATE=1 make -n env_test | grep -q DROCKSDB_FALLOCATE_PRESENT ; echo $? 1 Reviewers: kradhakrishnan, yhchiang, sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D54069 --- build_tools/build_detect_platform | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/build_tools/build_detect_platform b/build_tools/build_detect_platform index 80905266f..5832b03a9 100755 --- a/build_tools/build_detect_platform +++ b/build_tools/build_detect_platform @@ -189,17 +189,19 @@ if [ "$CROSS_COMPILE" = "true" -o "$FBCODE_BUILD" = "true" ]; then # Also don't need any compilation tests if compiling on fbcode true else - # Test whether fallocate is available - $CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null < - #include - int main() { - int fd = open("/dev/null", 0); - fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, 0, 1024); - } + if ! test $ROCKSDB_DISABLE_FALLOCATE; then + # Test whether fallocate is available + $CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null < + #include + int main() { + int fd = open("/dev/null", 0); + fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, 0, 1024); + } EOF - if [ "$?" = 0 ]; then - COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_FALLOCATE_PRESENT" + if [ "$?" = 0 ]; then + COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_FALLOCATE_PRESENT" + fi fi # Test whether Snappy library is installed -- GitLab