]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs: make ceph_fallocate() platform independent 41580/head
authorSven Anderson <sven@redhat.com>
Thu, 27 May 2021 16:42:52 +0000 (18:42 +0200)
committerSven Anderson <sven@anderson.de>
Thu, 27 May 2021 19:20:56 +0000 (21:20 +0200)
Until now the implementation of Client::_fallocate() was depending on
the GNU/Linux specific mode flags FALLOC_FL_KEEP_SIZE and
FALLOC_FL_PUNCH_HOLE.  This is technically not necessary and prevents
user-space applications on non-Linux platforms to make use of
ceph_fallocate() without good reason.  This change defines the flags
with hard-coded values in case they have not been defined by system
headers.

Signed-off-by: Sven Anderson <sven@redhat.com>
src/client/Client.cc
src/include/cephfs/ceph_ll_client.h

index b1b86290ae4d12c72044c7bcd05fb3c93ecb074a..8d5aebd37490dd122ed346325726f60d95769e06 100644 (file)
@@ -14389,8 +14389,6 @@ int Client::ll_sync_inode(Inode *in, bool syncdataonly)
   return _fsync(in, syncdataonly);
 }
 
-#ifdef FALLOC_FL_PUNCH_HOLE
-
 int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length)
 {
   ceph_assert(ceph_mutex_is_locked_by_me(client_lock));
@@ -14512,15 +14510,6 @@ int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length)
   put_cap_ref(in, CEPH_CAP_FILE_WR);
   return r;
 }
-#else
-
-int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length)
-{
-  return -CEPHFS_EOPNOTSUPP;
-}
-
-#endif
-
 
 int Client::ll_fallocate(Fh *fh, int mode, int64_t offset, int64_t length)
 {
index 78731db218d6823fa001aeb5bb201f28050f675c..17dc2fec6193c489e3f14873fa0a549fb16a422a 100644 (file)
@@ -102,6 +102,14 @@ struct ceph_statx {
  */
 #define CEPH_REQ_FLAG_MASK             (AT_SYMLINK_NOFOLLOW|AT_NO_ATTR_SYNC)
 
+/* fallocate mode flags */
+#ifndef FALLOC_FL_KEEP_SIZE
+#define FALLOC_FL_KEEP_SIZE 0x01
+#endif
+#ifndef FALLOC_FL_PUNCH_HOLE
+#define FALLOC_FL_PUNCH_HOLE 0x02
+#endif
+
 /* delegation recalls */
 typedef void (*ceph_deleg_cb_t)(Fh *fh, void *priv);