From a297fb713419da7079225626b81dbc0e8444902f Mon Sep 17 00:00:00 2001 From: Sven Anderson Date: Thu, 27 May 2021 18:42:52 +0200 Subject: [PATCH] cephfs: make ceph_fallocate() platform independent 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 --- src/client/Client.cc | 11 ----------- src/include/cephfs/ceph_ll_client.h | 8 ++++++++ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index b1b86290ae4..8d5aebd3749 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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) { diff --git a/src/include/cephfs/ceph_ll_client.h b/src/include/cephfs/ceph_ll_client.h index 78731db218d..17dc2fec619 100644 --- a/src/include/cephfs/ceph_ll_client.h +++ b/src/include/cephfs/ceph_ll_client.h @@ -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); -- 2.47.3