osd: loop over uint8_t instead of shard_id_t

When looping in the range [0,number of shards[ using a uint8_t variable
which is an integer instead of shard_id_t. The alternative would be
define the ++ operator on shard_id_t but since the two are used
interchangeably in a number of places, that seems unnecessary.

Signed-off-by: Loic Dachary <loic@dachary.org>
This commit is contained in:
Loic Dachary 2014-05-28 15:36:57 +02:00
parent d723cac03b
commit 20e66d1609
3 changed files with 6 additions and 6 deletions

View File

@ -675,7 +675,7 @@ public:
vector<int> acting;
pg_to_acting_osds(pgid, &acting, &primary);
if (i->second.ec_pool()) {
for (shard_id_t i = 0; i < acting.size(); ++i) {
for (uint8_t i = 0; i < acting.size(); ++i) {
if (acting[i] == primary) {
*out = spg_t(pgid, i);
return true;

View File

@ -953,7 +953,7 @@ void PG::calc_ec_acting(
++i) {
all_info_by_shard[i->first.shard].insert(i->first);
}
for (shard_id_t i = 0; i < want.size(); ++i) {
for (uint8_t i = 0; i < want.size(); ++i) {
ss << "For position " << (unsigned)i << ": ";
if (up.size() > (unsigned)i && up[i] != CRUSH_ITEM_NONE &&
!all_info.find(pg_shard_t(up[i], i))->second.is_incomplete() &&
@ -997,7 +997,7 @@ void PG::calc_ec_acting(
}
bool found_primary = false;
for (shard_id_t i = 0; i < want.size(); ++i) {
for (uint8_t i = 0; i < want.size(); ++i) {
if (want[i] != CRUSH_ITEM_NONE) {
acting_backfill->insert(pg_shard_t(want[i], i));
if (!found_primary) {

View File

@ -1889,7 +1889,7 @@ public:
int new_acting_primary) {
actingset.clear();
acting = newacting;
for (shard_id_t i = 0; i < acting.size(); ++i) {
for (uint8_t i = 0; i < acting.size(); ++i) {
if (acting[i] != CRUSH_ITEM_NONE)
actingset.insert(
pg_shard_t(
@ -1904,13 +1904,13 @@ public:
}
up_primary = pg_shard_t();
primary = pg_shard_t();
for (shard_id_t i = 0; i < up.size(); ++i) {
for (uint8_t i = 0; i < up.size(); ++i) {
if (up[i] == new_up_primary) {
up_primary = pg_shard_t(up[i], i);
break;
}
}
for (shard_id_t i = 0; i < acting.size(); ++i) {
for (uint8_t i = 0; i < acting.size(); ++i) {
if (acting[i] == new_acting_primary) {
primary = pg_shard_t(acting[i], i);
break;