From 98a67b65961adef7f61fa0cdc30178078fb14ff7 Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Wed, 11 Sep 2024 15:39:21 +0530 Subject: [PATCH] client: return EOPNOTSUPP for fallocate with mode 0 Fixes: https://tracker.ceph.com/issues/68026 Signed-off-by: Milind Changire --- src/client/Client.cc | 2 +- src/pybind/cephfs/cephfs.pyx | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index f687264e167..21555d0d07c 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -16234,7 +16234,7 @@ int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length) if (offset < 0 || length <= 0) return -CEPHFS_EINVAL; - if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) + if (mode == 0 || (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))) return -CEPHFS_EOPNOTSUPP; if ((mode & FALLOC_FL_PUNCH_HOLE) && !(mode & FALLOC_FL_KEEP_SIZE)) diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 793d88b9850..798ea3f902a 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -923,12 +923,12 @@ cdef class LibCephFS(object): :param fd: the file descriptor of the file to fallocate. :param mode: the flags determines the operation to be performed on the given - range. default operation (0) allocate and initialize to zero - the file in the byte range, and the file size will be changed - if offset + length is greater than the file size. if the - FALLOC_FL_KEEP_SIZE flag is specified in the mode, the file size - will not be changed. if the FALLOC_FL_PUNCH_HOLE flag is specified - in the mode, the operation is deallocate space and zero the byte range. + range. default operation (0) is to return -EOPNOTSUPP since + cephfs does not allocate disk blocks to provide write guarantees. + if the FALLOC_FL_KEEP_SIZE flag is specified in the mode, + the file size will not be changed. if the FALLOC_FL_PUNCH_HOLE + flag is specified in the mode, the operation is deallocate + space and zero the byte range. :param offset: the byte range starting. :param length: the length of the range. """ -- 2.39.5