From: Patrick Donnelly Date: Fri, 7 Jul 2023 16:14:58 +0000 (-0400) Subject: mon: add helper ::set_val to change fs settings X-Git-Tag: v20.0.0~2223^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f974da7342a7dc0d93571e15ca767c1b6a219b9d;p=ceph.git mon: add helper ::set_val to change fs settings Signed-off-by: Dhairya Parmar Signed-off-by: Patrick Donnelly --- diff --git a/src/mon/FSCommands.cc b/src/mon/FSCommands.cc index 26061996907..e73d13d3456 100644 --- a/src/mon/FSCommands.cc +++ b/src/mon/FSCommands.cc @@ -328,13 +328,22 @@ public: return -EINVAL; } string val; - string interr; - int64_t n = 0; if (!cmd_getval(cmdmap, "val", val)) { return -EINVAL; } + + return set_val(mon, fsmap, op, cmdmap, ss, fsp, var, val); + } +}; + +int FileSystemCommandHandler::set_val(Monitor *mon, FSMap& fsmap, MonOpRequestRef op, + const cmdmap_t& cmdmap, std::ostream &ss, Filesystem const* fsp, + std::string var, std::string val) +{ + { + std::string interr; // we got a string. see if it contains an int. - n = strict_strtoll(val.c_str(), 10, &interr); + int64_t n = strict_strtoll(val.c_str(), 10, &interr); if (var == "max_mds") { // NOTE: see also "mds set_max_mds", which can modify the same field. if (interr.length()) { @@ -762,10 +771,9 @@ public: ss << "unknown variable " << var; return -EINVAL; } - - return 0; } -}; + return 0; +} class CompatSetHandler : public FileSystemCommandHandler { diff --git a/src/mon/FSCommands.h b/src/mon/FSCommands.h index cd9009724e0..09ffda54cc6 100644 --- a/src/mon/FSCommands.h +++ b/src/mon/FSCommands.h @@ -52,6 +52,8 @@ protected: virtual std::string const &get_prefix() const {return prefix;} + int set_val(Monitor *mon, FSMap& fsmap, MonOpRequestRef op, const cmdmap_t& cmdmap, std::ostream &ss, Filesystem const* fsp, std::string var, std::string val); + public: FileSystemCommandHandler(const std::string &prefix_) : prefix(prefix_)