Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osd/Pool: Disallow enabling 'hashpspool' option to a pool without '--yes-i-really-mean-it' #13406

Merged
merged 1 commit into from Feb 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -5268,7 +5268,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 @@ -5281,6 +5281,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