// write it
t.remove(0, info.pgid.to_log_pobject() );
t.write(0, info.pgid.to_log_pobject() , 0, bl.length(), bl);
- t.collection_setattr(info.pgid.to_coll(), "ondisklog_bottom", &ondisklog.bottom, sizeof(ondisklog.bottom));
- t.collection_setattr(info.pgid.to_coll(), "ondisklog_top", &ondisklog.top, sizeof(ondisklog.top));
+
+ bufferlist blb(sizeof(ondisklog));
+ ::encode(ondisklog, blb);
+ t.collection_setattr(info.pgid.to_coll(), "ondisklog", blb);
dout(10) << "write_log to " << ondisklog.bottom << "~" << ondisklog.length() << dendl;
dirty_log = false;
{
dout(15) << "trim_ondisk_log_to v " << v << dendl;
- map<loff_t,eversion_t>::iterator p = ondisklog.block_map.begin();
+ map<__u64,eversion_t>::iterator p = ondisklog.block_map.begin();
while (p != ondisklog.block_map.end()) {
dout(15) << " " << p->first << " -> " << p->second << dendl;
p++;
return; // can't trim anything!
// we can trim!
- loff_t trim = p->first;
+ __u64 trim = p->first;
dout(10) << " trimming ondisklog to " << ondisklog.bottom << "~" << ondisklog.length() << dendl;
assert(trim >= ondisklog.bottom);
while (p != ondisklog.block_map.begin())
ondisklog.block_map.erase(ondisklog.block_map.begin());
- t.collection_setattr(info.pgid.to_coll(), "ondisklog_bottom", &ondisklog.bottom, sizeof(ondisklog.bottom));
- t.collection_setattr(info.pgid.to_coll(), "ondisklog_top", &ondisklog.top, sizeof(ondisklog.top));
+ bufferlist blb(sizeof(ondisklog));
+ ::encode(ondisklog, blb);
+ t.collection_setattr(info.pgid.to_coll(), "ondisklog", blb);
if (!g_conf.osd_preserve_trimmed_log)
t.zero(0, info.pgid.to_log_pobject(), 0, ondisklog.bottom);
t.write(0, info.pgid.to_log_pobject(), ondisklog.top, bl.length(), bl );
ondisklog.top += bl.length();
- t.collection_setattr(info.pgid.to_coll(), "ondisklog_top",
- &ondisklog.top, sizeof(ondisklog.top));
+
+ bufferlist blb(sizeof(ondisklog));
+ ::encode(ondisklog, blb);
+ t.collection_setattr(info.pgid.to_coll(), "ondisklog", blb);
+
// trim?
if (trim_to > log.bottom &&
void PG::read_log(ObjectStore *store)
{
- int r;
// load bounds
ondisklog.bottom = ondisklog.top = 0;
- r = store->collection_getattr(info.pgid.to_coll(), "ondisklog_bottom", &ondisklog.bottom, sizeof(ondisklog.bottom));
- assert(r == sizeof(ondisklog.bottom));
- r = store->collection_getattr(info.pgid.to_coll(), "ondisklog_top", &ondisklog.top, sizeof(ondisklog.top));
- assert(r == sizeof(ondisklog.top));
+
+ bufferlist blb;
+ store->collection_getattr(info.pgid.to_coll(), "ondisklog", blb);
+ bufferlist::iterator p = blb.begin();
+ ::decode(ondisklog, p);
dout(10) << "read_log " << ondisklog.bottom << "~" << ondisklog.length() << dendl;
class OndiskLog {
public:
// ok
- loff_t bottom; // first byte of log.
- loff_t top; // byte following end of log.
- map<loff_t,eversion_t> block_map; // block -> first stamp logged there
+ __u64 bottom; // first byte of log.
+ __u64 top; // byte following end of log.
+ map<__u64,eversion_t> block_map; // block -> first stamp logged there
OndiskLog() : bottom(0), top(0) {}
- loff_t length() { return top - bottom; }
+ __u64 length() { return top - bottom; }
bool trim_to(eversion_t v, ObjectStore::Transaction& t);
+
+ void encode(bufferlist& bl) const {
+ ::encode(bottom, bl);
+ ::encode(top, bl);
+ }
+ void decode(bufferlist::iterator& bl) {
+ ::decode(bottom, bl);
+ ::decode(top, bl);
+ }
};
+ WRITE_CLASS_ENCODER(OndiskLog)
/*
WRITE_CLASS_ENCODER(PG::Log::Entry)
WRITE_CLASS_ENCODER(PG::Log)
WRITE_CLASS_ENCODER(PG::Interval)
-
+WRITE_CLASS_ENCODER(PG::OndiskLog)
inline ostream& operator<<(ostream& out, const PG::Info::History& h)
{