From: Venky Shankar Date: Fri, 16 Apr 2021 07:02:10 +0000 (-0400) Subject: pybind/cephfs: add interface to set mount timeout X-Git-Tag: v17.1.0~1932^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=42015a34d6b33f17130acec628e25333bb3e180d;p=ceph.git pybind/cephfs: add interface to set mount timeout Signed-off-by: Venky Shankar --- diff --git a/src/pybind/cephfs/c_cephfs.pxd b/src/pybind/cephfs/c_cephfs.pxd index cb266ecf9101..5b0fa29924eb 100644 --- a/src/pybind/cephfs/c_cephfs.pxd +++ b/src/pybind/cephfs/c_cephfs.pxd @@ -50,6 +50,7 @@ cdef extern from "cephfs/libcephfs.h" nogil: int ceph_conf_parse_argv(ceph_mount_info *cmount, int argc, const char **argv) int ceph_conf_get(ceph_mount_info *cmount, const char *option, char *buf, size_t len) int ceph_conf_set(ceph_mount_info *cmount, const char *option, const char *value) + int ceph_set_mount_timeout(ceph_mount_info *cmount, uint32_t timeout) int ceph_mount(ceph_mount_info *cmount, const char *root) int ceph_select_filesystem(ceph_mount_info *cmount, const char *fs_name) diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index e536fcbe5eb3..50e0dd738a34 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -622,6 +622,24 @@ cdef class LibCephFS(object): if ret != 0: raise make_ex(ret, "error calling conf_set") + def set_mount_timeout(self, timeout): + """ + Set mount timeout + + :param timeout: mount timeout + """ + self.require_state("configuring", "initialized") + if not isinstance(timeout, int): + raise TypeError('timeout must be an integer') + if timeout < 0: + raise make_ex(CEPHFS_EINVAL, 'timeout must be greater than or equal to 0') + cdef: + uint32_t _timeout = timeout + with nogil: + ret = ceph_set_mount_timeout(self.cluster, _timeout) + if ret != 0: + raise make_ex(ret, "error setting mount timeout") + def init(self): """ Initialize the filesystem client (but do not mount the filesystem yet) diff --git a/src/pybind/cephfs/mock_cephfs.pxi b/src/pybind/cephfs/mock_cephfs.pxi index c871b8b353b3..d78016f4cce1 100644 --- a/src/pybind/cephfs/mock_cephfs.pxi +++ b/src/pybind/cephfs/mock_cephfs.pxi @@ -63,6 +63,8 @@ cdef nogil: pass int ceph_conf_set(ceph_mount_info *cmount, const char *option, const char *value): pass + int ceph_set_mount_timeout(ceph_mount_info *cmount, uint32_t timeout): + pass int ceph_mount(ceph_mount_info *cmount, const char *root): pass