]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs: add interface to set mount timeout
authorVenky Shankar <vshankar@redhat.com>
Thu, 15 Apr 2021 09:46:15 +0000 (05:46 -0400)
committerVenky Shankar <vshankar@redhat.com>
Tue, 4 May 2021 04:58:02 +0000 (00:58 -0400)
Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index f37114351049bd55fb72c6f57f7dd2639a18d092..4e20549dc385f95890ddfa7f33a763f02f2450af 100644 (file)
@@ -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.
  *
index d9a348fd6b7909274f22f225bb6174a3a1e9e2ae..d6e3208b1cb8b6a470c0240812ef5793f36b8643 100644 (file)
@@ -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,