]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs: make ceph_fallocate() platform independent
authorSven Anderson <sven@redhat.com>
Thu, 27 May 2021 16:42:52 +0000 (18:42 +0200)
committerXiubo Li <xiubli@redhat.com>
Tue, 11 Apr 2023 02:16:44 +0000 (10:16 +0800)
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>
(cherry picked from commit a297fb713419da7079225626b81dbc0e8444902f)

src/client/Client.cc
src/include/cephfs/ceph_ll_client.h

index 22200772d43bfcf9737a2387c84c595b9d2d7666..f8063b46e5d5f618ac5ad2fe7a1baba56b7bd446 100644 (file)
@@ -14790,8 +14790,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));
@@ -14913,15 +14911,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 7709a6de490779e72dc29893141afd35a1d4ba38..eecc72dbfcabf91dbd0a4dca89359eb327f346cb 100644 (file)
@@ -111,6 +111,14 @@ struct ceph_statx {
  */
 #define CEPH_REQ_FLAG_MASK             (AT_SYMLINK_NOFOLLOW|AT_STATX_DONT_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);