From: Venky Shankar Date: Thu, 15 Apr 2021 09:46:15 +0000 (-0400) Subject: libcephfs: add interface to set mount timeout X-Git-Tag: v17.1.0~1932^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9efdce2920bb568b45fbb8651020682da9ca5715;p=ceph.git libcephfs: add interface to set mount timeout Signed-off-by: Venky Shankar --- diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index f37114351049..4e20549dc385 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -456,6 +456,15 @@ int ceph_conf_parse_env(struct ceph_mount_info *cmount, const char *var); */ int ceph_conf_set(struct ceph_mount_info *cmount, const char *option, const char *value); +/** Set mount timeout. + * + * @param cmount mount handle to set the configuration value on + * @param timeout mount timeout interval + * + * @returns 0 on success, negative error code otherwise. + */ +int ceph_set_mount_timeout(struct ceph_mount_info *cmount, uint32_t timeout); + /** * Gets the configuration value as a string. * diff --git a/src/libcephfs.cc b/src/libcephfs.cc index d9a348fd6b79..d6e3208b1cb8 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -27,6 +27,7 @@ #include "common/version.h" #include "mon/MonClient.h" #include "include/str_list.h" +#include "include/stringify.h" #include "messages/MMonMap.h" #include "msg/Messenger.h" #include "include/ceph_assert.h" @@ -504,6 +505,15 @@ extern "C" int ceph_conf_get(struct ceph_mount_info *cmount, const char *option, return cmount->conf_get(option, buf, len); } +extern "C" int ceph_set_mount_timeout(struct ceph_mount_info *cmount, uint32_t timeout) { + if (cmount->is_mounted()) { + return -EINVAL; + } + + auto timeout_str = stringify(timeout); + return ceph_conf_set(cmount, "client_mount_timeout", timeout_str.c_str()); +} + extern "C" int ceph_mds_command(struct ceph_mount_info *cmount, const char *mds_spec, const char **cmd,