Skip to content

Commit

Permalink
osd/OSDMap: make get prev/next up osd more efficient
Browse files Browse the repository at this point in the history
what's more, in get_previous_up_osd_before(), if arg n = 0, run into endless loop

Signed-off-by: Mingxin Liu <mingxin@xsky.com>
  • Loading branch information
LiumxNL committed Jan 18, 2017
1 parent a7b7862 commit a37765c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/osd/OSDMap.h
Expand Up @@ -525,6 +525,8 @@ class OSDMap {
}

int get_next_up_osd_after(int n) const {
if (get_max_osd() == 0)
return -1;
for (int i = n + 1; i != n; ++i) {
if (i >= get_max_osd())
i = 0;
Expand All @@ -537,6 +539,8 @@ class OSDMap {
}

int get_previous_up_osd_before(int n) const {
if (get_max_osd() == 0)
return -1;
for (int i = n - 1; i != n; --i) {
if (i < 0)
i = get_max_osd() - 1;
Expand Down

0 comments on commit a37765c

Please sign in to comment.