]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/filestore: FALLOC_FL_PUNCH_HOLE must be used with FALLOC_FL_KEEP_SIZE 13041/head
authorNathan Cutler <ncutler@suse.com>
Sat, 21 Jan 2017 13:54:52 +0000 (14:54 +0100)
committerNathan Cutler <ncutler@suse.com>
Sat, 21 Jan 2017 13:55:38 +0000 (14:55 +0100)
Signed-off-by: xinxin shu <xinxin.shu@intel.com>
(cherry picked from commit 7bd95b595fddb8a4e618a2c7df1ba04eccf0829d)

Conflicts:
    src/os/FileStore.cc (in master, this file is in a different location)

src/os/FileStore.cc

index 61bad358ff16283f5684cb1076fcefc6f0062aac..e0afbd057952046e9d764fb4385e26fd178d2c12 100644 (file)
@@ -3076,6 +3076,7 @@ int FileStore::_zero(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t
 
 #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);
@@ -3084,7 +3085,7 @@ int FileStore::_zero(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t
   }
 
   // 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);
@@ -3098,6 +3099,7 @@ int FileStore::_zero(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t
     goto out;  // yay!
   if (ret != -EOPNOTSUPP)
     goto out;  // some other error
+#    endif
 # endif
 #endif