]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: fix the 'Error ERANGE' message when conf "osd_objectstore" is filestore 37474/head
authorwangyunqing <wangyunqing@inspur.com>
Thu, 16 Jul 2020 07:06:53 +0000 (15:06 +0800)
committerNathan Cutler <ncutler@suse.com>
Tue, 29 Sep 2020 17:09:26 +0000 (19:09 +0200)
Fixes: https://tracker.ceph.com/issues/37532
Signed-off-by: wangyunqing <wangyunqing@inspur.com>
(cherry picked from commit 4155a79f76b177ada79af746de4448773e07584a)

Conflicts:
        src/mon/OSDMonitor.cc
- in nautilus, "cmd_getval()" needs cct as first argument

src/mon/OSDMonitor.cc

index ff705201381568d53bc99660592283e30e331a6d..601abc88b910ee22e0597a8fef86604cf2f815cf 100644 (file)
@@ -12185,22 +12185,38 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       goto reply;
     }
 
-    if (expected_num_objects > 0 &&
-       cct->_conf->osd_objectstore == "filestore" &&
-       cct->_conf->filestore_merge_threshold > 0) {
+    set<int32_t> osds;
+    osdmap.get_all_osds(osds);
+    bool has_filestore_osd = std::any_of(osds.begin(), osds.end(), [this](int osd) {
+      string type;
+      if (!get_osd_objectstore_type(osd, &type)) {
+        return type == "filestore";
+      } else {
+        return false;
+      }
+    });
+
+    if (has_filestore_osd &&
+        expected_num_objects > 0 &&
+        cct->_conf->filestore_merge_threshold > 0) {
       ss << "'expected_num_objects' requires 'filestore_merge_threshold < 0'";
       err = -EINVAL;
       goto reply;
     }
 
-    if (expected_num_objects == 0 &&
-       cct->_conf->osd_objectstore == "filestore" &&
-       cct->_conf->filestore_merge_threshold < 0) {
+    if (has_filestore_osd &&
+        expected_num_objects == 0 &&
+        cct->_conf->filestore_merge_threshold < 0) {
       int osds = osdmap.get_num_osds();
-      if (osds && (pg_num >= 1024 || pg_num / osds >= 100)) {
+      bool sure = false;
+      cmd_getval(cct, cmdmap, "yes_i_really_mean_it", sure);
+      if (!sure && osds && (pg_num >= 1024 || pg_num / osds >= 100)) {
         ss << "For better initial performance on pools expected to store a "
-          << "large number of objects, consider supplying the "
-          << "expected_num_objects parameter when creating the pool.\n";
+           << "large number of objects, consider supplying the "
+           << "expected_num_objects parameter when creating the pool."
+           << " Pass --yes-i-really-mean-it to ignore it";
+        err = -EPERM;
+        goto reply;
       }
     }