22
22
#include "msg/msg_types.h"
23
23
#include "include/types.h"
24
#include "include/utime.h"
24
25
#include "include/CompatSet.h"
25
26
#include "include/interval_set.h"
26
27
#include "common/Formatter.h"
106
//#define CEPH_POOL(poolset, size) (((poolset) << 8) + (size))
108
#define OSD_SUPERBLOCK_POBJECT sobject_t(object_t("osd_superblock"), 0)
105
#define OSD_SUPERBLOCK_POBJECT hobject_t(sobject_t(object_t("osd_superblock"), 0))
107
// placement seed (a hash value)
108
typedef uint32_t ps_t;
110
// old (v1) pg_t encoding (wrap old struct ceph_pg)
113
void encode(bufferlist& bl) const {
116
void decode(bufferlist::iterator& bl) {
120
WRITE_CLASS_ENCODER(old_pg_t)
110
122
// placement group id
114
pg_t() { memset(&v, 0, sizeof(v)); }
115
pg_t(const pg_t& o) { v = o.v; }
116
pg_t(ps_t seed, int pool_, int pref) {
119
v.preferred = pref; // hack: avoid negative.
128
pg_t() : m_pool(0), m_seed(0), m_preferred(-1) {}
129
pg_t(ps_t seed, uint64_t pool, int pref) {
121
135
pg_t(const ceph_pg& cpg) {
125
ps_t ps() const { return v.ps; }
126
int pool() const { return v.pool; }
127
int preferred() const { return (__s16)v.preferred; } // hack: avoid negative.
138
m_preferred = (__s16)cpg.preferred;
140
old_pg_t get_old_pg() const {
142
assert(m_pool < 0xffffffffull);
145
o.v.preferred = (__s16)m_preferred;
148
pg_t(const old_pg_t& opg) {
155
uint64_t pool() const {
158
int32_t preferred() const {
162
void set_ps(ps_t p) {
165
void set_pool(uint64_t p) {
168
void set_preferred(int32_t osd) {
129
172
int print(char *o, int maxlen) const;
130
173
bool parse(const char *s);
131
} __attribute__ ((packed));
175
void encode(bufferlist& bl) const {
178
::encode(m_pool, bl);
179
::encode(m_seed, bl);
180
::encode(m_preferred, bl);
182
void decode(bufferlist::iterator& bl) {
185
::decode(m_pool, bl);
186
::decode(m_seed, bl);
187
::decode(m_preferred, bl);
189
void decode_old(bufferlist::iterator& bl) {
195
WRITE_CLASS_ENCODER(pg_t)
133
197
inline bool operator<(const pg_t& l, const pg_t& r) {
134
198
return l.pool() < r.pool() ||
161
225
(l.preferred() == r.preferred() && (l.ps() >= r.ps()))));
165
inline void encode(pg_t pgid, bufferlist& bl) {
166
encode_raw(pgid.v, bl);
168
inline void decode(pg_t &pgid, bufferlist::iterator& p) {
169
decode_raw(pgid.v, p);
172
228
ostream& operator<<(ostream& out, const pg_t &pg);
174
230
namespace __gnu_cxx {
516
576
bool is_rep() const { return get_type() == CEPH_PG_TYPE_REP; }
517
577
bool is_raid4() const { return get_type() == CEPH_PG_TYPE_RAID4; }
519
int get_pg_num() const { return v.pg_num; }
520
int get_pgp_num() const { return v.pgp_num; }
521
int get_lpg_num() const { return v.lpg_num; }
522
int get_lpgp_num() const { return v.lpgp_num; }
579
unsigned get_pg_num() const { return v.pg_num; }
580
unsigned get_pgp_num() const { return v.pgp_num; }
581
unsigned get_lpg_num() const { return v.lpg_num; }
582
unsigned get_lpgp_num() const { return v.lpgp_num; }
524
int get_pg_num_mask() const { return pg_num_mask; }
525
int get_pgp_num_mask() const { return pgp_num_mask; }
526
int get_lpg_num_mask() const { return lpg_num_mask; }
527
int get_lpgp_num_mask() const { return lpgp_num_mask; }
584
unsigned get_pg_num_mask() const { return pg_num_mask; }
585
unsigned get_pgp_num_mask() const { return pgp_num_mask; }
586
unsigned get_lpg_num_mask() const { return lpg_num_mask; }
587
unsigned get_lpgp_num_mask() const { return lpgp_num_mask; }
529
589
int calc_bits_of(int t);
530
590
void calc_pg_masks();
821
881
::decode(log_start, bl);
822
882
::decode(ondisk_log_start, bl);
823
883
::decode(created, bl);
824
::decode(parent, bl);
889
::decode(parent, bl);
825
891
::decode(parent_split_bits, bl);
826
892
::decode(last_scrub, bl);
827
893
::decode(last_scrub_stamp, bl);
1125
1191
void copy_user_bits(const object_info_t& other);
1193
static ps_t legacy_object_locator_to_ps(const object_t &oid,
1194
const object_locator_t &loc);
1127
1196
void encode(bufferlist& bl) const;
1128
1197
void decode(bufferlist::iterator& bl);
1129
1198
void decode(bufferlist& bl) {
1134
object_info_t(const sobject_t& s, const object_locator_t& o)
1203
object_info_t(const hobject_t& s, const object_locator_t& o)
1135
1204
: soid(s), oloc(o), size(0),
1136
1205
lost(false), truncate_seq(0), truncate_size(0) {}
1175
1244
WRITE_CLASS_ENCODER(object)
1177
map<sobject_t,object> objects;
1246
map<hobject_t,object> objects;
1178
1247
map<string,bufferptr> attrs;
1179
1248
bufferlist logbl;
1180
1249
eversion_t valid_through;