From: Milind Changire Date: Wed, 11 Sep 2024 10:09:21 +0000 (+0530) Subject: client: return EOPNOTSUPP for fallocate with mode 0 X-Git-Tag: v19.2.3~363^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e32d50ccaf0a35a5676bf788c5bd635407dff8f4;p=ceph.git client: return EOPNOTSUPP for fallocate with mode 0 Fixes: https://tracker.ceph.com/issues/68026 Signed-off-by: Milind Changire (cherry picked from commit 98a67b65961adef7f61fa0cdc30178078fb14ff7) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 67a1f65b4f8..6e3d38a1cc3 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -16155,7 +16155,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. """