object_t() : ino(0), bno(0), rev(0) {}
object_t(__uint64_t i, __uint32_t b) : ino(i), bno(b), rev(0) {}
+ object_t(__uint64_t i, __uint32_t b, __uint32_t r) : ino(i), bno(b), rev(r) {}
};
return r;
}
+/*
int FakeStore::listattr(object_t oid, char *attrls, size_t size)
{
if (fake_attrs) return attrs.listattr(oid, attrls, size);
get_oname(oid, fn);
return ::listxattr(fn, attrls, size);
}
+*/
// collections
return 0;
}
+/*
int FakeStore::collection_listattr(coll_t c, char *attrs, size_t size)
{
if (fake_attrs) return collection_listattr(c, attrs, size);
return 0;
}
-
+*/
// --------------------------
// collections
int stat(object_t oid, struct stat *st);
int remove(object_t oid, Context *onsafe);
int truncate(object_t oid, off_t size, Context *onsafe);
- int read(object_t oid,
- off_t offset, size_t len,
- bufferlist& bl);
- int write(object_t oid,
- off_t offset, size_t len,
- bufferlist& bl,
- Context *onsafe);
+ int read(object_t oid, off_t offset, size_t len, bufferlist& bl);
+ int write(object_t oid, off_t offset, size_t len, bufferlist& bl, Context *onsafe);
void sync();
void sync(Context *onsafe);
// attrs
- int setattr(object_t oid, const char *name,
- const void *value, size_t size,
- Context *onsafe=0);
+ int setattr(object_t oid, const char *name, const void *value, size_t size, Context *onsafe=0);
int setattrs(object_t oid, map<string,bufferptr>& aset);
- int getattr(object_t oid, const char *name,
- void *value, size_t size);
+ int getattr(object_t oid, const char *name, void *value, size_t size);
int getattrs(object_t oid, map<string,bufferptr>& aset);
- int rmattr(object_t oid, const char *name,
- Context *onsafe=0);
- int listattr(object_t oid, char *attrs, size_t size);
- int collection_setattr(coll_t c, const char *name,
- void *value, size_t size,
- Context *onsafe=0);
- int collection_rmattr(coll_t c, const char *name,
- Context *onsafe=0);
- int collection_getattr(coll_t c, const char *name,
- void *value, size_t size);
- int collection_listattr(coll_t c, char *attrs, size_t size);
+ int rmattr(object_t oid, const char *name, Context *onsafe=0);
+ //int listattr(object_t oid, char *attrs, size_t size);
+ int collection_setattr(coll_t c, const char *name, void *value, size_t size, Context *onsafe=0);
+ int collection_rmattr(coll_t c, const char *name, Context *onsafe=0);
+ int collection_getattr(coll_t c, const char *name, void *value, size_t size);
+ //int collection_listattr(coll_t c, char *attrs, size_t size);
// collections
int list_collections(list<coll_t>& ls);
- int create_collection(coll_t c,
- Context *onsafe=0);
- int destroy_collection(coll_t c,
- Context *onsafe=0);
+ int create_collection(coll_t c, Context *onsafe=0);
+ int destroy_collection(coll_t c, Context *onsafe=0);
int collection_stat(coll_t c, struct stat *st);
bool collection_exists(coll_t c);
- int collection_add(coll_t c, object_t o,
- Context *onsafe=0);
- int collection_remove(coll_t c, object_t o,
- Context *onsafe=0);
+ int collection_add(coll_t c, object_t o, Context *onsafe=0);
+ int collection_remove(coll_t c, object_t o, Context *onsafe=0);
int collection_list(coll_t c, list<object_t>& o);
};
p++)
t.remove(*p);
t.remove_collection(pgid);
- t.remove(object_t(1,pgid)); // log too
+ t.remove(pgid.to_object()); // log too
}
store->apply_transaction(t);
return -1;
}
- virtual int listattr(object_t oid, char *attrs, size_t size) {return 0;} //= 0;
+ //virtual int listattr(object_t oid, char *attrs, size_t size) {return 0;} //= 0;
// collections
virtual int list_collections(list<coll_t>& ls) {return 0;}//= 0;
Context *onsafe=0) {return 0;} //= 0;
virtual int collection_getattr(coll_t cid, const char *name,
void *value, size_t size) {return 0;} //= 0;
- virtual int collection_listattr(coll_t cid, char *attrs, size_t size) {return 0;} //= 0;
+ //virtual int collection_listattr(coll_t cid, char *attrs, size_t size) {return 0;} //= 0;
- virtual void sync(Context *onsync) {};
- virtual void sync() {};
+ virtual void sync(Context *onsync) {}
+ virtual void sync() {}
virtual void _fake_writes(bool b) {};
state_set(STATE_ACTIVE);
state_clear(STATE_STRAY);
if (is_crashed()) {
- assert(is_replay());
+ //assert(is_replay()); // HELP.. not on replica?
state_clear(STATE_CRASHED);
state_clear(STATE_REPLAY);
}
void PG::write_log(ObjectStore::Transaction& t)
{
+ dout(10) << "write_log" << endl;
+
// assemble buffer
bufferlist bl;
if (bl.length() % 4096 == 0)
ondisklog.block_map[bl.length()] = p->version;
bl.append((char*)&(*p), sizeof(*p));
+ if (g_conf.osd_pad_pg_log) { // pad to 4k, until i fix ebofs reallocation crap. FIXME.
+ bufferptr bp(4096 - sizeof(*p));
+ bl.push_back(bp);
+ }
}
ondisklog.top = bl.length();
// write it
- t.remove( object_t(1,info.pgid) );
- t.write( object_t(1,info.pgid) , 0, bl.length(), bl);
+ t.remove( info.pgid.to_object() );
+ t.write( info.pgid.to_object() , 0, bl.length(), bl);
t.collection_setattr(info.pgid, "ondisklog_bottom", &ondisklog.bottom, sizeof(ondisklog.bottom));
t.collection_setattr(info.pgid, "ondisklog_top", &ondisklog.top, sizeof(ondisklog.top));
void PG::append_log(ObjectStore::Transaction& t, PG::Log::Entry& logentry,
eversion_t trim_to)
{
+ dout(10) << "append_log " << ondisklog.top << " " << logentry << endl;
+
// write entry on disk
bufferlist bl;
bl.append( (char*)&logentry, sizeof(logentry) );
bufferptr bp(4096 - sizeof(logentry));
bl.push_back(bp);
}
- t.write( object_t(1,info.pgid), ondisklog.top, bl.length(), bl );
+ t.write( info.pgid.to_object(), ondisklog.top, bl.length(), bl );
// update block map?
if (ondisklog.top % 4096 == 0)
void PG::read_log(ObjectStore *store)
{
+ int r;
// load bounds
ondisklog.bottom = ondisklog.top = 0;
- store->collection_getattr(info.pgid, "ondisklog_bottom", &ondisklog.bottom, sizeof(ondisklog.bottom));
- store->collection_getattr(info.pgid, "ondisklog_top", &ondisklog.top, sizeof(ondisklog.top));
-
+ r = store->collection_getattr(info.pgid, "ondisklog_bottom", &ondisklog.bottom, sizeof(ondisklog.bottom));
+ assert(r == sizeof(ondisklog.bottom));
+ r = store->collection_getattr(info.pgid, "ondisklog_top", &ondisklog.top, sizeof(ondisklog.top));
+ assert(r == sizeof(ondisklog.top));
+
+ dout(10) << "read_log [" << ondisklog.bottom << "," << ondisklog.top << ")" << endl;
+
log.backlog = info.log_backlog;
log.bottom = info.log_bottom;
if (ondisklog.top > 0) {
// read
bufferlist bl;
- store->read(object_t(1,info.pgid), ondisklog.bottom, ondisklog.top-ondisklog.bottom, bl);
+ store->read(info.pgid.to_object(), ondisklog.bottom, ondisklog.top-ondisklog.bottom, bl);
PG::Log::Entry e;
off_t pos = ondisklog.bottom;
+ assert(log.log.empty());
while (pos < ondisklog.top) {
bl.copy(pos-ondisklog.bottom, sizeof(e), (char*)&e);
+ dout(10) << "read_log " << pos << " " << e << endl;
+
if (e.version > log.bottom || log.backlog) { // ignore items below log.bottom
if (pos % 4096 == 0)
- ondisklog.block_map[pos] = e.version;
+ ondisklog.block_map[pos] = e.version;
log.log.push_back(e);
+ } else {
+ dout(10) << "read_log ignoring entry at " << pos << endl;
}
- pos += sizeof(e);
+ if (g_conf.osd_pad_pg_log) // pad to 4k, until i fix ebofs reallocation crap. FIXME.
+ pos += 4096;
+ else
+ pos += sizeof(e);
}
}
log.top = info.last_update;
inline ostream& operator<<(ostream& out, const PG::Info& pgi)
{
- out << "pginfo(" << hex << pgi.pgid << dec;
+ out << "pginfo(" << pgi.pgid;
if (pgi.is_empty())
out << " empty";
else
!pg.log.backlog) ||
(pg.log.log.rbegin()->version.version != pg.log.top.version)) {
out << " (log bound mismatch, actual=["
- << pg.log.log.begin()->version << ","
- << pg.log.log.rbegin()->version << "])";
+ << pg.log.log.begin()->version << ","
+ << pg.log.log.rbegin()->version << "] len=" << pg.log.log.size() << ")";
}
}
#include "include/reqid.h"
+#define PG_INO 1
+
+
// osd types
typedef __uint64_t coll_t; // collection id
-
// pg stuff
typedef __uint16_t ps_t;
typedef __uint8_t pruleset_t;
struct pg_t {
union {
struct {
- int preferred;
- ps_t ps;
- __uint8_t nrep;
- pruleset_t ruleset;
+ __uint32_t preferred:32; // 32
+ ps_t ps:16; // 16
+ __uint8_t nrep:8; // 8
+ pruleset_t ruleset:8; // 8
} fields;
- __uint64_t val;
+ __uint64_t val; // 64
} u;
+
pg_t() { u.val = 0; }
pg_t(const pg_t& o) { u.val = o.u.val; }
pg_t(ps_t s, int p, unsigned char n, pruleset_t r=0) {
pg_t operator++() { ++u.val; return *this; }
*/
operator __uint64_t() const { return u.val; }
+
+ object_t to_object() const { return object_t(PG_INO, u.val >> 32, u.val & 0xffffffff); }
};
inline ostream& operator<<(ostream& out, pg_t pg) {
if (pg.u.fields.preferred)
out << pg.u.fields.preferred << '.';
out << hex << pg.u.fields.ps << dec;
+ out << "=" << hex << pg.u.val << dec;
+ out << "=" << hex << (__uint64_t)pg << dec;
return out;
}