v0.18
- basic ENOSPC handling
+- big endian fix
+
- qa
- osd: rebuild pg log
sbl.substr_of(bl, 0, t);
ObjectStore::Transaction tr;
sobject_t oid(poid, 0);
- tr.write(0, oid, off, t, sbl);
+ tr.write(coll_t(), oid, off, t, sbl);
store->apply_transaction(tr);
off += t;
s -= t;
ObjectStore::Transaction t;
sobject_t oid(poid, 0);
- t.remove(0, oid);
+ t.remove(coll_t(), oid);
store->apply_transaction(t);
age_free_oids.push_back(poid);
}
object_t oid("disk_bw_test");
for (int i=0; i<1000; i++) {
ObjectStore::Transaction t;
- t.write(0, sobject_t(oid, 0), i*bl.length(), bl.length(), bl);
+ t.write(meta_coll, sobject_t(oid, 0), i*bl.length(), bl.length(), bl);
store->apply_transaction(t);
}
store->sync();
end -= start;
cout << "measured " << (1000.0 / (double)end) << " mb/sec" << std::endl;
ObjectStore::Transaction tr;
- tr.remove(0, sobject_t(oid, 0));
+ tr.remove(meta_coll, sobject_t(oid, 0));
store->apply_transaction(tr);
// set osd weight
::encode(sb, bl);
ObjectStore::Transaction t;
- t.create_collection(0);
- t.write(0, OSD_SUPERBLOCK_POBJECT, 0, bl.length(), bl);
+ t.create_collection(meta_coll);
+ t.write(meta_coll, OSD_SUPERBLOCK_POBJECT, 0, bl.length(), bl);
int r = store->apply_transaction(t);
store->umount();
delete store;
OSDSuperblock sb;
bufferlist bl;
- err = store->read(0, OSD_SUPERBLOCK_POBJECT, 0, 0, bl);
+ err = store->read(meta_coll, OSD_SUPERBLOCK_POBJECT, 0, 0, bl);
store->umount();
delete store;
bufferlist bl;
::encode(superblock, bl);
- t.write(0, OSD_SUPERBLOCK_POBJECT, 0, bl.length(), bl);
+ t.write(meta_coll, OSD_SUPERBLOCK_POBJECT, 0, bl.length(), bl);
}
int OSD::read_superblock()
{
bufferlist bl;
- int r = store->read(0, OSD_SUPERBLOCK_POBJECT, 0, 0, bl);
+ int r = store->read(meta_coll, OSD_SUPERBLOCK_POBJECT, 0, 0, bl);
if (r < 0)
return r;
for (vector<coll_t>::iterator it = ls.begin();
it != ls.end();
it++) {
- if (*it == 0)
+ if (*it == meta_coll)
continue;
if (it->snap != CEPH_NOSNAP)
continue;
p != m->maps.end();
p++) {
sobject_t poid = get_osdmap_pobject_name(p->first);
- if (store->exists(0, poid)) {
+ if (store->exists(meta_coll, poid)) {
dout(10) << "handle_osd_map already had full map epoch " << p->first << dendl;
logger->inc(l_osd_mapfdup);
bufferlist bl;
dout(10) << "handle_osd_map got full map epoch " << p->first << dendl;
ObjectStore::Transaction ft;
- ft.write(0, poid, 0, p->second.length(), p->second); // store _outside_ transaction; activate_map reads it.
+ ft.write(meta_coll, poid, 0, p->second.length(), p->second); // store _outside_ transaction; activate_map reads it.
int r = store->apply_transaction(ft);
if (r) {
char buf[80];
p != m->incremental_maps.end();
p++) {
sobject_t poid = get_inc_osdmap_pobject_name(p->first);
- if (store->exists(0, poid)) {
+ if (store->exists(meta_coll, poid)) {
dout(10) << "handle_osd_map already had incremental map epoch " << p->first << dendl;
logger->inc(l_osd_mapidup);
bufferlist bl;
dout(10) << "handle_osd_map got incremental map epoch " << p->first << dendl;
ObjectStore::Transaction ft;
- ft.write(0, poid, 0, p->second.length(), p->second); // store _outside_ transaction; activate_map reads it.
+ ft.write(meta_coll, poid, 0, p->second.length(), p->second); // store _outside_ transaction; activate_map reads it.
int r = store->apply_transaction(ft);
if (r) {
char buf[80];
OSDMap::Incremental inc;
if (m->incremental_maps.count(cur+1) ||
- store->exists(0, get_inc_osdmap_pobject_name(cur+1))) {
+ store->exists(meta_coll, get_inc_osdmap_pobject_name(cur+1))) {
dout(10) << "handle_osd_map decoding inc map epoch " << cur+1 << dendl;
bufferlist bl;
bl.clear();
osdmap->encode(bl);
ObjectStore::Transaction ft;
- ft.write(0, get_osdmap_pobject_name(cur+1), 0, bl.length(), bl);
+ ft.write(meta_coll, get_osdmap_pobject_name(cur+1), 0, bl.length(), bl);
int r = store->apply_transaction(ft);
if (r) {
char buf[80];
}
}
else if (m->maps.count(cur+1) ||
- store->exists(0, get_osdmap_pobject_name(cur+1))) {
+ store->exists(meta_coll, get_osdmap_pobject_name(cur+1))) {
dout(10) << "handle_osd_map decoding full map epoch " << cur+1 << dendl;
bufferlist bl;
if (m->maps.count(cur+1))
bool OSD::get_map_bl(epoch_t e, bufferlist& bl)
{
- return store->read(0, get_osdmap_pobject_name(e), 0, 0, bl) >= 0;
+ return store->read(meta_coll, get_osdmap_pobject_name(e), 0, 0, bl) >= 0;
}
bool OSD::get_inc_map_bl(epoch_t e, bufferlist& bl)
{
- return store->read(0, get_inc_osdmap_pobject_name(e), 0, 0, bl) >= 0;
+ return store->read(meta_coll, get_inc_osdmap_pobject_name(e), 0, 0, bl) >= 0;
}
OSDMap *OSD::get_map(epoch_t epoch)
{
ObjectStore::Transaction t;
pg->write_info(t);
- t.remove(0, pg->log_oid);
+ t.remove(meta_coll, pg->log_oid);
int tr = store->apply_transaction(t);
assert(tr == 0);
}
ondisklog.head = bl.length();
// write it
- t.remove(0, log_oid );
- t.write(0, log_oid , 0, bl.length(), bl);
+ t.remove(meta_coll, log_oid );
+ t.write(meta_coll, log_oid , 0, bl.length(), bl);
bufferlist blb(sizeof(ondisklog));
::encode(ondisklog, blb);
t.collection_setattr(coll_t::build_pg_coll(info.pgid), "ondisklog", blb);
if (!g_conf.osd_preserve_trimmed_log)
- t.zero(0, log_oid, 0, ondisklog.tail & ~4095);
+ t.zero(meta_coll, log_oid, 0, ondisklog.tail & ~4095);
}
void PG::trim_peers()
if (ondisklog.head % 4096 < (ondisklog.head + bl.length()) % 4096)
ondisklog.block_map[ondisklog.head] = log_version; // log_version is last event in prev. block
- t.write(0, log_oid, ondisklog.head, bl.length(), bl );
+ t.write(meta_coll, log_oid, ondisklog.head, bl.length(), bl );
ondisklog.head += bl.length();
if (ondisklog.head > 0) {
// read
bufferlist bl;
- store->read(0, log_oid, ondisklog.tail, ondisklog.length(), bl);
+ store->read(meta_coll, log_oid, ondisklog.tail, ondisklog.length(), bl);
if (bl.length() < ondisklog.length()) {
dout(0) << "read_log got " << bl.length() << " bytes, expected "
<< ondisklog.head << "-" << ondisklog.tail << "="
}
} history;
- Info(pg_t p=0) : pgid(p),
- log_backlog(false)
- { }
+ Info() : log_backlog(false) {}
+ Info(pg_t p) : pgid(p), log_backlog(false) { }
+
bool is_uptodate() const { return last_update == last_complete; }
bool is_empty() const { return last_update.version == 0; }
bool dne() const { return history.epoch_created == 0; }
v.pool = pool;
v.preferred = pref; // hack: avoid negative.
}
- pg_t(uint64_t n) { *(__le64*)&v = n; }
pg_t(const ceph_pg& cpg) {
v = cpg;
}
- ps_t ps() { return v.ps; }
- int pool() { return v.pool; }
- int preferred() { return (__s16)v.preferred; } // hack: avoid negative.
+ ps_t ps() const { return v.ps; }
+ int pool() const { return v.pool; }
+ int preferred() const { return (__s16)v.preferred; } // hack: avoid negative.
- operator uint64_t() const { return *(__le64*)&v; }
-
/*coll_t to_coll() const {
return coll_t(u.pg64, 0);
}
} __attribute__ ((packed));
+inline bool operator<(const pg_t& l, const pg_t& r) {
+ return memcmp(&l, &r, sizeof(l)) < 0;
+}
+inline bool operator<=(const pg_t& l, const pg_t& r) {
+ return memcmp(&l, &r, sizeof(l)) <= 0;
+}
+inline bool operator==(const pg_t& l, const pg_t& r) {
+ return memcmp(&l, &r, sizeof(l)) == 0;
+}
+inline bool operator!=(const pg_t& l, const pg_t& r) {
+ return memcmp(&l, &r, sizeof(l)) != 0;
+}
+inline bool operator>(const pg_t& l, const pg_t& r) {
+ return memcmp(&l, &r, sizeof(l)) > 0;
+}
+inline bool operator>=(const pg_t& l, const pg_t& r) {
+ return memcmp(&l, &r, sizeof(l)) >= 0;
+}
+
+
inline void encode(pg_t pgid, bufferlist& bl) { encode_raw(pgid.v, bl); }
inline void decode(pg_t &pgid, bufferlist::iterator& p) {
decode_raw(pgid.v, p);
{
size_t operator()( const pg_t& x ) const
{
- static rjhash<uint64_t> H;
- return H(x);
+ static hash<uint32_t> H;
+ return H(x.pool() ^ x.ps() ^ x.preferred());
}
};
}
pg_t pgid;
snapid_t snap;
- coll_t(__u64 p=0, snapid_t s=0) : pgid(p), snap(s) {}
+ coll_t() : snap(0) {}
+ coll_t(pg_t p, snapid_t s) : pgid(p), snap(s) {}
static coll_t build_pg_coll(pg_t p) {
return coll_t(p, CEPH_NOSNAP);
namespace __gnu_cxx {
template<> struct hash<coll_t> {
size_t operator()(const coll_t &c) const {
- static rjhash<uint32_t> H;
+ static hash<pg_t> H;
static rjhash<uint64_t> I;
return H(c.pgid) ^ I(c.snap);
}
}
+const coll_t meta_coll;
+
inline ostream& operator<<(ostream& out, const ceph_object_layout &ol)
}
ObjectStore::Transaction ft;
- ft.create_collection(0);
+ ft.create_collection(coll_t());
fs->apply_transaction(ft);
utime_t now = g_clock.now();
utime_t start = now;
set_start(pos, now);
ObjectStore::Transaction t;
- t.write(0, poid, pos, bytes, bl);
+ t.write(coll_t(), poid, pos, bytes, bl);
fs->apply_transaction(t, new C_Commit(pos));
now = g_clock.now();
set_ack(pos, now);