]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: require force argument to split a cache pool 1681/head
authorSage Weil <sage@inktank.com>
Tue, 15 Apr 2014 20:57:21 +0000 (13:57 -0700)
committerSage Weil <sage@inktank.com>
Tue, 15 Apr 2014 20:57:21 +0000 (13:57 -0700)
There are several perils when splitting a cache pool:

 - split invalidstes pg stats, which disables the agent
 - a scrub must be manually triggered post-split to rebuild stats
 - the pool may fill the OSDs during that period.
 - or, the pool may end up beyond the 'full' mark and once scrub does
   complete and the agent activate we may block IO for a long time while
   we catch up with flush/evict

Make it a bit harder for users to shoot themselves in the foot.

Fixes: #8043
Signed-off-by: Sage Weil <sage@inktank.com>
qa/workunits/cephtool/test.sh
src/mon/MonCommands.h
src/mon/OSDMonitor.cc

index 53ec1f93d6a8b342624a062bcb22a4b5263c300e..63d6b365fd09cc4b250fda1f158ea7e67ac9afce 100755 (executable)
@@ -60,6 +60,8 @@ ceph osd tier add data cache2
 expect_false ceph osd tier add metadata cache
 ceph osd tier cache-mode cache writeback
 ceph osd tier cache-mode cache readonly
+expect_false ceph osd pool set cache pg_num 3
+ceph osd pool set cache pg_num 3 --yes-i-really-mean-it
 ceph osd tier cache-mode cache none
 ceph osd tier set-overlay data cache
 expect_false ceph osd tier set-overlay data cache2
index 84af3d6a6241b03090be9cfb27ceb6cd1597ea43..9fb83e251731c061da4763a383fbdd672acf4688 100644 (file)
@@ -557,7 +557,8 @@ COMMAND("osd pool get " \
 COMMAND("osd pool set " \
        "name=pool,type=CephPoolname " \
        "name=var,type=CephChoices,strings=size|min_size|crash_replay_interval|pg_num|pgp_num|crush_ruleset|hashpspool|hit_set_type|hit_set_period|hit_set_count|hit_set_fpp|debug_fake_ec_pool|target_max_bytes|target_max_objects|cache_target_dirty_ratio|cache_target_full_ratio|cache_min_flush_age|cache_min_evict_age " \
-       "name=val,type=CephString", \
+       "name=val,type=CephString " \
+       "name=force,type=CephChoices,strings=--yes-i-really-mean-it,req=false", \
        "set pool parameter <var> to <val>", "osd", "rw", "cli,rest")
 // 'val' is a CephString because it can include a unit.  Perhaps
 // there should be a Python type for validation/conversion of strings
index d171e1f0ab2f8c55feca7d4573202de4f275cc9c..eb0561b07831eeb5f91f240a82fecd66ae3b4fd6 100644 (file)
@@ -3324,6 +3324,13 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
        return -EEXIST;
       return 0;
     }
+    string force;
+    cmd_getval(g_ceph_context,cmdmap, "force", force);
+    if (p.cache_mode != pg_pool_t::CACHEMODE_NONE &&
+       force != "--yes-i-really-mean-it") {
+      ss << "splits in cache pools must be followed by scrubs and leave sufficient free space to avoid overfilling.  use --yes-i-really-mean-it to force.";
+      return -EPERM;
+    }
     int expected_osds = MIN(p.get_pg_num(), osdmap.get_num_osds());
     int64_t new_pgs = n - p.get_pg_num();
     int64_t pgs_per_osd = new_pgs / expected_osds;