]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: add crimson pool support, enforce crimson restrictions
authorSamuel Just <sjust@redhat.com>
Thu, 13 Oct 2022 00:50:11 +0000 (17:50 -0700)
committerSamuel Just <sjust@redhat.com>
Tue, 14 Feb 2023 06:36:35 +0000 (22:36 -0800)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/common/options/mon.yaml.in
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 3870ea517e94d7c7b67522fbdce6f041cbbe30f3..1cd655ad48258b5c22279fdc7ac3f364c4e67cf4 100644 (file)
@@ -27,6 +27,15 @@ options:
   default: 4_K
   services:
   - mon
+- name: osd_pool_default_crimson
+  type: bool
+  level: advanced
+  desc: Create pools by default with FLAG_CRIMSON
+  default: false
+  services :
+  - mon
+  flags:
+  - runtime
 - name: mon_max_pool_pg_num
   type: uint
   level: advanced
index 46a7a20768dd3d9fb497fa285a6fe7c60ec82a95..ac521cc18d316cefc94d221dcaa303607182a133 100644 (file)
@@ -1084,7 +1084,8 @@ COMMAND("osd pool create "
        "name=bulk,type=CephBool,req=false "
        "name=target_size_bytes,type=CephInt,range=0,req=false "
        "name=target_size_ratio,type=CephFloat,range=0.0,req=false "\
-       "name=yes_i_really_mean_it,type=CephBool,req=false",
+       "name=yes_i_really_mean_it,type=CephBool,req=false"
+       "name=crimson,type=CephBool,req=false",
        "create pool", "osd", "rw")
 COMMAND_WITH_FLAG("osd pool delete "
        "name=pool,type=CephPoolname "
index 4eccbf42408cab398c2bb622ecfead5a20c0ee80..c8d715ed3ac43c6de6da7e8803ebf53a33c1a91d 100644 (file)
@@ -7376,6 +7376,7 @@ int OSDMonitor::prepare_new_pool(MonOpRequestRef op)
                         0, 0, 0, 0, 0, 0, 0.0,
                         erasure_code_profile,
                         pg_pool_t::TYPE_REPLICATED, 0, FAST_READ_OFF, {}, bulk,
+                        cct->_conf.get_val<bool>("osd_pool_default_crimson"),
                         &ss);
 
   if (ret < 0) {
@@ -7982,6 +7983,9 @@ int OSDMonitor::check_pg_num(int64_t pool, int pg_num, int size, int crush_rule,
  * @param pool_type TYPE_ERASURE, or TYPE_REP
  * @param expected_num_objects expected number of objects on the pool
  * @param fast_read fast read type. 
+ * @param pg_autoscale_mode autoscale mode, one of on, off, warn
+ * @param bool bulk indicates whether pool should be a bulk pool
+ * @param bool crimson indicates whether pool is a crimson pool
  * @param ss human readable error message, if any.
  *
  * @return 0 on success, negative errno on failure.
@@ -7999,12 +8003,21 @@ int OSDMonitor::prepare_new_pool(string& name,
                                  const unsigned pool_type,
                                  const uint64_t expected_num_objects,
                                  FastReadType fast_read,
-                                const string& pg_autoscale_mode,
+                                string pg_autoscale_mode,
                                 bool bulk,
+                                bool crimson,
                                 ostream *ss)
 {
+  if (crimson && pg_autoscale_mode.empty()) {
+    // default pg_autoscale_mode to off for crimson, we'll error out below if
+    // the user tried to actually set pg_autoscale_mode to something other than
+    // "off"
+    pg_autoscale_mode = "off";
+  }
+
   if (name.length() == 0)
     return -EINVAL;
+
   if (pg_num == 0) {
     auto pg_num_from_mode =
       [pg_num=g_conf().get_val<uint64_t>("osd_pool_default_pg_num")]
@@ -8031,6 +8044,25 @@ int OSDMonitor::prepare_new_pool(string& name,
         << ", which in this case is " << pg_num;
     return -ERANGE;
   }
+
+  if (crimson) {
+    /* crimson-osd requires that the pool be replicated and that pg_num/pgp_num
+     * be static.  User must also have specified set-allow-crimson */
+    const auto *suffix = " (--crimson specified or osd_pool_default_crimson set)";
+    if (pool_type != pg_pool_t::TYPE_REPLICATED) {
+      *ss << "crimson-osd only supports replicated pools" << suffix;
+      return -EINVAL;
+    } else if (pg_autoscale_mode != "off") {
+      *ss << "crimson-osd does not support changing pg_num or pgp_num, "
+         << "pg_autoscale_mode must be set to 'off'" << suffix;
+      return -EINVAL;
+    } else if (!osdmap.get_allow_crimson()) {
+      *ss << "set-allow-crimson must be set to create a pool with the "
+         << "crimson flag" << suffix;
+      return -EINVAL;
+    }
+  }
+
   if (pool_type == pg_pool_t::TYPE_REPLICATED && fast_read == FAST_READ_ON) {
     *ss << "'fast_read' can only apply to erasure coding pool";
     return -EINVAL;
@@ -8140,6 +8172,8 @@ int OSDMonitor::prepare_new_pool(string& name,
     pi->use_gmt_hitset = true;
   else
     pi->use_gmt_hitset = false;
+  if (crimson)
+    pi->set_flag(pg_pool_t::FLAG_CRIMSON);
 
   pi->size = size;
   pi->min_size = min_size;
@@ -13186,6 +13220,10 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     cmd_getval(cmdmap, "autoscale_mode", pg_autoscale_mode);
 
     bool bulk = cmd_getval_or<bool>(cmdmap, "bulk", 0);
+
+    bool crimson = cmd_getval_or<bool>(cmdmap, "crimson", false) ||
+      cct->_conf.get_val<bool>("osd_pool_default_crimson");
+
     err = prepare_new_pool(poolstr,
                           -1, // default crush rule
                           rule_name,
@@ -13196,6 +13234,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
                            fast_read,
                           pg_autoscale_mode,
                           bulk,
+                          crimson,
                           &ss);
     if (err < 0) {
       switch(err) {
index 3ced8be401b4c033891531b9b6b62f35fe48ebf6..eac85707576293ff0166e42dab43c3112c33003e 100644 (file)
@@ -530,8 +530,9 @@ private:
                        const unsigned pool_type,
                        const uint64_t expected_num_objects,
                        FastReadType fast_read,
-                      const std::string& pg_autoscale_mode,
+                      std::string pg_autoscale_mode,
                       bool bulk,
+                      bool crimson,
                       std::ostream *ss);
   int prepare_new_pool(MonOpRequestRef op);