Skip to content

Commit

Permalink
Merge pull request #13406 from vumrao/wip-vumrao-18486
Browse files Browse the repository at this point in the history
osd/Pool: Disallow enabling 'hashpspool' option to a pool without  '--yes-i-really-mean-it'

Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
tchaikov committed Feb 16, 2017
2 parents 42d4bf7 + 3715362 commit f91fa5a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
8 changes: 7 additions & 1 deletion qa/workunits/cephtool/test.sh
Expand Up @@ -1467,7 +1467,7 @@ function test_mon_osd_pool_set()
ceph --format=xml osd pool get $TEST_POOL_GETSET auid | grep $auid
ceph osd pool set $TEST_POOL_GETSET auid 0

for flag in hashpspool nodelete nopgchange nosizechange write_fadvise_dontneed noscrub nodeep-scrub; do
for flag in nodelete nopgchange nosizechange write_fadvise_dontneed noscrub nodeep-scrub; do
ceph osd pool set $TEST_POOL_GETSET $flag false
ceph osd pool get $TEST_POOL_GETSET $flag | grep "$flag: false"
ceph osd pool set $TEST_POOL_GETSET $flag true
Expand Down Expand Up @@ -1540,6 +1540,12 @@ function test_mon_osd_pool_set()
ceph osd pool set $TEST_POOL_GETSET size 2
wait_for_clean
ceph osd pool set $TEST_POOL_GETSET min_size 2

expect_false ceph osd pool set $TEST_POOL_GETSET hashpspool 0
ceph osd pool set $TEST_POOL_GETSET hashpspool 0 --yes-i-really-mean-it

expect_false ceph osd pool set $TEST_POOL_GETSET hashpspool 1
ceph osd pool set $TEST_POOL_GETSET hashpspool 1 --yes-i-really-mean-it

ceph osd pool set $TEST_POOL_GETSET nodelete 1
expect_false ceph osd pool delete $TEST_POOL_GETSET $TEST_POOL_GETSET --yes-i-really-really-mean-it
Expand Down
21 changes: 20 additions & 1 deletion src/mon/OSDMonitor.cc
Expand Up @@ -5271,7 +5271,7 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
return -EINVAL;
}
p.crush_ruleset = n;
} else if (var == "hashpspool" || var == "nodelete" || var == "nopgchange" ||
} else if (var == "nodelete" || var == "nopgchange" ||
var == "nosizechange" || var == "write_fadvise_dontneed" ||
var == "noscrub" || var == "nodeep-scrub") {
uint64_t flag = pg_pool_t::get_flag_by_name(var);
Expand All @@ -5284,6 +5284,25 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
ss << "expecting value 'true', 'false', '0', or '1'";
return -EINVAL;
}
} else if (var == "hashpspool") {
uint64_t flag = pg_pool_t::get_flag_by_name(var);
string force;
cmd_getval(g_ceph_context, cmdmap, "force", force);
if (force != "--yes-i-really-mean-it") {
ss << "are you SURE? this will remap all placement groups in this pool,"
" this triggers large data movement,"
" pass --yes-i-really-mean-it if you really do.";
return -EPERM;
}
// make sure we only compare against 'n' if we didn't receive a string
if (val == "true" || (interr.empty() && n == 1)) {
p.set_flag(flag);
} else if (val == "false" || (interr.empty() && n == 0)) {
p.unset_flag(flag);
} else {
ss << "expecting value 'true', 'false', '0', or '1'";
return -EINVAL;
}
} else if (var == "hit_set_type") {
if (val == "none")
p.hit_set_params = HitSet::Params();
Expand Down
7 changes: 1 addition & 6 deletions src/test/mon/misc.sh
Expand Up @@ -42,12 +42,7 @@ function TEST_osd_pool_get_set() {
run_mon $dir a || return 1

local flag
for flag in hashpspool nodelete nopgchange nosizechange write_fadvise_dontneed noscrub nodeep-scrub; do
if [ $flag = hashpspool ]; then
ceph osd dump | grep 'pool ' | grep $flag || return 1
else
! ceph osd dump | grep 'pool ' | grep $flag || return 1
fi
for flag in nodelete nopgchange nosizechange write_fadvise_dontneed noscrub nodeep-scrub; do
ceph osd pool set $TEST_POOL $flag 0 || return 1
! ceph osd dump | grep 'pool ' | grep $flag || return 1
ceph osd pool set $TEST_POOL $flag 1 || return 1
Expand Down

0 comments on commit f91fa5a

Please sign in to comment.