]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: introduce per-pool crimson_allow_pg_merge flag
authorAishwarya Mathuria <amathuri@redhat.com>
Tue, 28 Apr 2026 06:41:22 +0000 (12:11 +0530)
committerAishwarya Mathuria <amathuri@redhat.com>
Thu, 11 Jun 2026 04:55:45 +0000 (10:25 +0530)
Switch Crimson PG merge gating from a global config to a pool-scoped flag.

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/osd/osd_types.h

index 3c7f13db567b37a6f751f740ddcd292152f2d48b..3024667cf67b35b5d9079bb74c373b45f9761203 100644 (file)
@@ -1184,6 +1184,7 @@ COMMAND("osd pool get "
           "|compression_min_blob_size"
           "|compression_mode"
           "|compression_required_ratio"
+          "|crimson_allow_pg_merge"
           "|crush_rule"
           "|csum_max_block"
           "|csum_min_block"
@@ -1250,6 +1251,7 @@ COMMAND("osd pool set "
           "|compression_min_blob_size"
           "|compression_mode"
           "|compression_required_ratio"
+          "|crimson_allow_pg_merge"
           "|crush_rule"
           "|csum_max_block"
           "|csum_min_block"
index c27879fcd442bf6fce9c04d954106d2ff5226fa0..b256899e3a4022965b0fa833b3a58d14098e8465 100644 (file)
@@ -4078,7 +4078,19 @@ bool OSDMonitor::prepare_pg_ready_to_merge(MonOpRequestRef op)
     return false; /* nothing to propose, yet */
   }
 
-  if (m->ready) {
+  bool allow_merge = true;
+  if (m->ready && p.has_flag(pg_pool_t::FLAG_CRIMSON)) {
+    if (!p.has_flag(pg_pool_t::FLAG_CRIMSON_ALLOW_PG_MERGE)) {
+      allow_merge = false;
+      mon.clog->warn() << "blocking crimson pg merge for " << m->pgid
+                       << " (pool '" << osdmap.get_pool_name(m->pgid.pool())
+                       << "') because pool flag 'crimson_allow_pg_merge' is not set";
+      dout(1) << __func__ << " blocking crimson pg merge for " << m->pgid
+              << " because pool flag crimson_allow_pg_merge is not set" << dendl;
+    }
+  }
+
+  if (m->ready && allow_merge) {
     p.dec_pg_num(m->pgid,
                 pending_inc.epoch,
                 m->source_version,
@@ -8742,11 +8754,14 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap,
       return -EPERM;
     }
     // check for Crimson pools
-    // pg merging is not yet supported in Crimson
+    // pg merging is only supported when explicitly enabled per-pool (crimson_allow_pg_merge)
     if (p.has_flag(pg_pool_t::FLAG_CRIMSON)) {
       if (n < (int)p.get_pg_num()) {
-        ss << "crimson-osd does not support decreasing pg_num_actual (shrinking)";
-        return -ENOTSUP;
+        if (!p.has_flag(pg_pool_t::FLAG_CRIMSON_ALLOW_PG_MERGE)) {
+          ss << "crimson-osd does not support decreasing pg_num_actual (shrinking) "
+             << "unless the pool flag crimson_allow_pg_merge is set";
+          return -ENOTSUP;
+        }
       }
       if (n > (int)p.get_pg_num() && !g_conf().get_val<bool>("crimson_allow_pg_split")) {
         ss << "crimson_allow_pg_split is false; pg_num_actual increase denied";
@@ -8805,11 +8820,14 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap,
       return -EPERM;
     }
     // check for Crimson pools
-    // pg merging is not yet supported in Crimson
+    // pg merging is only supported when explicitly enabled per-pool (crimson_allow_pg_merge)
     if (p.has_flag(pg_pool_t::FLAG_CRIMSON)) {
       if (n < (int)p.get_pg_num_target()) {
-        ss << "crimson-osd does not support decreasing pg_num";
-        return -ENOTSUP;
+        if (!p.has_flag(pg_pool_t::FLAG_CRIMSON_ALLOW_PG_MERGE)) {
+          ss << "crimson-osd does not support decreasing pg_num "
+             << "unless the pool flag crimson_allow_pg_merge is set";
+          return -ENOTSUP;
+        }
       }
       if (n > (int)p.get_pg_num_target() && !g_conf().get_val<bool>("crimson_allow_pg_split")) {
         ss << "crimson_allow_pg_split is false; pg_num increase denied for crimson pool";
@@ -8886,11 +8904,14 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap,
       return -EPERM;
     }
     // check for Crimson pools
-    // pg merging is not yet supported in Crimson
+    // pg merging is only supported when explicitly enabled per-pool (crimson_allow_pg_merge)
     if (p.has_flag(pg_pool_t::FLAG_CRIMSON)) {
       if (n < (int)p.get_pgp_num()) {
-        ss << "crimson-osd does not support decreasing pgp_num_actual";
-        return -ENOTSUP;
+        if (!p.has_flag(pg_pool_t::FLAG_CRIMSON_ALLOW_PG_MERGE)) {
+          ss << "crimson-osd does not support decreasing pgp_num_actual "
+             << "unless the pool flag crimson_allow_pg_merge is set";
+          return -ENOTSUP;
+        }
       }
       if (n > (int)p.get_pgp_num() && !g_conf().get_val<bool>("crimson_allow_pg_split")) {
         ss << "crimson_allow_pg_split is false; pgp_num_actual increase denied";
@@ -8921,11 +8942,14 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap,
       return -EPERM;
     }
     // check for Crimson pools
-    // pg merging is not yet supported in Crimson
+    // pg merging is only supported when explicitly enabled per-pool (crimson_allow_pg_merge)
     if (p.has_flag(pg_pool_t::FLAG_CRIMSON)) {
       if (n < (int)p.get_pgp_num_target()) {
-        ss << "crimson-osd does not support decreasing pgp_num";
-        return -ENOTSUP;
+        if (!p.has_flag(pg_pool_t::FLAG_CRIMSON_ALLOW_PG_MERGE)) {
+          ss << "crimson-osd does not support decreasing pgp_num "
+             << "unless the pool flag crimson_allow_pg_merge is set";
+          return -ENOTSUP;
+        }
       }
       if (n > (int)p.get_pgp_num_target() && !g_conf().get_val<bool>("crimson_allow_pg_split")) {
         ss << "crimson_allow_pg_split is false; pgp_num increase denied";
@@ -8978,7 +9002,8 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap,
     p.crush_rule = id;
   } else if (var == "nodelete" || var == "nopgchange" ||
             var == "nosizechange" || var == "write_fadvise_dontneed" ||
-            var == "noscrub" || var == "nodeep-scrub" || var == "bulk") {
+            var == "noscrub" || var == "nodeep-scrub" || var == "bulk" ||
+            var == "crimson_allow_pg_merge") {
     uint64_t flag = pg_pool_t::get_flag_by_name(var);
     // make sure we only compare against 'n' if we didn't receive a string
     if (val == "true" || (interr.empty() && n == 1)) {
index bb6cc381fee31a1030cf27ebd39ebf86a31361de..1065066948ee555f6003266447fb60c9fd933be5 100644 (file)
@@ -1330,6 +1330,9 @@ struct pg_pool_t {
     FLAG_EC_OPTIMIZATIONS = 1<<19, // enable optimizations, once enabled, cannot be disabled
     FLAG_CLIENT_SPLIT_READS = 1<<20, // Optimized EC is permitted to do direct reads.
     FLAG_OMAP = 1<<21, // Pool is permitted to perform OMAP operations
+    // Allow decreasing pg_num/pgp_num (PG merge) for crimson pools.
+    // Note: requires that the pool is currently all bluestore.
+    FLAG_CRIMSON_ALLOW_PG_MERGE = 1<<22,
   };
 
   static const char *get_flag_name(uint64_t f) {
@@ -1356,6 +1359,7 @@ struct pg_pool_t {
     case FLAG_EC_OPTIMIZATIONS: return "ec_optimizations";
     case FLAG_CLIENT_SPLIT_READS: return "split_reads";
     case FLAG_OMAP: return "supports_omap";
+    case FLAG_CRIMSON_ALLOW_PG_MERGE: return "crimson_allow_pg_merge";
     default: return "???";
     }
   }
@@ -1412,6 +1416,8 @@ struct pg_pool_t {
       return FLAG_BULK;
     if (name == "crimson")
       return FLAG_CRIMSON;
+    if (name == "crimson_allow_pg_merge")
+      return FLAG_CRIMSON_ALLOW_PG_MERGE;
     if (name == "ec_optimizations")
       return FLAG_EC_OPTIMIZATIONS;
     if (name == "split_reads")