]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/filestore: FALLOC_FL_PUNCH_HOLE must be used with FALLOC_FL_KEEP_SIZE 7768/head
authorxinxin shu <xinxin.shu@intel.com>
Wed, 24 Feb 2016 03:37:45 +0000 (11:37 +0800)
committerxinxin shu <xinxin.shu@intel.com>
Wed, 24 Feb 2016 06:11:36 +0000 (14:11 +0800)
Signed-off-by: xinxin shu <xinxin.shu@intel.com>
src/os/filestore/FileStore.cc

index 548b1d926f75b2285bd5708c9e0ce9e45d7fe23c..656a6e484746be2ec75d53a399db49809572343e 100644 (file)
@@ -3232,6 +3232,7 @@ int FileStore::_zero(const coll_t& cid, const ghobject_t& oid, uint64_t offset,
 
 #ifdef CEPH_HAVE_FALLOCATE
 # if !defined(DARWIN) && !defined(__FreeBSD__)
+#    ifdef FALLOC_FL_KEEP_SIZE
   // first try to punch a hole.
   FDRef fd;
   ret = lfn_open(cid, oid, false, &fd);
@@ -3240,7 +3241,7 @@ int FileStore::_zero(const coll_t& cid, const ghobject_t& oid, uint64_t offset,
   }
 
   // first try fallocate
-  ret = fallocate(**fd, FALLOC_FL_PUNCH_HOLE, offset, len);
+  ret = fallocate(**fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, offset, len);
   if (ret < 0)
     ret = -errno;
   lfn_close(fd);
@@ -3254,6 +3255,7 @@ int FileStore::_zero(const coll_t& cid, const ghobject_t& oid, uint64_t offset,
     goto out;  // yay!
   if (ret != -EOPNOTSUPP)
     goto out;  // some other error
+#    endif
 # endif
 #endif