]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-tool: Add support for overriding the 'client_oc' options
authorEdwin Rodriguez <edwin.rodriguez1@ibm.com>
Wed, 15 Apr 2026 16:37:32 +0000 (12:37 -0400)
committerEdwin Rodriguez <edwin.rodriguez1@ibm.com>
Wed, 1 Jul 2026 13:11:15 +0000 (09:11 -0400)
Add --client-oc and --client-oc-size to override libcephfs object cacher
settings before ceph_init. Enables benchmarking with the object cacher
enabled or disabled and with a configurable cache size. Resolved values
are shown in console and JSON output.

Fixes: https://tracker.ceph.com/issues/76183
Signed-off-by: Edwin Rodriguez <edwin.rodriguez1@ibm.com>
src/tools/cephfs/cephfs-tool.cc

index 9762dfc0849cae915faa2dce0c3b7beb7280714d..c4718389a3835eff65d967a046a073016aa8056e 100644 (file)
@@ -167,6 +167,8 @@ struct BenchConfig {
   string json_path;
   int duration;
   string perf_dump_path;
+  string client_oc;
+  string client_oc_size;
 };
 
 struct ThreadStats {
@@ -202,6 +204,26 @@ int setup_mount(struct ceph_mount_info **cmount, const BenchConfig& config, std:
     }
   }
 
+  // 1b. Apply client_oc override
+  if (!config.client_oc.empty()) {
+    if (int rc = ceph_conf_set(*cmount, "client_oc", config.client_oc.c_str()); rc < 0) {
+      out_stream << "Failed to set client_oc option: " << strerror(-rc) << endl;
+      return cleanup_on_fail(rc);
+    }
+  }
+
+  // 1c. Apply client_oc_size override
+  if (!config.client_oc_size.empty()) {
+    uint64_t oc_size = parse_size(config.client_oc_size);
+    string oc_size_str = std::to_string(oc_size);
+    if (int rc = ceph_conf_set(*cmount, "client_oc_size", oc_size_str.c_str());
+        rc < 0) {
+      out_stream << "Failed to set client_oc_size option: " << strerror(-rc)
+                 << endl;
+      return cleanup_on_fail(rc);
+    }
+  }
+
   // 2. Apply Keyring Override (if provided)
   if (!config.keyring.empty()) {
     if (int rc = ceph_conf_set(*cmount, "keyring", config.keyring.c_str()); rc < 0) {
@@ -641,6 +663,20 @@ int do_bench(BenchConfig& config) {
     json_formatter->dump_string("subdirectory", config.subdir);
     json_formatter->dump_int("uid", config.uid);
     json_formatter->dump_int("gid", config.gid);
+    if (!config.client_oc.empty()) {
+      char buf[128];
+      int rc = ceph_conf_get(shared_cmount, "client_oc", buf, sizeof(buf));
+      if (rc >= 0) {
+        json_formatter->dump_string("client_oc", buf);
+      }
+    }
+    if (!config.client_oc_size.empty()) {
+      char buf[128];
+      int rc = ceph_conf_get(shared_cmount, "client_oc_size", buf, sizeof(buf));
+      if (rc >= 0) {
+        json_formatter->dump_string("client_oc_size", buf);
+      }
+    }
     json_formatter->close_section(); // configuration
     json_formatter->open_array_section("iterations");
   }
@@ -654,6 +690,20 @@ int do_bench(BenchConfig& config) {
   cout << "  Subdirectory: " << config.subdir << std::endl;
   cout << "  UID: " << config.uid << std::endl;
   cout << "  GID: " << config.gid << std::endl;
+  if (!config.client_oc.empty()) {
+    char buf[128];
+    int rc = ceph_conf_get(shared_cmount, "client_oc", buf, sizeof(buf));
+    if (rc >= 0) {
+      cout << "  client_oc: " << buf << std::endl;
+    }
+  }
+  if (!config.client_oc_size.empty()) {
+    char buf[128];
+    int rc = ceph_conf_get(shared_cmount, "client_oc_size", buf, sizeof(buf));
+    if (rc >= 0) {
+      cout << "  client_oc_size: " << buf << std::endl;
+    }
+  }
 
   if (int rc = ceph_mkdir(shared_cmount, config.subdir.c_str(), 0755); rc < 0) {
     cerr << "Failed to create bench directory '" << config.subdir << "': " << strerror(-rc) << std::endl;
@@ -926,7 +976,9 @@ int main(int argc, char **argv) {
     ("keyring,k", po::value<string>(&config.keyring), "Path to keyring file")
     ("filesystem,fs", po::value<string>(&config.filesystem), "CephFS filesystem name to mount")
     ("uid", po::value<int>(&config.uid)->default_value(-1), "User ID to mount as")
-    ("gid", po::value<int>(&config.gid)->default_value(-1), "Group ID to mount as");
+    ("gid", po::value<int>(&config.gid)->default_value(-1), "Group ID to mount as")
+    ("client-oc", po::value<string>(&config.client_oc), "Set the 'client_oc' option (0|1)")
+    ("client-oc-size", po::value<string>(&config.client_oc_size), "Set the 'client_oc_size' option");
 
   // Group 2: Benchmark Options
   po::options_description bench("Benchmark Options (used with 'bench' command)");