Skip to content

Commit

Permalink
Merge pull request #18699 from shinobu-x/wip-luminous-21538
Browse files Browse the repository at this point in the history
luminous: upmap does not respect osd reweights

Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
tchaikov committed Nov 8, 2017
2 parents 31afe85 + cd18f84 commit 2e11e66
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/osd/OSDMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3871,8 +3871,9 @@ int OSDMap::calc_pg_upmaps(
tmp.crush->get_rule_weight_osd_map(ruleno, &pmap);
ldout(cct,30) << __func__ << " pool " << i.first << " ruleno " << ruleno << dendl;
for (auto p : pmap) {
osd_weight[p.first] += p.second;
osd_weight_total += p.second;
auto adjusted_weight = tmp.get_weightf(p.first) * p.second;
osd_weight[p.first] += adjusted_weight;
osd_weight_total += adjusted_weight;
}
}
for (auto& i : osd_weight) {
Expand Down
1 change: 1 addition & 0 deletions src/test/cli/osdmaptool/help.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
--test-map-pgs-dump-all [--pool <poolid>] map all pgs to osds
--health dump health checks
--mark-up-in mark osds up and in (but do not persist)
--mark-out <osdid> mark an osd as out (but do not persist)
--with-default-pool include default pool when creating map
--clear-temp clear pg_temp and primary_temp
--test-random do random placements
Expand Down
1 change: 1 addition & 0 deletions src/test/cli/osdmaptool/missing-argument.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
--test-map-pgs-dump-all [--pool <poolid>] map all pgs to osds
--health dump health checks
--mark-up-in mark osds up and in (but do not persist)
--mark-out <osdid> mark an osd as out (but do not persist)
--with-default-pool include default pool when creating map
--clear-temp clear pg_temp and primary_temp
--test-random do random placements
Expand Down
23 changes: 23 additions & 0 deletions src/test/cli/osdmaptool/upmap-out.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
$ osdmaptool --create-from-conf om -c $TESTDIR/ceph.conf.withracks --with-default-pool
osdmaptool: osdmap file 'om'
osdmaptool: writing epoch 1 to om
$ osdmaptool om --mark-up-in --mark-out 147 --upmap-max 11 --upmap c
osdmaptool: osdmap file 'om'
marking all OSDs up and in
marking OSD@147 as out
writing upmap command output to: c
checking for upmap cleanups
upmap, max-count 11, max deviation 0.01
$ cat c
ceph osd pg-upmap-items 1.7 142 145
ceph osd pg-upmap-items 1.8 219 223 99 103
ceph osd pg-upmap-items 1.17 171 173 201 202
ceph osd pg-upmap-items 1.1a 201 202 115 114
ceph osd pg-upmap-items 1.1c 171 173 201 202 127 130
ceph osd pg-upmap-items 1.20 88 87 201 202
ceph osd pg-upmap-items 1.21 207 206 142 145
ceph osd pg-upmap-items 1.51 201 202 65 64 186 189
ceph osd pg-upmap-items 1.62 219 223
ceph osd pg-upmap-items 1.6f 219 223 108 111
ceph osd pg-upmap-items 1.82 219 223 157 158 6 3
$ rm -f om c
13 changes: 13 additions & 0 deletions src/tools/osdmaptool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void usage()
cout << " --test-map-pgs-dump-all [--pool <poolid>] map all pgs to osds" << std::endl;
cout << " --health dump health checks" << std::endl;
cout << " --mark-up-in mark osds up and in (but do not persist)" << std::endl;
cout << " --mark-out <osdid> mark an osd as out (but do not persist)" << std::endl;
cout << " --with-default-pool include default pool when creating map" << std::endl;
cout << " --clear-temp clear pg_temp and primary_temp" << std::endl;
cout << " --test-random do random placements" << std::endl;
Expand Down Expand Up @@ -116,6 +117,7 @@ int main(int argc, const char **argv)
int range_last = -1;
int pool = -1;
bool mark_up_in = false;
int marked_out = -1;
bool clear_temp = false;
bool test_map_pgs = false;
bool test_map_pgs_dump = false;
Expand Down Expand Up @@ -175,6 +177,8 @@ int main(int argc, const char **argv)
create_from_conf = true;
} else if (ceph_argparse_flag(args, i, "--mark-up-in", (char*)NULL)) {
mark_up_in = true;
} else if (ceph_argparse_witharg(args, i, &val, "--mark-out", (char*)NULL)) {
marked_out = std::stoi(val);
} else if (ceph_argparse_flag(args, i, "--clear-temp", (char*)NULL)) {
clear_temp = true;
} else if (ceph_argparse_flag(args, i, "--test-map-pgs", (char*)NULL)) {
Expand Down Expand Up @@ -317,6 +321,15 @@ int main(int argc, const char **argv)
osdmap.crush->adjust_item_weightf(g_ceph_context, i, 1.0);
}
}

if (marked_out >=0 && marked_out < osdmap.get_max_osd()) {
cout << "marking OSD@" << marked_out << " as out" << std::endl;
int id = marked_out;
osdmap.set_state(id, osdmap.get_state(id) | CEPH_OSD_UP);
osdmap.set_weight(id, CEPH_OSD_OUT);
osdmap.crush->adjust_item_weightf(g_ceph_context, id, 1.0);
}

if (clear_temp) {
cout << "clearing pg/primary temp" << std::endl;
osdmap.clear_temp();
Expand Down

0 comments on commit 2e11e66

Please sign in to comment.