]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mon/FSCommands.cc
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / mon / FSCommands.cc
index b5f8b6ce373c3d5ceac4ce17cefa4fe378b20176..65d2c356b687bee4cadd2ae2b5a87b115500579c 100644 (file)
@@ -222,19 +222,17 @@ class FsNewHandler : public FileSystemCommandHandler
       return -EINVAL;
     }
 
+    bool allow_overlay = false;
+    cmd_getval(cmdmap, "allow_dangerous_metadata_overlay", allow_overlay);
+
     for (auto& fs : fsmap.get_filesystems()) {
       const std::vector<int64_t> &data_pools = fs->mds_map.get_data_pools();
-
-      bool sure = false;
-      cmd_getval(cmdmap,
-                 "allow_dangerous_metadata_overlay", sure);
-
       if ((std::find(data_pools.begin(), data_pools.end(), data) != data_pools.end()
           || fs->mds_map.get_metadata_pool() == metadata)
-         && !sure) {
+         && !allow_overlay) {
        ss << "Filesystem '" << fs_name
           << "' is already using one of the specified RADOS pools. This should ONLY be done in emergencies and after careful reading of the documentation. Pass --allow-dangerous-metadata-overlay to permit this.";
-       return -EEXIST;
+       return -EINVAL;
       }
     }
 
@@ -255,12 +253,12 @@ class FsNewHandler : public FileSystemCommandHandler
     pg_pool_t const *metadata_pool = mon->osdmon()->osdmap.get_pg_pool(metadata);
     ceph_assert(metadata_pool != NULL);  // Checked it existed above
 
-    int r = _check_pool(mon->osdmon()->osdmap, data, POOL_DATA_DEFAULT, force, &ss);
+    int r = _check_pool(mon->osdmon()->osdmap, data, POOL_DATA_DEFAULT, force, &ss, allow_overlay);
     if (r < 0) {
       return r;
     }
 
-    r = _check_pool(mon->osdmon()->osdmap, metadata, POOL_METADATA, force, &ss);
+    r = _check_pool(mon->osdmon()->osdmap, metadata, POOL_METADATA, force, &ss, allow_overlay);
     if (r < 0) {
       return r;
     }
@@ -426,6 +424,28 @@ public:
           fs->mds_map.set_balancer(val);
         });
       return true;
+    } else if (var == "bal_rank_mask") {
+      if (val.empty()) {
+        ss << "bal_rank_mask may not be empty";
+       return -EINVAL;
+      }
+
+      if (fs->mds_map.check_special_bal_rank_mask(val, MDSMap::BAL_RANK_MASK_TYPE_ANY) == false) {
+       std::string bin_string;
+       int r = fs->mds_map.hex2bin(val, bin_string, MAX_MDS, ss);
+       if (r != 0) {
+         return r;
+       }
+      }
+      ss << "setting the metadata balancer rank mask to " << val;
+
+      fsmap.modify_filesystem(
+       fs->fscid,
+       [val](std::shared_ptr<Filesystem> fs)
+        {
+          fs->mds_map.set_bal_rank_mask(val);
+        });
+      return true;
     } else if (var == "max_file_size") {
       if (interr.length()) {
        ss << var << " requires an integer value";
@@ -661,6 +681,38 @@ public:
         fs->mds_map.set_min_compat_client(vno);
       };
       fsmap.modify_filesystem(fs->fscid, std::move(f));
+    } else if (var == "refuse_client_session") {
+      bool refuse_session = false;
+      int r = parse_bool(val, &refuse_session, ss);
+      if (r != 0) {
+        return r;
+      }
+
+      if (refuse_session) {
+        if (!(fs->mds_map.test_flag(CEPH_MDSMAP_REFUSE_CLIENT_SESSION))) {
+          fsmap.modify_filesystem(
+            fs->fscid,
+            [](std::shared_ptr<Filesystem> fs)
+          {
+            fs->mds_map.set_flag(CEPH_MDSMAP_REFUSE_CLIENT_SESSION);
+          });
+          ss << "client(s) blocked from establishing new session(s)"; 
+        } else {
+          ss << "client(s) already blocked from establishing new session(s)";
+        }     
+      } else {
+          if (fs->mds_map.test_flag(CEPH_MDSMAP_REFUSE_CLIENT_SESSION)) {
+            fsmap.modify_filesystem(
+              fs->fscid,
+              [](std::shared_ptr<Filesystem> fs)
+            {
+              fs->mds_map.clear_flag(CEPH_MDSMAP_REFUSE_CLIENT_SESSION);
+            });
+            ss << "client(s) allowed to establish new session(s)"; 
+          } else {
+            ss << "client(s) already allowed to establish new session(s)";
+          }
+      }
     } else {
       ss << "unknown variable " << var;
       return -EINVAL;
@@ -1514,7 +1566,8 @@ int FileSystemCommandHandler::_check_pool(
     const int64_t pool_id,
     int type,
     bool force,
-    std::ostream *ss) const
+    std::ostream *ss,
+    bool allow_overlay) const
 {
   ceph_assert(ss != NULL);
 
@@ -1524,7 +1577,36 @@ int FileSystemCommandHandler::_check_pool(
     return -ENOENT;
   }
 
+  if (pool->has_snaps()) {
+    *ss << "pool(" << pool_id <<") already has mon-managed snaps; "
+          "can't attach pool to fs";
+    return -EOPNOTSUPP;
+  }
+
   const string& pool_name = osd_map.get_pool_name(pool_id);
+  auto app_map = pool->application_metadata;
+
+  if (!allow_overlay && !force && !app_map.empty()) {
+    auto app = app_map.find(pg_pool_t::APPLICATION_NAME_CEPHFS);
+    if (app != app_map.end()) {
+      auto& [app_name, app_metadata] = *app;
+      auto itr = app_metadata.find("data");
+      if (itr == app_metadata.end()) {
+       itr = app_metadata.find("metadata");
+      }
+      if (itr != app_metadata.end()) {
+        auto& [type, filesystem] = *itr;
+        *ss << "RADOS pool '" << pool_name << "' is already used by filesystem '"
+            << filesystem << "' as a '" << type << "' pool for application '"
+            << app_name << "'";
+        return -EINVAL;
+      }
+    } else {
+      *ss << "RADOS pool '" << pool_name
+          << "' has another non-CephFS application enabled.";
+      return -EINVAL;
+    }
+  }
 
   if (pool->is_erasure()) {
     if (type == POOL_METADATA) {
@@ -1578,6 +1660,14 @@ int FileSystemCommandHandler::_check_pool(
     return -EINVAL;
   }
 
+  if (type != POOL_METADATA && pool->pg_autoscale_mode == pg_pool_t::pg_autoscale_mode_t::ON && !pool->has_flag(pg_pool_t::FLAG_BULK)) {
+    // TODO: consider issuing an info event in this case
+    *ss << "  Pool '" << pool_name << "' (id '" << pool_id
+       << "') has pg autoscale mode 'on' but is not marked as bulk." << std::endl
+       << "  Consider setting the flag by running" << std::endl
+       << "    # ceph osd pool set " << pool_name << " bulk true" << std::endl;
+  }
+
   // Nothing special about this pool, so it is permissible
   return 0;
 }