mon/OSDMonitor: apply new 'destroyed' status to 'osd tree' filter

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
This commit is contained in:
xie xingguo 2017-07-21 15:08:44 +08:00
parent 3b6bbc416d
commit 96eb0a9887
5 changed files with 44 additions and 21 deletions

View File

@ -1618,12 +1618,16 @@ function test_mon_osd()
ceph osd tree down
ceph osd tree in
ceph osd tree out
ceph osd tree destroyed
ceph osd tree up in
ceph osd tree up out
ceph osd tree down in
ceph osd tree down out
ceph osd tree out down
expect_false ceph osd tree up down
expect_false ceph osd tree up destroyed
expect_false ceph osd tree down destroyed
expect_false ceph osd tree up down destroyed
expect_false ceph osd tree in out
expect_false ceph osd tree up foo

View File

@ -460,7 +460,7 @@ COMMAND("osd dump " \
"print summary of OSD map", "osd", "r", "cli,rest")
COMMAND("osd tree " \
"name=epoch,type=CephInt,range=0,req=false " \
"name=states,type=CephChoices,strings=up|down|in|out,n=N,req=false", \
"name=states,type=CephChoices,strings=up|down|in|out|destroyed,n=N,req=false", \
"print OSD tree", "osd", "r", "cli,rest")
COMMAND("osd ls " \
"name=epoch,type=CephInt,range=0,req=false", \

View File

@ -4137,6 +4137,8 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
filter |= OSDMap::DUMP_IN;
} else if (s == "out") {
filter |= OSDMap::DUMP_OUT;
} else if (s == "destroyed") {
filter |= OSDMap::DUMP_DESTROYED;
} else {
ss << "unrecognized state '" << s << "'";
r = -EINVAL;
@ -4144,10 +4146,18 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
}
}
if ((filter & (OSDMap::DUMP_IN|OSDMap::DUMP_OUT)) ==
(OSDMap::DUMP_IN|OSDMap::DUMP_OUT) ||
(filter & (OSDMap::DUMP_UP|OSDMap::DUMP_DOWN)) ==
(OSDMap::DUMP_UP|OSDMap::DUMP_DOWN)) {
ss << "cannot specify both up and down or both in and out";
(OSDMap::DUMP_IN|OSDMap::DUMP_OUT)) {
ss << "cannot specify both 'in' and 'out'";
r = -EINVAL;
goto reply;
}
if (((filter & (OSDMap::DUMP_UP|OSDMap::DUMP_DOWN)) ==
(OSDMap::DUMP_UP|OSDMap::DUMP_DOWN)) ||
((filter & (OSDMap::DUMP_UP|OSDMap::DUMP_DESTROYED)) ==
(OSDMap::DUMP_UP|OSDMap::DUMP_DESTROYED)) ||
((filter & (OSDMap::DUMP_DOWN|OSDMap::DUMP_DESTROYED)) ==
(OSDMap::DUMP_DOWN|OSDMap::DUMP_DESTROYED))) {
ss << "can specify only one of 'up', 'down' and 'destroyed'";
r = -EINVAL;
goto reply;
}

View File

@ -3056,13 +3056,17 @@ public:
: Parent(crush, osdmap_->get_pool_names()), osdmap(osdmap_), filter(f) { }
bool should_dump_leaf(int i) const override {
if (((filter & OSDMap::DUMP_UP) && !osdmap->is_up(i)) ||
((filter & OSDMap::DUMP_DOWN) && !osdmap->is_down(i)) ||
((filter & OSDMap::DUMP_IN) && !osdmap->is_in(i)) ||
((filter & OSDMap::DUMP_OUT) && !osdmap->is_out(i))) {
return false;
if (!filter) {
return true; // normal case
}
return true;
if (((filter & OSDMap::DUMP_UP) && osdmap->is_up(i)) ||
((filter & OSDMap::DUMP_DOWN) && osdmap->is_down(i)) ||
((filter & OSDMap::DUMP_IN) && osdmap->is_in(i)) ||
((filter & OSDMap::DUMP_OUT) && osdmap->is_out(i)) ||
((filter & OSDMap::DUMP_DESTROYED) && osdmap->is_destroyed(i))) {
return true;
}
return false;
}
bool should_dump_empty_bucket() const override {
@ -3142,13 +3146,17 @@ public:
: Parent(crush, osdmap_->get_pool_names()), osdmap(osdmap_), filter(f) { }
bool should_dump_leaf(int i) const override {
if (((filter & OSDMap::DUMP_UP) && !osdmap->is_up(i)) ||
((filter & OSDMap::DUMP_DOWN) && !osdmap->is_down(i)) ||
((filter & OSDMap::DUMP_IN) && !osdmap->is_in(i)) ||
((filter & OSDMap::DUMP_OUT) && !osdmap->is_out(i))) {
return false;
if (!filter) {
return true; // normal case
}
return true;
if (((filter & OSDMap::DUMP_UP) && osdmap->is_up(i)) ||
((filter & OSDMap::DUMP_DOWN) && osdmap->is_down(i)) ||
((filter & OSDMap::DUMP_IN) && osdmap->is_in(i)) ||
((filter & OSDMap::DUMP_OUT) && osdmap->is_out(i)) ||
((filter & OSDMap::DUMP_DESTROYED) && osdmap->is_destroyed(i))) {
return true;
}
return false;
}
bool should_dump_empty_bucket() const override {

View File

@ -1345,10 +1345,11 @@ public:
void print_oneline_summary(ostream& out) const;
enum {
DUMP_IN = 1, // only 'in' osds
DUMP_OUT = 2, // only 'out' osds
DUMP_UP = 4, // only 'up' osds
DUMP_DOWN = 8, // only 'down' osds
DUMP_IN = 1, // only 'in' osds
DUMP_OUT = 2, // only 'out' osds
DUMP_UP = 4, // only 'up' osds
DUMP_DOWN = 8, // only 'down' osds
DUMP_DESTROYED = 16, // only 'destroyed' osds
};
void print_tree(Formatter *f, ostream *out, unsigned dump_flags=0) const;