~ubuntu-branches/ubuntu/raring/ceph/raring

« back to all changes in this revision

Viewing changes to src/messages/MOSDMap.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-08 15:54:37 UTC
  • mfrom: (0.3.9)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: package-import@ubuntu.com-20120608155437-30vek4y2gu92vhad
Tags: upstream-0.44.1
ImportĀ upstreamĀ versionĀ 0.44.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
#include "msg/Message.h"
20
20
#include "osd/OSDMap.h"
21
 
 
 
21
#include "include/ceph_features.h"
22
22
 
23
23
class MOSDMap : public Message {
 
24
 
 
25
  static const int HEAD_VERSION = 3;
 
26
 
24
27
 public:
25
28
  uuid_d fsid;
26
29
  map<epoch_t, bufferlist> maps;
27
30
  map<epoch_t, bufferlist> incremental_maps;
28
31
  epoch_t oldest_map, newest_map;
29
32
 
30
 
  epoch_t get_first() {
 
33
  epoch_t get_first() const {
31
34
    epoch_t e = 0;
32
 
    map<epoch_t, bufferlist>::iterator i = maps.begin();
 
35
    map<epoch_t, bufferlist>::const_iterator i = maps.begin();
33
36
    if (i != maps.end())  e = i->first;
34
37
    i = incremental_maps.begin();    
35
38
    if (i != incremental_maps.end() &&
36
39
        (e == 0 || i->first < e)) e = i->first;
37
40
    return e;
38
41
  }
39
 
  epoch_t get_last() {
 
42
  epoch_t get_last() const {
40
43
    epoch_t e = 0;
41
 
    map<epoch_t, bufferlist>::reverse_iterator i = maps.rbegin();
 
44
    map<epoch_t, bufferlist>::const_reverse_iterator i = maps.rbegin();
42
45
    if (i != maps.rend())  e = i->first;
43
46
    i = incremental_maps.rbegin();    
44
47
    if (i != incremental_maps.rend() &&
53
56
  }
54
57
 
55
58
 
56
 
  MOSDMap() : Message(CEPH_MSG_OSD_MAP) { }
 
59
  MOSDMap() : Message(CEPH_MSG_OSD_MAP, HEAD_VERSION) { }
57
60
  MOSDMap(const uuid_d &f, OSDMap *oc=0)
58
 
    : Message(CEPH_MSG_OSD_MAP), fsid(f),
59
 
      oldest_map(0), newest_map(0)
60
 
  {
 
61
    : Message(CEPH_MSG_OSD_MAP, HEAD_VERSION),
 
62
      fsid(f),
 
63
      oldest_map(0), newest_map(0) {
61
64
    if (oc)
62
65
      oc->encode(maps[oc->get_epoch()]);
63
66
  }
66
69
 
67
70
public:
68
71
  // marshalling
69
 
  void decode_payload(CephContext *cct) {
 
72
  void decode_payload() {
70
73
    bufferlist::iterator p = payload.begin();
71
74
    ::decode(fsid, p);
72
75
    ::decode(incremental_maps, p);
73
76
    ::decode(maps, p);
74
 
    if (header.version > 1) {
 
77
    if (header.version >= 2) {
75
78
      ::decode(oldest_map, p);
76
79
      ::decode(newest_map, p);
77
80
    } else {
79
82
      newest_map = 0;
80
83
    }
81
84
  }
82
 
  void encode_payload(CephContext *cct) {
 
85
  void encode_payload(uint64_t features) {
83
86
    ::encode(fsid, payload);
84
 
    header.version = 2;
85
 
    if (connection && (!connection->has_feature(CEPH_FEATURE_PGID64) ||
86
 
                       !connection->has_feature(CEPH_FEATURE_PGPOOL3))) {
 
87
    if ((features & CEPH_FEATURE_PGID64) == 0 ||
 
88
        (features & CEPH_FEATURE_PGPOOL3) == 0 ||
 
89
        (features & CEPH_FEATURE_OSDENC) == 0) {
 
90
      if ((features & CEPH_FEATURE_PGID64) == 0 ||
 
91
          (features & CEPH_FEATURE_PGPOOL3) == 0)
 
92
        header.version = 1;  // old old_client version
 
93
      else
 
94
        header.version = 2;  // old pg_pool_t
 
95
 
87
96
      // reencode maps using old format
88
97
      //
89
98
      // FIXME: this can probably be done more efficiently higher up
101
110
          OSDMap m;
102
111
          m.decode(inc.fullmap);
103
112
          inc.fullmap.clear();
104
 
          m.encode(inc.fullmap, connection->get_features());
 
113
          m.encode(inc.fullmap, features);
105
114
        }
106
 
        inc.encode(p->second, connection->get_features());
 
115
        inc.encode(p->second, features);
107
116
      }
108
117
      for (map<epoch_t,bufferlist>::iterator p = maps.begin();
109
118
           p != maps.end();
111
120
        OSDMap m;
112
121
        m.decode(p->second);
113
122
        p->second.clear();
114
 
        m.encode(p->second, connection->get_features());
 
123
        m.encode(p->second, features);
115
124
      }
116
 
      header.version = 1;
117
125
    }
118
126
    ::encode(incremental_maps, payload);
119
127
    ::encode(maps, payload);
123
131
    }
124
132
  }
125
133
 
126
 
  const char *get_type_name() { return "omap"; }
127
 
  void print(ostream& out) {
 
134
  const char *get_type_name() const { return "omap"; }
 
135
  void print(ostream& out) const {
128
136
    out << "osd_map(" << get_first() << ".." << get_last();
129
137
    if (oldest_map || newest_map)
130
138
      out << " src has " << oldest_map << ".." << newest_map;