]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
revert remove fallocate punch hole
authorAndrew Kryczka <andrewkr@fb.com>
Wed, 5 Apr 2017 21:11:33 +0000 (14:11 -0700)
committerAndrew Kryczka <andrewkr@fb.com>
Wed, 5 Apr 2017 21:11:33 +0000 (14:11 -0700)
HISTORY.md
util/io_posix.cc

index 3468d8b022ea96b85a1a8a92813b7fe7615f6126..d0ca86b3702fb10bd61e51c92d74c9e51b5f0540 100644 (file)
@@ -11,7 +11,6 @@
 
 ### Bug Fixes
 * Fix the bug that iterator may skip keys
-* Remove calling fallocate with FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE flag to circumvent a kernel bug that changes file size after this call on XFS
 
 ## 5.2.0 (02/08/2017)
 ### Public API Change
index 00ceb38db5a0fc2ff43cbfa3566963b3a5f9f97d..b61f4b38f55b9d1c431d31f8fef648b0180f80e9 100644 (file)
@@ -751,6 +751,29 @@ Status PosixWritableFile::Close() {
     // but it will be nice to log these errors.
     int dummy __attribute__((unused));
     dummy = ftruncate(fd_, filesize_);
+#if defined(ROCKSDB_FALLOCATE_PRESENT) && !defined(TRAVIS)
+    // in some file systems, ftruncate only trims trailing space if the
+    // new file size is smaller than the current size. Calling fallocate
+    // with FALLOC_FL_PUNCH_HOLE flag to explicitly release these unused
+    // blocks. FALLOC_FL_PUNCH_HOLE is supported on at least the following
+    // filesystems:
+    //   XFS (since Linux 2.6.38)
+    //   ext4 (since Linux 3.0)
+    //   Btrfs (since Linux 3.7)
+    //   tmpfs (since Linux 3.5)
+    // We ignore error since failure of this operation does not affect
+    // correctness.
+    // TRAVIS - this code does not work on TRAVIS filesystems.
+    // the FALLOC_FL_KEEP_SIZE option is expected to not change the size
+    // of the file, but it does. Simple strace report will show that.
+    // While we work with Travis-CI team to figure out if this is a
+    // quirk of Docker/AUFS, we will comment this out.
+    IOSTATS_TIMER_GUARD(allocate_nanos);
+    if (allow_fallocate_) {
+      fallocate(fd_, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, filesize_,
+                block_size * last_allocated_block - filesize_);
+    }
+#endif
   }
 
   if (close(fd_) < 0) {