From 600c81d2cc10241c5a2161b9910e8dd26c0babd6 Mon Sep 17 00:00:00 2001 From: sageweil Date: Fri, 30 Nov 2007 21:23:23 +0000 Subject: [PATCH] added pg_swap_primary mechanism in osdmap git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@2163 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/osd/OSDMap.h | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/trunk/ceph/osd/OSDMap.h b/trunk/ceph/osd/OSDMap.h index 9b534b8d46621..ec4c86029cbec 100644 --- a/trunk/ceph/osd/OSDMap.h +++ b/trunk/ceph/osd/OSDMap.h @@ -97,6 +97,8 @@ public: map new_up; map new_down; map new_offload; + map new_pg_swap_primary; + list old_pg_swap_primary; void encode(bufferlist& bl) { ::_encode(fsid, bl); @@ -109,6 +111,8 @@ public: ::_encode(new_up, bl); ::_encode(new_down, bl); ::_encode(new_offload, bl); + ::_encode(new_pg_swap_primary, bl); + ::_encode(old_pg_swap_primary, bl); } void decode(bufferlist& bl, int& off) { ::_decode(fsid, bl, off); @@ -121,6 +125,8 @@ public: ::_decode(new_up, bl, off); ::_decode(new_down, bl, off); ::_decode(new_offload, bl, off); + ::_decode(new_pg_swap_primary, bl, off); + ::_decode(old_pg_swap_primary, bl, off); } Incremental(epoch_t e=0) : epoch(e), mon_epoch(0), new_max_osd(-1) {} @@ -139,6 +145,7 @@ private: int32_t max_osd; vector osd_state; vector osd_addr; + map pg_swap_primary; // force new osd to be pg primary (if already a member) public: CrushWrapper crush; // hierarchical map @@ -316,6 +323,15 @@ private: osd_addr[i->first] = i->second; //cout << "epoch " << epoch << " up osd" << i->first << " at " << i->second << endl; } + + for (map::iterator i = inc.new_pg_swap_primary.begin(); + i != inc.new_pg_swap_primary.begin(); + i++) + pg_swap_primary[i->first] = i->second; + for (list::iterator i = inc.old_pg_swap_primary.begin(); + i != inc.old_pg_swap_primary.begin(); + i++) + pg_swap_primary.erase(*i); } // serialize, unserialize @@ -331,6 +347,7 @@ private: ::_encode(max_osd, blist); ::_encode(osd_state, blist); ::_encode(osd_addr, blist); + ::_encode(pg_swap_primary, blist); bufferlist cbl; crush._encode(cbl); @@ -351,6 +368,7 @@ private: ::_decode(max_osd, blist, off); ::_decode(osd_state, blist, off); ::_decode(osd_addr, blist, off); + ::_decode(pg_swap_primary, blist, off); bufferlist cbl; ::_decode(cbl, blist, off); @@ -406,8 +424,7 @@ private: // pg -> (osd list) - int pg_to_osds(pg_t pg, - vector& osds) { // list of osd addr's + int pg_to_osds(pg_t pg, vector& osds) { // map to osds[] switch (g_conf.osd_pg_layout) { case CEPH_PG_LAYOUT_CRUSH: @@ -485,6 +502,18 @@ private: if (is_out(osd)) osds.erase(osds.begin()); // oops, but it's out } + + // swap primary? + if (pg_swap_primary.count(pg)) { + for (unsigned i=1; i