Project

General

Profile

Actions

Bug #2448

closed

osdmap: mapping doesn't work without encoding and decoding

Added by Josh Durgin almost 12 years ago. Updated almost 12 years ago.

Status:
Resolved
Priority:
High
Assignee:
-
Category:
OSDMap
Target version:
-
% Done:

0%

Source:
Community (dev)
Tags:
Backport:
dho
Regression:
Severity:
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

adamcrume on irc was having trouble with this sample program only mapping to the same two osds for all objects. encoding/decoding the OSDMap makes it map to more than 2 osds.

#include "osd/OSDMap.h" 
#include "common/code_environment.h" 

int main() {
    OSDMap *osdmap = new OSDMap();
    CephContext *cct = new CephContext(CODE_ENVIRONMENT_UTILITY);
    uuid_d fsid;
    int num_osds = 10;
    osdmap->build_simple(cct, 0, fsid, num_osds, 7, 8);
    for(int i = 0; i < num_osds; i++) {
        osdmap->set_state(i, osdmap->get_state(i) | CEPH_OSD_UP | CEPH_OSD_EXISTS);
        osdmap->set_weight(i, CEPH_OSD_IN);
    }
    osdmap->calc_num_osds();
    osdmap->print(cout);
    osdmap->print_tree(cout);

    bufferlist bl;
    osdmap->encode(bl);
    osdmap = new OSDMap();
    osdmap->decode(bl);

    int i;
    for(i = 0; i < 4; i++) {
        int j;
        for(j = 0; j < 4; j++) {
            char foo[20];
            snprintf(foo, sizeof(foo), "%08x.%08x", i, j);
            object_t oid(foo);
            object_locator_t oloc(1);
            pg_t pgid = osdmap->object_locator_to_pg(oid, oloc);
            vector<int> raw, up, acting;
            osdmap->pg_to_osds(pgid, raw);
            osdmap->pg_to_up_acting_osds(pgid, up, acting);
            cout << "OID: " << oid << " RAW: " << raw << " PG: " << pgid << " UP: " << up << " ACTING: " << acting << std::endl;
        }
    }
}
Actions #1

Updated by Sage Weil almost 12 years ago

  • Priority changed from Normal to High
Actions #2

Updated by Sage Weil almost 12 years ago

  • Backport set to dho
Actions #3

Updated by Sage Weil almost 12 years ago

  • Status changed from New to Resolved
Actions

Also available in: Atom PDF