From ed45b7d600b64d065bcb393edb69cfca1a0c9655 Mon Sep 17 00:00:00 2001 From: sageweil Date: Fri, 30 Nov 2007 19:52:48 +0000 Subject: [PATCH] first pass at adding pobject abstraction git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@2161 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/ebofs/config.cc | 4 +- branches/ebofs/dupstore.cc | 8 +- branches/ebofs/ebofs/BufferCache.h | 6 +- branches/ebofs/ebofs/Ebofs.cc | 168 ++++++++++++++--------------- branches/ebofs/ebofs/Ebofs.h | 110 +++++++++---------- branches/ebofs/ebofs/Onode.h | 4 +- branches/ebofs/ebofs/types.h | 3 +- branches/ebofs/include/object.h | 33 ++---- branches/ebofs/include/pobject.h | 68 ++++++++++++ branches/ebofs/mds/mdstypes.h | 2 +- branches/ebofs/osd/Fake.h | 26 ++--- branches/ebofs/osd/FakeStore.cc | 102 ++++++++++-------- branches/ebofs/osd/FakeStore.h | 40 +++---- branches/ebofs/osd/OSD.cc | 4 +- branches/ebofs/osd/ObjectStore.h | 111 +++++++++---------- branches/ebofs/osd/PG.cc | 15 +-- branches/ebofs/osd/ReplicatedPG.cc | 15 +-- branches/ebofs/osd/osd_types.h | 9 +- 18 files changed, 402 insertions(+), 326 deletions(-) create mode 100644 branches/ebofs/include/pobject.h diff --git a/branches/ebofs/config.cc b/branches/ebofs/config.cc index 3dd7dfb79f2a9..b4c108d0b53eb 100644 --- a/branches/ebofs/config.cc +++ b/branches/ebofs/config.cc @@ -331,8 +331,8 @@ md_config_t g_conf = { ebofs_idle_commit_ms: 0, // 0 = no idle detection. UGLY HACK. use bdev_idle_kick_after_ms instead. ebofs_oc_size: 10000, // onode cache ebofs_cc_size: 10000, // cnode cache - ebofs_bc_size: (50 *256), // 4k blocks, *256 for MB - ebofs_bc_max_dirty: (30 *256), // before write() will block + ebofs_bc_size: (5 *256), // 4k blocks, *256 for MB + ebofs_bc_max_dirty: (3 *256), // before write() will block ebofs_max_prefetch: 1000, // 4k blocks ebofs_realloc: false, // hrm, this can cause bad fragmentation, don't use! ebofs_verify_csum_on_read: true, diff --git a/branches/ebofs/dupstore.cc b/branches/ebofs/dupstore.cc index d43f935cb50cc..0b3b6fa6eb8c2 100644 --- a/branches/ebofs/dupstore.cc +++ b/branches/ebofs/dupstore.cc @@ -24,12 +24,12 @@ int dupstore(ObjectStore* src, ObjectStore* dst) if (dst->mount() < 0) return 1; // objects - list objects; + list objects; src->list_objects(objects); int num = objects.size(); cout << num << " objects" << std::endl; int i = 1; - for (list::iterator p = objects.begin(); p != objects.end(); ++p) { + for (list::iterator p = objects.begin(); p != objects.end(); ++p) { bufferlist bl; src->read(*p, 0, 0, bl); cout << "object " << i++ << "/" << num << " " << *p << " = " << bl.length() << " bytes" << std::endl; @@ -52,10 +52,10 @@ int dupstore(ObjectStore* src, ObjectStore* dst) map attrs; src->collection_getattrs(*p, attrs); dst->collection_setattrs(*p, attrs); - list o; + list o; src->collection_list(*p, o); int numo = 0; - for (list::iterator q = o.begin(); q != o.end(); q++) { + for (list::iterator q = o.begin(); q != o.end(); q++) { dst->collection_add(*p, *q, 0); numo++; } diff --git a/branches/ebofs/ebofs/BufferCache.h b/branches/ebofs/ebofs/BufferCache.h index 31575c76f6bfa..fc8424057f1a0 100644 --- a/branches/ebofs/ebofs/BufferCache.h +++ b/branches/ebofs/ebofs/BufferCache.h @@ -274,7 +274,7 @@ inline ostream& operator<<(ostream& out, BufferHead& bh) class ObjectCache { public: - object_t object_id; + pobject_t object_id; Onode *on; BufferCache *bc; @@ -287,7 +287,7 @@ class ObjectCache { public: - ObjectCache(object_t o, Onode *_on, BufferCache *b) : + ObjectCache(pobject_t o, Onode *_on, BufferCache *b) : object_id(o), on(_on), bc(b), ref(0), write_count(0) { } ~ObjectCache() { @@ -307,7 +307,7 @@ class ObjectCache { return ref; } - object_t get_object_id() { return object_id; } + pobject_t get_object_id() { return object_id; } void add_bh(BufferHead *bh) { // add to my map diff --git a/branches/ebofs/ebofs/Ebofs.cc b/branches/ebofs/ebofs/Ebofs.cc index 1e2101f6ebae4..504d8df749d8f 100644 --- a/branches/ebofs/ebofs/Ebofs.cc +++ b/branches/ebofs/ebofs/Ebofs.cc @@ -106,14 +106,14 @@ int Ebofs::mount() // open tables dout(3) << "mount opening tables" << dendl; - object_tab = new Table( nodepool, sb->object_tab ); + object_tab = new Table( nodepool, sb->object_tab ); for (int i=0; i( nodepool, sb->free_tab[i] ); limbo_tab = new Table( nodepool, sb->limbo_tab ); alloc_tab = new Table >( nodepool, sb->alloc_tab ); collection_tab = new Table( nodepool, sb->collection_tab ); - co_tab = new Table( nodepool, sb->co_tab ); + co_tab = new Table( nodepool, sb->co_tab ); verify_tables(); @@ -223,7 +223,7 @@ int Ebofs::mkfs() empty.root.csum = 0; empty.depth = 0; - object_tab = new Table( nodepool, empty ); + object_tab = new Table( nodepool, empty ); collection_tab = new Table( nodepool, empty ); for (int i=0; i( nodepool, empty ); alloc_tab = new Table >( nodepool, empty ); - co_tab = new Table( nodepool, empty ); + co_tab = new Table( nodepool, empty ); // add free space Extent left; @@ -339,7 +339,7 @@ int Ebofs::umount() trim_bc(0); trim_inodes(0); - for (hash_map::iterator i = onode_map.begin(); + for (hash_map::iterator i = onode_map.begin(); i != onode_map.end(); i++) { dout(0) << "umount *** leftover: " << i->first << " " << *(i->second) << dendl; @@ -661,7 +661,7 @@ void *Ebofs::finisher_thread_entry() // *** onodes *** -Onode* Ebofs::new_onode(object_t oid) +Onode* Ebofs::new_onode(pobject_t oid) { Onode* on = new Onode(oid); @@ -683,7 +683,7 @@ Onode* Ebofs::new_onode(object_t oid) } -Onode* Ebofs::get_onode(object_t oid) +Onode* Ebofs::get_onode(pobject_t oid) { while (1) { // in cache? @@ -954,7 +954,7 @@ void Ebofs::remove_onode(Onode *on) for (set::iterator i = on->collections.begin(); i != on->collections.end(); i++) { - co_tab->remove(coll_object_t(*i,on->object_id)); + co_tab->remove(coll_pobject_t(*i,on->object_id)); } on->collections.clear(); @@ -2154,7 +2154,7 @@ int Ebofs::attempt_read(Onode *on, off_t off, size_t len, bufferlist& bl, * return value of -1 if onode isn't loaded. otherwise, the number * of extents that need to be read (i.e. # of seeks) */ -int Ebofs::is_cached(object_t oid, off_t off, size_t len) +int Ebofs::is_cached(pobject_t oid, off_t off, size_t len) { ebofs_lock.Lock(); int r = _is_cached(oid, off, len); @@ -2162,7 +2162,7 @@ int Ebofs::is_cached(object_t oid, off_t off, size_t len) return r; } -int Ebofs::_is_cached(object_t oid, off_t off, size_t len) +int Ebofs::_is_cached(pobject_t oid, off_t off, size_t len) { if (!have_onode(oid)) { dout(7) << "_is_cached " << oid << " " << off << "~" << len << " ... onode " << dendl; @@ -2205,14 +2205,14 @@ int Ebofs::_is_cached(object_t oid, off_t off, size_t len) */ } -void Ebofs::trim_from_cache(object_t oid, off_t off, size_t len) +void Ebofs::trim_from_cache(pobject_t oid, off_t off, size_t len) { ebofs_lock.Lock(); _trim_from_cache(oid, off, len); ebofs_lock.Unlock(); } -void Ebofs::_trim_from_cache(object_t oid, off_t off, size_t len) +void Ebofs::_trim_from_cache(pobject_t oid, off_t off, size_t len) { // be careful not to load it if we don't have it if (!have_onode(oid)) { @@ -2237,7 +2237,7 @@ void Ebofs::_trim_from_cache(object_t oid, off_t off, size_t len) } -int Ebofs::read(object_t oid, +int Ebofs::read(pobject_t oid, off_t off, size_t len, bufferlist& bl) { @@ -2247,7 +2247,7 @@ int Ebofs::read(object_t oid, return r; } -int Ebofs::_read(object_t oid, off_t off, size_t len, bufferlist& bl) +int Ebofs::_read(pobject_t oid, off_t off, size_t len, bufferlist& bl) { dout(7) << "_read " << oid << " " << off << "~" << len << dendl; @@ -2348,7 +2348,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) switch (op) { case Transaction::OP_READ: { - object_t oid; + pobject_t oid; t.get_oid(oid); off_t offset, len; t.get_length(offset); @@ -2364,7 +2364,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) case Transaction::OP_STAT: { - object_t oid; + pobject_t oid; t.get_oid(oid); struct stat *st; t.get_pstat(st); @@ -2377,7 +2377,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) case Transaction::OP_GETATTR: { - object_t oid; + pobject_t oid; t.get_oid(oid); const char *attrname; t.get_attrname(attrname); @@ -2392,7 +2392,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) case Transaction::OP_GETATTRS: { - object_t oid; + pobject_t oid; t.get_oid(oid); map *pset; t.get_pattrset(pset); @@ -2406,7 +2406,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) case Transaction::OP_WRITE: { - object_t oid; + pobject_t oid; t.get_oid(oid); off_t offset, len; t.get_length(offset); @@ -2422,7 +2422,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) case Transaction::OP_TRIMCACHE: { - object_t oid; + pobject_t oid; t.get_oid(oid); off_t offset, len; t.get_length(offset); @@ -2433,7 +2433,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) case Transaction::OP_TRUNCATE: { - object_t oid; + pobject_t oid; t.get_oid(oid); off_t len; t.get_length(len); @@ -2446,7 +2446,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) case Transaction::OP_REMOVE: { - object_t oid; + pobject_t oid; t.get_oid(oid); if (_remove(oid) < 0) { dout(7) << "apply_transaction fail on _remove" << dendl; @@ -2457,7 +2457,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) case Transaction::OP_SETATTR: { - object_t oid; + pobject_t oid; t.get_oid(oid); const char *attrname; t.get_attrname(attrname); @@ -2472,7 +2472,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) case Transaction::OP_SETATTRS: { - object_t oid; + pobject_t oid; t.get_oid(oid); map *pattrset; t.get_pattrset(pattrset); @@ -2485,7 +2485,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) case Transaction::OP_RMATTR: { - object_t oid; + pobject_t oid; t.get_oid(oid); const char *attrname; t.get_attrname(attrname); @@ -2498,9 +2498,9 @@ unsigned Ebofs::_apply_transaction(Transaction& t) case Transaction::OP_CLONE: { - object_t oid; + pobject_t oid; t.get_oid(oid); - object_t noid; + pobject_t noid; t.get_oid(noid); if (_clone(oid, noid) < 0) { dout(7) << "apply_transaction fail on _clone" << dendl; @@ -2535,7 +2535,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) { coll_t cid; t.get_cid(cid); - object_t oid; + pobject_t oid; t.get_oid(oid); if (_collection_add(cid, oid) < 0) { //dout(7) << "apply_transaction fail on _collection_add" << dendl; @@ -2548,7 +2548,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) { coll_t cid; t.get_cid(cid); - object_t oid; + pobject_t oid; t.get_oid(oid); if (_collection_remove(cid, oid) < 0) { dout(7) << "apply_transaction fail on _collection_remove" << dendl; @@ -2600,7 +2600,7 @@ unsigned Ebofs::_apply_transaction(Transaction& t) -int Ebofs::_write(object_t oid, off_t offset, size_t length, const bufferlist& bl) +int Ebofs::_write(pobject_t oid, off_t offset, size_t length, const bufferlist& bl) { dout(7) << "_write " << oid << " " << offset << "~" << length << dendl; assert(bl.length() == length); @@ -2662,7 +2662,7 @@ int Ebofs::_write(object_t oid, off_t offset, size_t length, const bufferlist& b return length; } -int Ebofs::_zero(object_t oid, off_t offset, size_t length) +int Ebofs::_zero(pobject_t oid, off_t offset, size_t length) { dout(7) << "_zero " << oid << " " << offset << "~" << length << dendl; @@ -2692,7 +2692,7 @@ int Ebofs::_zero(object_t oid, off_t offset, size_t length) } -int Ebofs::write(object_t oid, +int Ebofs::write(pobject_t oid, off_t off, size_t len, const bufferlist& bl, Context *onsafe) { @@ -2723,7 +2723,7 @@ int Ebofs::write(object_t oid, return r; } -int Ebofs::zero(object_t oid, off_t off, size_t len, Context *onsafe) +int Ebofs::zero(pobject_t oid, off_t off, size_t len, Context *onsafe) { ebofs_lock.Lock(); @@ -2753,7 +2753,7 @@ int Ebofs::zero(object_t oid, off_t off, size_t len, Context *onsafe) } -int Ebofs::_remove(object_t oid) +int Ebofs::_remove(pobject_t oid) { dout(7) << "_remove " << oid << dendl; @@ -2768,7 +2768,7 @@ int Ebofs::_remove(object_t oid) } -int Ebofs::remove(object_t oid, Context *onsafe) +int Ebofs::remove(pobject_t oid, Context *onsafe) { ebofs_lock.Lock(); @@ -2796,7 +2796,7 @@ int Ebofs::remove(object_t oid, Context *onsafe) return r; } -int Ebofs::_truncate(object_t oid, off_t size) +int Ebofs::_truncate(pobject_t oid, off_t size) { dout(7) << "_truncate " << oid << " size " << size << dendl; @@ -2855,7 +2855,7 @@ int Ebofs::_truncate(object_t oid, off_t size) } -int Ebofs::truncate(object_t oid, off_t size, Context *onsafe) +int Ebofs::truncate(pobject_t oid, off_t size, Context *onsafe) { ebofs_lock.Lock(); @@ -2884,7 +2884,7 @@ int Ebofs::truncate(object_t oid, off_t size, Context *onsafe) -int Ebofs::clone(object_t from, object_t to, Context *onsafe) +int Ebofs::clone(pobject_t from, pobject_t to, Context *onsafe) { ebofs_lock.Lock(); @@ -2911,7 +2911,7 @@ int Ebofs::clone(object_t from, object_t to, Context *onsafe) return r; } -int Ebofs::_clone(object_t from, object_t to) +int Ebofs::_clone(pobject_t from, pobject_t to) { dout(7) << "_clone " << from << " -> " << to << dendl; @@ -2971,34 +2971,34 @@ int Ebofs::_clone(object_t from, object_t to) * (oid.rev is a noninclusive upper bound.) * */ -int Ebofs::pick_object_revision_lt(object_t& oid) +int Ebofs::pick_object_revision_lt(pobject_t& oid) { - assert(oid.rev > 0); // this is only useful for non-zero oid.rev + assert(oid.oid.rev > 0); // this is only useful for non-zero oid.rev int r = -EEXIST; // return code ebofs_lock.Lock(); { - object_t orig = oid; - object_t live = oid; - live.rev = 0; + pobject_t orig = oid; + pobject_t live = oid; + live.oid.rev = 0; if (object_tab->get_num_keys() > 0) { - Table::Cursor cursor(object_tab); + Table::Cursor cursor(object_tab); object_tab->find(oid, cursor); // this will be just _past_ highest eligible rev if (cursor.move_left() > 0) { bool firstpass = true; while (1) { - object_t t = cursor.current().key; - if (t.ino != oid.ino || - t.bno != oid.bno) // passed to previous object + pobject_t t = cursor.current().key; + if (t.oid.ino != oid.oid.ino || + t.oid.bno != oid.oid.bno) // passed to previous object break; - if (oid.rev < t.rev) { // rev < desired. possible match. + if (oid.oid.rev < t.oid.rev) { // rev < desired. possible match. r = 0; oid = t; break; } - if (firstpass && oid.rev >= t.rev) { // there is no old rev < desired. try live. + if (firstpass && oid.oid.rev >= t.oid.rev) { // there is no old rev < desired. try live. r = 0; oid = live; break; @@ -3019,7 +3019,7 @@ int Ebofs::pick_object_revision_lt(object_t& oid) -bool Ebofs::exists(object_t oid) +bool Ebofs::exists(pobject_t oid) { ebofs_lock.Lock(); dout(8) << "exists " << oid << dendl; @@ -3028,7 +3028,7 @@ bool Ebofs::exists(object_t oid) return e; } -int Ebofs::stat(object_t oid, struct stat *st) +int Ebofs::stat(pobject_t oid, struct stat *st) { ebofs_lock.Lock(); int r = _stat(oid,st); @@ -3036,7 +3036,7 @@ int Ebofs::stat(object_t oid, struct stat *st) return r; } -int Ebofs::_stat(object_t oid, struct stat *st) +int Ebofs::_stat(pobject_t oid, struct stat *st) { dout(7) << "_stat " << oid << dendl; @@ -3051,7 +3051,7 @@ int Ebofs::_stat(object_t oid, struct stat *st) } -int Ebofs::_setattr(object_t oid, const char *name, const void *value, size_t size) +int Ebofs::_setattr(pobject_t oid, const char *name, const void *value, size_t size) { dout(8) << "setattr " << oid << " '" << name << "' len " << size << dendl; @@ -3072,7 +3072,7 @@ int Ebofs::_setattr(object_t oid, const char *name, const void *value, size_t si return 0; } -int Ebofs::setattr(object_t oid, const char *name, const void *value, size_t size, Context *onsafe) +int Ebofs::setattr(pobject_t oid, const char *name, const void *value, size_t size, Context *onsafe) { ebofs_lock.Lock(); int r = _setattr(oid, name, value, size); @@ -3098,7 +3098,7 @@ int Ebofs::setattr(object_t oid, const char *name, const void *value, size_t siz return r; } -int Ebofs::_setattrs(object_t oid, map& attrset) +int Ebofs::_setattrs(pobject_t oid, map& attrset) { dout(8) << "setattrs " << oid << dendl; @@ -3115,7 +3115,7 @@ int Ebofs::_setattrs(object_t oid, map& attrset) return 0; } -int Ebofs::setattrs(object_t oid, map& attrset, Context *onsafe) +int Ebofs::setattrs(pobject_t oid, map& attrset, Context *onsafe) { ebofs_lock.Lock(); int r = _setattrs(oid, attrset); @@ -3142,7 +3142,7 @@ int Ebofs::setattrs(object_t oid, map& attrset, Context *onsaf } -int Ebofs::get_object_collections(object_t oid, set& ls) +int Ebofs::get_object_collections(pobject_t oid, set& ls) { ebofs_lock.Lock(); int r = _get_object_collections(oid, ls); @@ -3150,7 +3150,7 @@ int Ebofs::get_object_collections(object_t oid, set& ls) return r; } -int Ebofs::_get_object_collections(object_t oid, set& ls) +int Ebofs::_get_object_collections(pobject_t oid, set& ls) { dout(8) << "_get_object_collections " << oid << dendl; @@ -3161,7 +3161,7 @@ int Ebofs::_get_object_collections(object_t oid, set& ls) return 0; } -int Ebofs::getattr(object_t oid, const char *name, void *value, size_t size) +int Ebofs::getattr(pobject_t oid, const char *name, void *value, size_t size) { ebofs_lock.Lock(); int r = _getattr(oid, name, value, size); @@ -3169,7 +3169,7 @@ int Ebofs::getattr(object_t oid, const char *name, void *value, size_t size) return r; } -int Ebofs::_getattr(object_t oid, const char *name, void *value, size_t size) +int Ebofs::_getattr(pobject_t oid, const char *name, void *value, size_t size) { dout(8) << "_getattr " << oid << " '" << name << "' maxlen " << size << dendl; @@ -3190,7 +3190,7 @@ int Ebofs::_getattr(object_t oid, const char *name, void *value, size_t size) return r; } -int Ebofs::getattrs(object_t oid, map &aset) +int Ebofs::getattrs(pobject_t oid, map &aset) { ebofs_lock.Lock(); int r = _getattrs(oid, aset); @@ -3198,7 +3198,7 @@ int Ebofs::getattrs(object_t oid, map &aset) return r; } -int Ebofs::_getattrs(object_t oid, map &aset) +int Ebofs::_getattrs(pobject_t oid, map &aset) { dout(8) << "_getattrs " << oid << dendl; @@ -3211,7 +3211,7 @@ int Ebofs::_getattrs(object_t oid, map &aset) -int Ebofs::_rmattr(object_t oid, const char *name) +int Ebofs::_rmattr(pobject_t oid, const char *name) { dout(8) << "_rmattr " << oid << " '" << name << "'" << dendl; @@ -3229,7 +3229,7 @@ int Ebofs::_rmattr(object_t oid, const char *name) return 0; } -int Ebofs::rmattr(object_t oid, const char *name, Context *onsafe) +int Ebofs::rmattr(pobject_t oid, const char *name, Context *onsafe) { ebofs_lock.Lock(); @@ -3256,7 +3256,7 @@ int Ebofs::rmattr(object_t oid, const char *name, Context *onsafe) return r; } -int Ebofs::listattr(object_t oid, vector& attrs) +int Ebofs::listattr(pobject_t oid, vector& attrs) { ebofs_lock.Lock(); dout(8) << "listattr " << oid << dendl; @@ -3279,15 +3279,15 @@ int Ebofs::listattr(object_t oid, vector& attrs) return 0; } -int Ebofs::list_objects(list& ls) +int Ebofs::list_objects(list& ls) { ebofs_lock.Lock(); dout(9) << "list_objects " << dendl; - Table::Cursor cursor(object_tab); + Table::Cursor cursor(object_tab); int num = 0; - if (object_tab->find(object_t(), cursor) >= 0) { + if (object_tab->find(pobject_t(), cursor) >= 0) { while (1) { ls.push_back(cursor.current().key); num++; @@ -3373,12 +3373,12 @@ int Ebofs::_destroy_collection(coll_t cid) assert(cn); // hose mappings - list objects; + list objects; collection_list(cid, objects); - for (list::iterator i = objects.begin(); + for (list::iterator i = objects.begin(); i != objects.end(); i++) { - co_tab->remove(coll_object_t(cid,*i)); + co_tab->remove(coll_pobject_t(cid,*i)); Onode *on = get_onode(*i); if (on) { @@ -3432,7 +3432,7 @@ bool Ebofs::_collection_exists(coll_t cid) return (collection_tab->lookup(cid) == 0); } -int Ebofs::_collection_add(coll_t cid, object_t oid) +int Ebofs::_collection_add(coll_t cid, pobject_t oid) { dout(9) << "_collection_add " << hex << cid << " object " << oid << dec << dendl; @@ -3447,7 +3447,7 @@ int Ebofs::_collection_add(coll_t cid, object_t oid) if (on->collections.count(cid) == 0) { on->collections.insert(cid); dirty_onode(on); - co_tab->insert(coll_object_t(cid,oid), true); + co_tab->insert(coll_pobject_t(cid,oid), true); } else { r = -ENOENT; // FIXME? already in collection. } @@ -3456,7 +3456,7 @@ int Ebofs::_collection_add(coll_t cid, object_t oid) return r; } -int Ebofs::collection_add(coll_t cid, object_t oid, Context *onsafe) +int Ebofs::collection_add(coll_t cid, pobject_t oid, Context *onsafe) { ebofs_lock.Lock(); @@ -3483,7 +3483,7 @@ int Ebofs::collection_add(coll_t cid, object_t oid, Context *onsafe) return 0; } -int Ebofs::_collection_remove(coll_t cid, object_t oid) +int Ebofs::_collection_remove(coll_t cid, pobject_t oid) { dout(9) << "_collection_remove " << hex << cid << " object " << oid << dec << dendl; @@ -3498,7 +3498,7 @@ int Ebofs::_collection_remove(coll_t cid, object_t oid) if (on->collections.count(cid)) { on->collections.erase(cid); dirty_onode(on); - co_tab->remove(coll_object_t(cid,oid)); + co_tab->remove(coll_pobject_t(cid,oid)); } else { r = -ENOENT; // FIXME? } @@ -3507,7 +3507,7 @@ int Ebofs::_collection_remove(coll_t cid, object_t oid) return r; } -int Ebofs::collection_remove(coll_t cid, object_t oid, Context *onsafe) +int Ebofs::collection_remove(coll_t cid, pobject_t oid, Context *onsafe) { ebofs_lock.Lock(); @@ -3534,7 +3534,7 @@ int Ebofs::collection_remove(coll_t cid, object_t oid, Context *onsafe) return 0; } -int Ebofs::collection_list(coll_t cid, list& ls) +int Ebofs::collection_list(coll_t cid, list& ls) { ebofs_lock.Lock(); dout(9) << "collection_list " << hex << cid << dec << dendl; @@ -3544,13 +3544,13 @@ int Ebofs::collection_list(coll_t cid, list& ls) return -ENOENT; } - Table::Cursor cursor(co_tab); + Table::Cursor cursor(co_tab); int num = 0; - if (co_tab->find(coll_object_t(cid,object_t()), cursor) >= 0) { + if (co_tab->find(coll_pobject_t(cid,pobject_t()), cursor) >= 0) { while (1) { const coll_t c = cursor.current().key.first; - const object_t o = cursor.current().key.second; + const pobject_t o = cursor.current().key.second; if (c != cid) break; // end! dout(10) << "collection_list " << hex << cid << " includes " << o << dec << dendl; ls.push_back(o); @@ -3835,8 +3835,8 @@ void Ebofs::_get_frag_stat(FragmentationStat& st) st.avg_extent_per_object = 0; st.avg_extent_jump = 0; - Table::Cursor cursor(object_tab); - object_tab->find(object_t(), cursor); + Table::Cursor cursor(object_tab); + object_tab->find(pobject_t(), cursor); int nobj = 0; int njump = 0; while (object_tab->get_num_keys() > 0) { diff --git a/branches/ebofs/ebofs/Ebofs.h b/branches/ebofs/ebofs/Ebofs.h index b8bdb9b45b528..bbd618d8f9d61 100644 --- a/branches/ebofs/ebofs/Ebofs.h +++ b/branches/ebofs/ebofs/Ebofs.h @@ -38,7 +38,7 @@ using namespace __gnu_cxx; #include "osd/ObjectStore.h" //typedef pair object_coll_t; -typedef pair coll_object_t; +typedef pair coll_pobject_t; class Ebofs : public ObjectStore { @@ -107,30 +107,30 @@ protected: NodePool nodepool; // for all tables... // tables - Table *object_tab; + Table *object_tab; Table *free_tab[EBOFS_NUM_FREE_BUCKETS]; Table *limbo_tab; Table > *alloc_tab; // collections Table *collection_tab; - Table *co_tab; + Table *co_tab; void close_tables(); void verify_tables(); // ** onodes ** - hash_map onode_map; // onode cache + hash_map onode_map; // onode cache LRU onode_lru; set dirty_onodes; - map > waitfor_onode; + map > waitfor_onode; - Onode* new_onode(object_t oid); // make new onode. ref++. - bool have_onode(object_t oid) { + Onode* new_onode(pobject_t oid); // make new onode. ref++. + bool have_onode(pobject_t oid) { return onode_map.count(oid); } - Onode* get_onode(object_t oid); // get cached onode, or read from disk. ref++. + Onode* get_onode(pobject_t oid); // get cached onode, or read from disk. ref++. void remove_onode(Onode *on); void put_onode(Onode* o); // put it back down. ref--. void dirty_onode(Onode* o); @@ -270,35 +270,35 @@ protected: // atomic transaction unsigned apply_transaction(Transaction& t, Context *onsafe=0); - int pick_object_revision_lt(object_t& oid); + int pick_object_revision_lt(pobject_t& oid); // object interface - bool exists(object_t); - int stat(object_t, struct stat*); - int read(object_t, off_t off, size_t len, bufferlist& bl); - int is_cached(object_t oid, off_t off, size_t len); - - int write(object_t oid, off_t off, size_t len, const bufferlist& bl, Context *onsafe); - int zero(object_t oid, off_t off, size_t len, Context *onsafe); - int truncate(object_t oid, off_t size, Context *onsafe=0); - int remove(object_t oid, Context *onsafe=0); + bool exists(pobject_t); + int stat(pobject_t, struct stat*); + int read(pobject_t, off_t off, size_t len, bufferlist& bl); + int is_cached(pobject_t oid, off_t off, size_t len); + + int write(pobject_t oid, off_t off, size_t len, const bufferlist& bl, Context *onsafe); + int zero(pobject_t oid, off_t off, size_t len, Context *onsafe); + int truncate(pobject_t oid, off_t size, Context *onsafe=0); + int remove(pobject_t oid, Context *onsafe=0); bool write_will_block(); - void trim_from_cache(object_t oid, off_t off, size_t len); + void trim_from_cache(pobject_t oid, off_t off, size_t len); - int rename(object_t from, object_t to); - int clone(object_t from, object_t to, Context *onsafe); + int rename(pobject_t from, pobject_t to); + int clone(pobject_t from, pobject_t to, Context *onsafe); - int list_objects(list& ls); + int list_objects(list& ls); // object attr - int setattr(object_t oid, const char *name, const void *value, size_t size, Context *onsafe=0); - int setattrs(object_t oid, map& attrset, Context *onsafe=0); - int getattr(object_t oid, const char *name, void *value, size_t size); - int getattrs(object_t oid, map &aset); - int rmattr(object_t oid, const char *name, Context *onsafe=0); - int listattr(object_t oid, vector& attrs); + int setattr(pobject_t oid, const char *name, const void *value, size_t size, Context *onsafe=0); + int setattrs(pobject_t oid, map& attrset, Context *onsafe=0); + int getattr(pobject_t oid, const char *name, void *value, size_t size); + int getattrs(pobject_t oid, map &aset); + int rmattr(pobject_t oid, const char *name, Context *onsafe=0); + int listattr(pobject_t oid, vector& attrs); - int get_object_collections(object_t oid, set& ls); + int get_object_collections(pobject_t oid, set& ls); // collections int list_collections(list& ls); @@ -306,10 +306,10 @@ protected: int create_collection(coll_t c, Context *onsafe); int destroy_collection(coll_t c, Context *onsafe); - int collection_add(coll_t c, object_t o, Context *onsafe); - int collection_remove(coll_t c, object_t o, Context *onsafe); + int collection_add(coll_t c, pobject_t o, Context *onsafe); + int collection_remove(coll_t c, pobject_t o, Context *onsafe); - int collection_list(coll_t c, list& o); + int collection_list(coll_t c, list& o); int collection_setattr(coll_t cid, const char *name, const void *value, size_t size, Context *onsafe); int collection_setattrs(coll_t cid, map &aset); @@ -319,12 +319,12 @@ protected: int collection_listattr(coll_t oid, vector& attrs); // maps - int map_lookup(object_t o, bufferlist& key, bufferlist& val); - int map_insert(object_t o, bufferlist& key, bufferlist& val); - int map_remove(object_t o, bufferlist& key); - int map_list(object_t o, list& keys); - int map_list(object_t o, map& vals); - int map_list(object_t o, + int map_lookup(pobject_t o, bufferlist& key, bufferlist& val); + int map_insert(pobject_t o, bufferlist& key, bufferlist& val); + int map_remove(pobject_t o, bufferlist& key); + int map_list(pobject_t o, list& keys); + int map_list(pobject_t o, map& vals); + int map_list(pobject_t o, bufferlist& start, bufferlist& end, map& vals); @@ -340,28 +340,28 @@ private: // private interface -- use if caller already holds lock unsigned _apply_transaction(Transaction& t); - int _read(object_t oid, off_t off, size_t len, bufferlist& bl); - int _is_cached(object_t oid, off_t off, size_t len); - int _stat(object_t oid, struct stat *st); - int _getattr(object_t oid, const char *name, void *value, size_t size); - int _getattrs(object_t oid, map &aset); - int _get_object_collections(object_t oid, set& ls); + int _read(pobject_t oid, off_t off, size_t len, bufferlist& bl); + int _is_cached(pobject_t oid, off_t off, size_t len); + int _stat(pobject_t oid, struct stat *st); + int _getattr(pobject_t oid, const char *name, void *value, size_t size); + int _getattrs(pobject_t oid, map &aset); + int _get_object_collections(pobject_t oid, set& ls); bool _write_will_block(); - int _write(object_t oid, off_t off, size_t len, const bufferlist& bl); - void _trim_from_cache(object_t oid, off_t off, size_t len); - int _truncate(object_t oid, off_t size); - int _zero(object_t oid, off_t offset, size_t length); - int _remove(object_t oid); - int _clone(object_t from, object_t to); - int _setattr(object_t oid, const char *name, const void *value, size_t size); - int _setattrs(object_t oid, map& attrset); - int _rmattr(object_t oid, const char *name); + int _write(pobject_t oid, off_t off, size_t len, const bufferlist& bl); + void _trim_from_cache(pobject_t oid, off_t off, size_t len); + int _truncate(pobject_t oid, off_t size); + int _zero(pobject_t oid, off_t offset, size_t length); + int _remove(pobject_t oid); + int _clone(pobject_t from, pobject_t to); + int _setattr(pobject_t oid, const char *name, const void *value, size_t size); + int _setattrs(pobject_t oid, map& attrset); + int _rmattr(pobject_t oid, const char *name); bool _collection_exists(coll_t c); int _create_collection(coll_t c); int _destroy_collection(coll_t c); - int _collection_add(coll_t c, object_t o); - int _collection_remove(coll_t c, object_t o); + int _collection_add(coll_t c, pobject_t o); + int _collection_remove(coll_t c, pobject_t o); int _collection_getattrs(coll_t oid, map &aset); int _collection_setattr(coll_t oid, const char *name, const void *value, size_t size); int _collection_setattrs(coll_t oid, map &aset); diff --git a/branches/ebofs/ebofs/Onode.h b/branches/ebofs/ebofs/Onode.h index 58ba445cacfaf..fd78b4f788a85 100644 --- a/branches/ebofs/ebofs/Onode.h +++ b/branches/ebofs/ebofs/Onode.h @@ -69,7 +69,7 @@ private: int ref; public: - object_t object_id; + pobject_t object_id; version_t version; // incremented on each modify. // data @@ -97,7 +97,7 @@ public: list commit_waiters; public: - Onode(object_t oid) : ref(0), object_id(oid), version(0), + Onode(pobject_t oid) : ref(0), object_id(oid), version(0), object_size(0), alloc_blocks(0), last_block(0), data_csum(0), readonly(0), oc(0), diff --git a/branches/ebofs/ebofs/types.h b/branches/ebofs/ebofs/types.h index 638cad437fe85..6645881e355e5 100644 --- a/branches/ebofs/ebofs/types.h +++ b/branches/ebofs/ebofs/types.h @@ -19,6 +19,7 @@ #include #include "include/buffer.h" #include "include/Context.h" +#include "include/pobject.h" #include "common/Cond.h" #include @@ -71,7 +72,7 @@ struct ebofs_onode { csum_t data_csum; Extent onode_loc; /* this is actually the block we live in */ - object_t object_id; /* for kicks */ + pobject_t object_id; /* for kicks */ __u8 readonly; __s64 object_size; /* file size in bytes. should this be 64-bit? */ diff --git a/branches/ebofs/include/object.h b/branches/ebofs/include/object.h index 3b8ac05a86b38..39e67212be23c 100644 --- a/branches/ebofs/include/object.h +++ b/branches/ebofs/include/object.h @@ -31,8 +31,8 @@ typedef uint32_t objectrev_t; struct object_t { static const uint32_t MAXREV = 0xffffffffU; - uint64_t ino; // "file" identifier - uint32_t bno; // "block" in that "file" + uint64_t ino; // "file" identifier + uint32_t bno; // "block" in that "file" objectrev_t rev; // revision. normally ctime (as epoch). object_t() : ino(0), bno(0), rev(0) {} @@ -40,34 +40,23 @@ struct object_t { object_t(uint64_t i, uint32_t b, uint32_t r) : ino(i), bno(b), rev(r) {} }; - inline bool operator==(const object_t l, const object_t r) { - return (l.ino == r.ino) && (l.bno == r.bno) && (l.rev == r.rev); + return memcmp(&l, &r, sizeof(l)) == 0; } inline bool operator!=(const object_t l, const object_t r) { - return (l.ino != r.ino) || (l.bno != r.bno) || (l.rev != r.rev); + return memcmp(&l, &r, sizeof(l)) != 0; } inline bool operator>(const object_t l, const object_t r) { - if (l.ino > r.ino) return true; - if (l.ino < r.ino) return false; - if (l.bno > r.bno) return true; - if (l.bno < r.bno) return false; - if (l.rev > r.rev) return true; - return false; + return memcmp(&l, &r, sizeof(l)) > 0; } inline bool operator<(const object_t l, const object_t r) { - if (l.ino < r.ino) return true; - if (l.ino > r.ino) return false; - if (l.bno < r.bno) return true; - if (l.bno > r.bno) return false; - if (l.rev < r.rev) return true; - return false; + return memcmp(&l, &r, sizeof(l)) < 0; } inline bool operator>=(const object_t l, const object_t r) { - return !(l < r); + return memcmp(&l, &r, sizeof(l)) >= 0; } inline bool operator<=(const object_t l, const object_t r) { - return !(l > r); + return memcmp(&l, &r, sizeof(l)) <= 0; } inline ostream& operator<<(ostream& out, const object_t o) { out << hex << o.ino << '.'; @@ -80,17 +69,11 @@ inline ostream& operator<<(ostream& out, const object_t o) { return out; } - - - - namespace __gnu_cxx { template<> struct hash { size_t operator()(const object_t &r) const { static rjhash H; static rjhash I; - //static hash H; - //static hash I; return H(r.ino) ^ I(r.bno) ^ I(r.rev); } }; diff --git a/branches/ebofs/include/pobject.h b/branches/ebofs/include/pobject.h new file mode 100644 index 0000000000000..a334524483719 --- /dev/null +++ b/branches/ebofs/include/pobject.h @@ -0,0 +1,68 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2006 Sage Weil + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef __CEPH_POBJECT_H +#define __CEPH_POBJECT_H + +#include "object.h" + +/* + * "physical" object stored in an individual OSD's object store. + * includes fields to describe which volume the logical object_t + * belongs to, and/or a specific part of the object (if striped + * or encoded for redundancy, etc.). + */ +struct pobject_t { + uint32_t volume; // "volume" + uint32_t rank; // rank/stripe id (e.g. for parity encoding) + object_t oid; // logical object + pobject_t() : volume(0), rank(0) {} + pobject_t(object_t o) : volume(0), rank(0), oid(o) {} // this should go away eventually + pobject_t(uint16_t v, uint16_t r, object_t o) : volume(v), rank(r), oid(o) {} +}; + +inline ostream& operator<<(ostream& out, const pobject_t o) { + return out << o.volume << '/' << o.rank << '/' << o.oid; +} + +inline bool operator==(const pobject_t l, const pobject_t r) { + return memcmp(&l, &r, sizeof(l)) == 0; +} +inline bool operator!=(const pobject_t l, const pobject_t r) { + return memcmp(&l, &r, sizeof(l)) != 0; +} +inline bool operator>(const pobject_t l, const pobject_t r) { + return memcmp(&l, &r, sizeof(l)) > 0; +} +inline bool operator>=(const pobject_t l, const pobject_t r) { + return memcmp(&l, &r, sizeof(l)) >= 0; +} +inline bool operator<(const pobject_t l, const pobject_t r) { + return memcmp(&l, &r, sizeof(l)) < 0; +} +inline bool operator<=(const pobject_t l, const pobject_t r) { + return memcmp(&l, &r, sizeof(l)) <= 0; +} + +namespace __gnu_cxx { + template<> struct hash { + size_t operator()(const pobject_t &r) const { + static rjhash H; + static rjhash I; + return I(r.volume) ^ I(r.rank) ^ H(r.oid.ino) ^ I(r.oid.bno) ^ I(r.oid.rev); + } + }; +} + +#endif diff --git a/branches/ebofs/mds/mdstypes.h b/branches/ebofs/mds/mdstypes.h index c185909d89fae..bda0b5591ae5f 100644 --- a/branches/ebofs/mds/mdstypes.h +++ b/branches/ebofs/mds/mdstypes.h @@ -32,7 +32,7 @@ using namespace std; #define MDS_INO_ROOT 1 #define MDS_INO_PGTABLE 2 #define MDS_INO_ANCHORTABLE 3 -#define MDS_INO_PG 4 // *** WARNING: this should match osd/osd_types.h PG_INO *** + #define MDS_INO_LOG_OFFSET (1*MAX_MDS) #define MDS_INO_IDS_OFFSET (2*MAX_MDS) #define MDS_INO_CLIENTMAP_OFFSET (3*MAX_MDS) diff --git a/branches/ebofs/osd/Fake.h b/branches/ebofs/osd/Fake.h index 342c153c25cfd..f364438d3b088 100644 --- a/branches/ebofs/osd/Fake.h +++ b/branches/ebofs/osd/Fake.h @@ -28,7 +28,7 @@ class FakeStoreCollections { private: Mutex faker_lock; ObjectStore *store; - hash_map > fakecollections; + hash_map > fakecollections; public: FakeStoreCollections(ObjectStore *s) : store(s) {} @@ -37,7 +37,7 @@ class FakeStoreCollections { int list_collections(list& ls) { faker_lock.Lock(); int r = 0; - for (hash_map< coll_t, set >::iterator p = fakecollections.begin(); + for (hash_map< coll_t, set >::iterator p = fakecollections.begin(); p != fakecollections.end(); p++) { r++; @@ -81,7 +81,7 @@ class FakeStoreCollections { return r; } - int collection_add(coll_t c, object_t o, + int collection_add(coll_t c, pobject_t o, Context *onsafe=0) { faker_lock.Lock(); fakecollections[c].insert(o); @@ -90,7 +90,7 @@ class FakeStoreCollections { return 0; } - int collection_remove(coll_t c, object_t o, + int collection_remove(coll_t c, pobject_t o, Context *onsafe=0) { faker_lock.Lock(); fakecollections[c].erase(o); @@ -99,10 +99,10 @@ class FakeStoreCollections { return 0; } - int collection_list(coll_t c, list& o) { + int collection_list(coll_t c, list& o) { faker_lock.Lock(); int r = 0; - for (set::iterator p = fakecollections[c].begin(); + for (set::iterator p = fakecollections[c].begin(); p != fakecollections[c].end(); p++) { o.push_back(*p); @@ -164,13 +164,13 @@ class FakeStoreAttrs { Mutex faker_lock; ObjectStore *store; - hash_map fakeoattrs; + hash_map fakeoattrs; hash_map fakecattrs; public: FakeStoreAttrs(ObjectStore *s) : store(s) {} - int setattr(object_t oid, const char *name, + int setattr(pobject_t oid, const char *name, const void *value, size_t size, Context *onsafe=0) { faker_lock.Lock(); @@ -179,26 +179,26 @@ class FakeStoreAttrs { faker_lock.Unlock(); return r; } - int setattrs(object_t oid, map& aset) { + int setattrs(pobject_t oid, map& aset) { faker_lock.Lock(); int r = fakeoattrs[oid].setattrs(aset); faker_lock.Unlock(); return r; } - int getattr(object_t oid, const char *name, + int getattr(pobject_t oid, const char *name, void *value, size_t size) { faker_lock.Lock(); int r = fakeoattrs[oid].getattr(name, value, size); faker_lock.Unlock(); return r; } - int getattrs(object_t oid, map& aset) { + int getattrs(pobject_t oid, map& aset) { faker_lock.Lock(); int r = fakeoattrs[oid].getattrs(aset); faker_lock.Unlock(); return r; } - int rmattr(object_t oid, const char *name, + int rmattr(pobject_t oid, const char *name, Context *onsafe=0) { faker_lock.Lock(); int r = fakeoattrs[oid].rmattr(name); @@ -207,7 +207,7 @@ class FakeStoreAttrs { return r; } - int listattr(object_t oid, char *attrs, size_t size) { + int listattr(pobject_t oid, char *attrs, size_t size) { faker_lock.Lock(); int r = fakeoattrs[oid].listattr(attrs,size); faker_lock.Unlock(); diff --git a/branches/ebofs/osd/FakeStore.cc b/branches/ebofs/osd/FakeStore.cc index e7c77f3eab558..6f50e16e4a074 100644 --- a/branches/ebofs/osd/FakeStore.cc +++ b/branches/ebofs/osd/FakeStore.cc @@ -64,25 +64,48 @@ int FakeStore::statfs(struct statfs *buf) /* - * sorry, these are sentitive to the object_t and coll_t typing. + * sorry, these are sentitive to the pobject_t and coll_t typing. */ -void FakeStore::get_oname(object_t oid, char *s) +void FakeStore::get_oname(pobject_t oid, char *s) { - //static hash H; - assert(sizeof(oid) == 16); + //static hash H; + assert(sizeof(oid) == 24); #ifdef __LP64__ //sprintf(s, "%s/objects/%02lx/%016lx.%016lx", basedir.c_str(), H(oid) & HASH_MASK, - sprintf(s, "%s/objects/%016lx.%016lx", basedir.c_str(), - *((uint64_t*)&oid), - *(((uint64_t*)&oid) + 1)); + sprintf(s, "%s/objects/%04x.%04x.%016lx.%016lx", basedir.c_str(), + oid.volume, oid.rank, + *((uint64_t*)&oid.oid), + *(((uint64_t*)&oid.oid) + 1)); #else //sprintf(s, "%s/objects/%02x/%016llx.%016llx", basedir.c_str(), H(oid) & HASH_MASK, - sprintf(s, "%s/objects/%016llx.%016llx", basedir.c_str(), + sprintf(s, "%s/objects/%04x.%04x.%016llx.%016llx", basedir.c_str(), + oid.volume, oisd.rank, *((uint64_t*)&oid), *(((uint64_t*)&oid) + 1)); #endif } +pobject_t FakeStore::parse_object(char *s) +{ + pobject_t o; + assert(sizeof(o) == 24); + //cout << " got object " << de->d_name << std::endl; + o.volume = strtoll(s, 0, 16); + assert(s[4] == '.'); + o.rank = strtoll(s+5, 0, 16); + assert(s[9] == '.'); + *(((uint64_t*)&o.oid) + 0) = strtoll(s+10, 0, 16); + assert(s[26] == '.'); + *(((uint64_t*)&o.oid) + 1) = strtoll(s+27, 0, 16); + dout(0) << " got " << o << " errno " << errno << " on " << s << dendl; + return o; +} + +coll_t FakeStore::parse_coll(char *s) +{ + return strtoll(s, 0, 16); +} + void FakeStore::get_cdir(coll_t cid, char *s) { assert(sizeof(cid) == 8); @@ -95,15 +118,17 @@ void FakeStore::get_cdir(coll_t cid, char *s) #endif } -void FakeStore::get_coname(coll_t cid, object_t oid, char *s) +void FakeStore::get_coname(coll_t cid, pobject_t oid, char *s) { - assert(sizeof(oid) == 16); + assert(sizeof(oid) == 24); #ifdef __LP64__ - sprintf(s, "%s/collections/%016lx/%016lx.%016lx", basedir.c_str(), cid, - *((uint64_t*)&oid), - *(((uint64_t*)&oid) + 1)); + sprintf(s, "%s/collections/%016lx/%04x.%04x.%016lx.%016lx", basedir.c_str(), cid, + oid.volume, oid.rank, + *((uint64_t*)&oid.oid), + *(((uint64_t*)&oid.oid) + 1)); #else - sprintf(s, "%s/collections/%016llx/%016llx.%016llx", basedir.c_str(), cid, + sprintf(s, "%s/collections/%016llx/%04x.%04x.%016llx.%016llx", basedir.c_str(), cid, + oid.volume, oid.rank, *((uint64_t*)&oid), *(((uint64_t*)&oid) + 1)); #endif @@ -226,7 +251,7 @@ int FakeStore::umount() // objects -bool FakeStore::exists(object_t oid) +bool FakeStore::exists(pobject_t oid) { struct stat st; if (stat(oid, &st) == 0) @@ -236,7 +261,7 @@ bool FakeStore::exists(object_t oid) } -int FakeStore::stat(object_t oid, +int FakeStore::stat(pobject_t oid, struct stat *st) { dout(20) << "stat " << oid << dendl; @@ -248,7 +273,7 @@ int FakeStore::stat(object_t oid, -int FakeStore::remove(object_t oid, Context *onsafe) +int FakeStore::remove(pobject_t oid, Context *onsafe) { dout(20) << "remove " << oid << dendl; char fn[200]; @@ -258,7 +283,7 @@ int FakeStore::remove(object_t oid, Context *onsafe) return r; } -int FakeStore::truncate(object_t oid, off_t size, Context *onsafe) +int FakeStore::truncate(pobject_t oid, off_t size, Context *onsafe) { dout(20) << "truncate " << oid << " size " << size << dendl; @@ -269,7 +294,7 @@ int FakeStore::truncate(object_t oid, off_t size, Context *onsafe) return r; } -int FakeStore::read(object_t oid, +int FakeStore::read(pobject_t oid, off_t offset, size_t len, bufferlist& bl) { dout(20) << "read " << oid << " len " << len << " off " << offset << dendl; @@ -305,7 +330,7 @@ int FakeStore::read(object_t oid, } -int FakeStore::write(object_t oid, +int FakeStore::write(pobject_t oid, off_t offset, size_t len, const bufferlist& bl, Context *onsafe) @@ -410,7 +435,7 @@ void FakeStore::sync(Context *onsafe) // objects -int FakeStore::setattr(object_t oid, const char *name, +int FakeStore::setattr(pobject_t oid, const char *name, const void *value, size_t size, Context *onsafe) { @@ -425,7 +450,7 @@ int FakeStore::setattr(object_t oid, const char *name, return r; } -int FakeStore::setattrs(object_t oid, map& aset) +int FakeStore::setattrs(pobject_t oid, map& aset) { if (fake_attrs) return attrs.setattrs(oid, aset); @@ -446,7 +471,7 @@ int FakeStore::setattrs(object_t oid, map& aset) return r; } -int FakeStore::getattr(object_t oid, const char *name, +int FakeStore::getattr(pobject_t oid, const char *name, void *value, size_t size) { if (fake_attrs) return attrs.getattr(oid, name, value, size); @@ -459,7 +484,7 @@ int FakeStore::getattr(object_t oid, const char *name, return r; } -int FakeStore::getattrs(object_t oid, map& aset) +int FakeStore::getattrs(pobject_t oid, map& aset) { if (fake_attrs) return attrs.getattrs(oid, aset); @@ -483,7 +508,7 @@ int FakeStore::getattrs(object_t oid, map& aset) return 0; } -int FakeStore::rmattr(object_t oid, const char *name, Context *onsafe) +int FakeStore::rmattr(pobject_t oid, const char *name, Context *onsafe) { if (fake_attrs) return attrs.rmattr(oid, name, onsafe); int r = 0; @@ -496,7 +521,7 @@ int FakeStore::rmattr(object_t oid, const char *name, Context *onsafe) } /* -int FakeStore::listattr(object_t oid, char *attrls, size_t size) +int FakeStore::listattr(pobject_t oid, char *attrls, size_t size) { if (fake_attrs) return attrs.listattr(oid, attrls, size); char fn[100]; @@ -582,7 +607,7 @@ int FakeStore::collection_listattr(coll_t c, char *attrs, size_t size) */ -int FakeStore::list_objects(list& ls) +int FakeStore::list_objects(list& ls) { char fn[200]; sprintf(fn, "%s/objects", basedir.c_str()); @@ -594,13 +619,7 @@ int FakeStore::list_objects(list& ls) while ((de = ::readdir(dir)) != 0) { if (de->d_name[0] == '.') continue; // parse - object_t o; - assert(sizeof(o) == 16); - //cout << " got object " << de->d_name << std::endl; - *(((uint64_t*)&o) + 0) = strtoll(de->d_name, 0, 16); - assert(de->d_name[16] == '.'); - *(((uint64_t*)&o) + 1) = strtoll(de->d_name+17, 0, 16); - //dout(0) << " got " << o << " errno " << errno << " on " << de->d_name << dendl; + pobject_t o = parse_object(de->d_name); if (errno) continue; ls.push_back(o); } @@ -627,7 +646,7 @@ int FakeStore::list_collections(list& ls) while ((de = ::readdir(dir)) != 0) { // parse errno = 0; - coll_t c = strtoll(de->d_name, 0, 16); + coll_t c = parse_coll(de->d_name); if (c) ls.push_back(c); } @@ -682,7 +701,7 @@ bool FakeStore::collection_exists(coll_t c) } -int FakeStore::collection_add(coll_t c, object_t o, +int FakeStore::collection_add(coll_t c, pobject_t o, Context *onsafe) { if (fake_collections) return collections.collection_add(c, o, onsafe); @@ -697,7 +716,7 @@ int FakeStore::collection_add(coll_t c, object_t o, return r; } -int FakeStore::collection_remove(coll_t c, object_t o, +int FakeStore::collection_remove(coll_t c, pobject_t o, Context *onsafe) { if (fake_collections) return collections.collection_remove(c, o, onsafe); @@ -710,7 +729,7 @@ int FakeStore::collection_remove(coll_t c, object_t o, return r; } -int FakeStore::collection_list(coll_t c, list& ls) +int FakeStore::collection_list(coll_t c, list& ls) { if (fake_collections) return collections.collection_list(c, ls); @@ -725,12 +744,7 @@ int FakeStore::collection_list(coll_t c, list& ls) // parse if (de->d_name[0] == '.') continue; //cout << " got object " << de->d_name << std::endl; - object_t o; - assert(sizeof(o) == 16); - *(((uint64_t*)&o) + 0) = strtoll(de->d_name, 0, 16); - assert(de->d_name[16] == '.'); - *(((uint64_t*)&o) + 1) = strtoll(de->d_name+17, 0, 16); - dout(0) << " got " << o << " errno " << errno << " on " << de->d_name << dendl; + pobject_t o = parse_object(de->d_name); if (errno) continue; ls.push_back(o); } diff --git a/branches/ebofs/osd/FakeStore.h b/branches/ebofs/osd/FakeStore.h index 5828c27c14d96..bbd7d82d3978f 100644 --- a/branches/ebofs/osd/FakeStore.h +++ b/branches/ebofs/osd/FakeStore.h @@ -49,9 +49,11 @@ class FakeStore : public ObjectStore { bool fake_collections; // helper fns - void get_oname(object_t oid, char *s); + void get_oname(pobject_t oid, char *s); void get_cdir(coll_t cid, char *s); - void get_coname(coll_t cid, object_t oid, char *s); + void get_coname(coll_t cid, pobject_t oid, char *s); + pobject_t parse_object(char *s); + coll_t parse_coll(char *s); public: FakeStore(char *base) : @@ -68,28 +70,28 @@ class FakeStore : public ObjectStore { // ------------------ // objects - int pick_object_revision_lt(object_t& oid) { + int pick_object_revision_lt(pobject_t& oid) { return 0; } - bool exists(object_t oid); - 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, const bufferlist& bl, Context *onsafe); + bool exists(pobject_t oid); + int stat(pobject_t oid, struct stat *st); + int remove(pobject_t oid, Context *onsafe); + int truncate(pobject_t oid, off_t size, Context *onsafe); + int read(pobject_t oid, off_t offset, size_t len, bufferlist& bl); + int write(pobject_t oid, off_t offset, size_t len, const bufferlist& bl, Context *onsafe); void sync(); void sync(Context *onsafe); - int list_objects(list& ls); + int list_objects(list& ls); // attrs - int setattr(object_t oid, const char *name, const void *value, size_t size, Context *onsafe=0); - int setattrs(object_t oid, map& aset); - int getattr(object_t oid, const char *name, void *value, size_t size); - int getattrs(object_t oid, map& aset); - int rmattr(object_t oid, const char *name, Context *onsafe=0); - //int listattr(object_t oid, char *attrs, size_t size); + int setattr(pobject_t oid, const char *name, const void *value, size_t size, Context *onsafe=0); + int setattrs(pobject_t oid, map& aset); + int getattr(pobject_t oid, const char *name, void *value, size_t size); + int getattrs(pobject_t oid, map& aset); + int rmattr(pobject_t oid, const char *name, Context *onsafe=0); + //int listattr(pobject_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); @@ -103,9 +105,9 @@ class FakeStore : public ObjectStore { 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_list(coll_t c, list& o); + int collection_add(coll_t c, pobject_t o, Context *onsafe=0); + int collection_remove(coll_t c, pobject_t o, Context *onsafe=0); + int collection_list(coll_t c, list& o); diff --git a/branches/ebofs/osd/OSD.cc b/branches/ebofs/osd/OSD.cc index 9e5210a4bc862..0512d57f13437 100644 --- a/branches/ebofs/osd/OSD.cc +++ b/branches/ebofs/osd/OSD.cc @@ -459,12 +459,12 @@ void OSD::_remove_unlock_pg(PG *pg) dout(10) << "_remove_unlock_pg " << pgid << dendl; // remove from store - list olist; + list olist; store->collection_list(pgid, olist); ObjectStore::Transaction t; { - for (list::iterator p = olist.begin(); + for (list::iterator p = olist.begin(); p != olist.end(); p++) t.remove(*p); diff --git a/branches/ebofs/osd/ObjectStore.h b/branches/ebofs/osd/ObjectStore.h index d683120933b59..4902d94925c69 100644 --- a/branches/ebofs/osd/ObjectStore.h +++ b/branches/ebofs/osd/ObjectStore.h @@ -20,6 +20,7 @@ #include "osd_types.h" #include "include/Context.h" #include "include/buffer.h" +#include "include/pobject.h" #include "include/Distribution.h" @@ -99,7 +100,7 @@ public: private: list ops; list bls; - list oids; + list oids; list cids; list lengths; list attrnames; @@ -125,7 +126,7 @@ public: bl.claim(bls.front()); bls.pop_front(); } - void get_oid(object_t& oid) { + void get_oid(pobject_t& oid) { oid = oids.front(); oids.pop_front(); } @@ -159,7 +160,7 @@ public: } - void read(object_t oid, off_t off, size_t len, bufferlist *pbl) { + void read(pobject_t oid, off_t off, size_t len, bufferlist *pbl) { int op = OP_READ; ops.push_back(op); oids.push_back(oid); @@ -167,27 +168,27 @@ public: lengths.push_back(len); pbls.push_back(pbl); } - void stat(object_t oid, struct stat *st) { + void stat(pobject_t oid, struct stat *st) { int op = OP_STAT; ops.push_back(op); oids.push_back(oid); psts.push_back(st); } - void getattr(object_t oid, const char* name, void* val, int *plen) { + void getattr(pobject_t oid, const char* name, void* val, int *plen) { int op = OP_GETATTR; ops.push_back(op); oids.push_back(oid); attrnames.push_back(name); pattrvals.push_back(pair(val,plen)); } - void getattrs(object_t oid, map& aset) { + void getattrs(pobject_t oid, map& aset) { int op = OP_GETATTRS; ops.push_back(op); oids.push_back(oid); pattrsets.push_back(&aset); } - void write(object_t oid, off_t off, size_t len, const bufferlist& bl) { + void write(pobject_t oid, off_t off, size_t len, const bufferlist& bl) { int op = OP_WRITE; ops.push_back(op); oids.push_back(oid); @@ -195,32 +196,32 @@ public: lengths.push_back(len); bls.push_back(bl); } - void zero(object_t oid, off_t off, size_t len) { + void zero(pobject_t oid, off_t off, size_t len) { int op = OP_ZERO; ops.push_back(op); oids.push_back(oid); lengths.push_back(off); lengths.push_back(len); } - void trim_from_cache(object_t oid, off_t off, size_t len) { + void trim_from_cache(pobject_t oid, off_t off, size_t len) { int op = OP_TRIMCACHE; ops.push_back(op); oids.push_back(oid); lengths.push_back(off); lengths.push_back(len); } - void truncate(object_t oid, off_t off) { + void truncate(pobject_t oid, off_t off) { int op = OP_TRUNCATE; ops.push_back(op); oids.push_back(oid); lengths.push_back(off); } - void remove(object_t oid) { + void remove(pobject_t oid) { int op = OP_REMOVE; ops.push_back(op); oids.push_back(oid); } - void setattr(object_t oid, const char* name, const void* val, int len) { + void setattr(pobject_t oid, const char* name, const void* val, int len) { int op = OP_SETATTR; ops.push_back(op); oids.push_back(oid); @@ -230,19 +231,19 @@ public: bl.append((char*)val,len); bls.push_back(bl); } - void setattrs(object_t oid, map& attrset) { + void setattrs(pobject_t oid, map& attrset) { int op = OP_SETATTRS; ops.push_back(op); oids.push_back(oid); pattrsets.push_back(&attrset); } - void rmattr(object_t oid, const char* name) { + void rmattr(pobject_t oid, const char* name) { int op = OP_RMATTR; ops.push_back(op); oids.push_back(oid); attrnames.push_back(name); } - void clone(object_t oid, object_t noid) { + void clone(pobject_t oid, pobject_t noid) { int op = OP_CLONE; ops.push_back(op); oids.push_back(oid); @@ -258,13 +259,13 @@ public: ops.push_back(op); cids.push_back(cid); } - void collection_add(coll_t cid, object_t oid) { + void collection_add(coll_t cid, pobject_t oid) { int op = OP_COLL_ADD; ops.push_back(op); cids.push_back(cid); oids.push_back(oid); } - void collection_remove(coll_t cid, object_t oid) { + void collection_remove(coll_t cid, pobject_t oid) { int op = OP_COLL_REMOVE; ops.push_back(op); cids.push_back(cid); @@ -322,7 +323,7 @@ public: switch (op) { case Transaction::OP_READ: { - object_t oid; + pobject_t oid; off_t offset, len; t.get_oid(oid); t.get_length(offset); @@ -334,7 +335,7 @@ public: break; case Transaction::OP_STAT: { - object_t oid; + pobject_t oid; t.get_oid(oid); struct stat *st; t.get_pstat(st); @@ -343,7 +344,7 @@ public: break; case Transaction::OP_GETATTR: { - object_t oid; + pobject_t oid; t.get_oid(oid); const char *attrname; t.get_attrname(attrname); @@ -354,7 +355,7 @@ public: break; case Transaction::OP_GETATTRS: { - object_t oid; + pobject_t oid; t.get_oid(oid); map *pset; t.get_pattrset(pset); @@ -364,7 +365,7 @@ public: case Transaction::OP_WRITE: { - object_t oid; + pobject_t oid; t.get_oid(oid); off_t offset, len; t.get_length(offset); @@ -377,7 +378,7 @@ public: case Transaction::OP_ZERO: { - object_t oid; + pobject_t oid; t.get_oid(oid); off_t offset, len; t.get_length(offset); @@ -388,7 +389,7 @@ public: case Transaction::OP_TRIMCACHE: { - object_t oid; + pobject_t oid; t.get_oid(oid); off_t offset, len; t.get_length(offset); @@ -399,7 +400,7 @@ public: case Transaction::OP_TRUNCATE: { - object_t oid; + pobject_t oid; t.get_oid(oid); off_t len; t.get_length(len); @@ -409,7 +410,7 @@ public: case Transaction::OP_REMOVE: { - object_t oid; + pobject_t oid; t.get_oid(oid); remove(oid, 0); } @@ -417,7 +418,7 @@ public: case Transaction::OP_SETATTR: { - object_t oid; + pobject_t oid; t.get_oid(oid); const char *attrname; t.get_attrname(attrname); @@ -428,7 +429,7 @@ public: break; case Transaction::OP_SETATTRS: { - object_t oid; + pobject_t oid; t.get_oid(oid); map *pattrset; t.get_pattrset(pattrset); @@ -438,7 +439,7 @@ public: case Transaction::OP_RMATTR: { - object_t oid; + pobject_t oid; t.get_oid(oid); const char *attrname; t.get_attrname(attrname); @@ -448,9 +449,9 @@ public: case Transaction::OP_CLONE: { - object_t oid; + pobject_t oid; t.get_oid(oid); - object_t noid; + pobject_t noid; t.get_oid(noid); clone(oid, noid); } @@ -476,7 +477,7 @@ public: { coll_t cid; t.get_cid(cid); - object_t oid; + pobject_t oid; t.get_oid(oid); collection_add(cid, oid, 0); } @@ -486,7 +487,7 @@ public: { coll_t cid; t.get_cid(cid); - object_t oid; + pobject_t oid; t.get_oid(oid); collection_remove(cid, oid, 0); } @@ -542,25 +543,25 @@ public: virtual int statfs(struct statfs *buf) = 0; // objects - virtual int pick_object_revision_lt(object_t& oid) = 0; + virtual int pick_object_revision_lt(pobject_t& oid) = 0; - virtual bool exists(object_t oid) = 0; // useful? - virtual int stat(object_t oid, struct stat *st) = 0; // struct stat? + virtual bool exists(pobject_t oid) = 0; // useful? + virtual int stat(pobject_t oid, struct stat *st) = 0; // struct stat? - virtual int remove(object_t oid, + virtual int remove(pobject_t oid, Context *onsafe=0) = 0; - virtual int truncate(object_t oid, off_t size, + virtual int truncate(pobject_t oid, off_t size, Context *onsafe=0) = 0; - virtual int read(object_t oid, + virtual int read(pobject_t oid, off_t offset, size_t len, bufferlist& bl) = 0; - virtual int write(object_t oid, + virtual int write(pobject_t oid, off_t offset, size_t len, const bufferlist& bl, Context *onsafe) = 0;//{ return -1; } - virtual int zero(object_t oid, + virtual int zero(pobject_t oid, off_t offset, size_t len, Context *onsafe) { // write zeros.. yuck! @@ -569,33 +570,33 @@ public: bl.push_back(bp); return write(oid, offset, len, bl, onsafe); } - virtual void trim_from_cache(object_t oid, + virtual void trim_from_cache(pobject_t oid, off_t offset, size_t len) { } - virtual int is_cached(object_t oid, + virtual int is_cached(pobject_t oid, off_t offset, size_t len) { return -1; } - virtual int setattr(object_t oid, const char *name, + virtual int setattr(pobject_t oid, const char *name, const void *value, size_t size, Context *onsafe=0) {return 0;} //= 0; - virtual int setattrs(object_t oid, map& aset, + virtual int setattrs(pobject_t oid, map& aset, Context *onsafe=0) {return 0;} //= 0; - virtual int getattr(object_t oid, const char *name, + virtual int getattr(pobject_t oid, const char *name, void *value, size_t size) {return 0;} //= 0; - virtual int getattrs(object_t oid, map& aset) {return 0;}; + virtual int getattrs(pobject_t oid, map& aset) {return 0;}; - virtual int rmattr(object_t oid, const char *name, + virtual int rmattr(pobject_t oid, const char *name, Context *onsafe=0) {return 0;} - virtual int clone(object_t oid, object_t noid) { + virtual int clone(pobject_t oid, pobject_t noid) { return -1; } - virtual int list_objects(list& ls) = 0;//{ return -1; } + virtual int list_objects(list& ls) = 0;//{ return -1; } - virtual int get_object_collections(object_t oid, set& ls) { return -1; } + virtual int get_object_collections(pobject_t oid, set& ls) { return -1; } - //virtual int listattr(object_t oid, char *attrs, size_t size) {return 0;} //= 0; + //virtual int listattr(pobject_t oid, char *attrs, size_t size) {return 0;} //= 0; // collections virtual int list_collections(list& ls) {return 0;}//= 0; @@ -605,11 +606,11 @@ public: Context *onsafe=0) {return 0;}//= 0; virtual bool collection_exists(coll_t c) {return 0;} virtual int collection_stat(coll_t c, struct stat *st) {return 0;}//= 0; - virtual int collection_add(coll_t c, object_t o, + virtual int collection_add(coll_t c, pobject_t o, Context *onsafe=0) {return 0;}//= 0; - virtual int collection_remove(coll_t c, object_t o, + virtual int collection_remove(coll_t c, pobject_t o, Context *onsafe=0) {return 0;}// = 0; - virtual int collection_list(coll_t c, list& o) {return 0;}//= 0; + virtual int collection_list(coll_t c, list& o) {return 0;}//= 0; virtual int collection_setattr(coll_t cid, const char *name, const void *value, size_t size, diff --git a/branches/ebofs/osd/PG.cc b/branches/ebofs/osd/PG.cc index 99b81f2f0dc96..cb2703d101ce8 100644 --- a/branches/ebofs/osd/PG.cc +++ b/branches/ebofs/osd/PG.cc @@ -430,23 +430,24 @@ void PG::generate_backlog() assert(!log.backlog); log.backlog = true; - list olist; + list olist; osd->store->collection_list(info.pgid, olist); int local = 0; map add; - for (list::iterator it = olist.begin(); + for (list::iterator it = olist.begin(); it != olist.end(); it++) { local++; + object_t oid = it->oid; - if (log.logged_object(*it)) continue; // already have it logged. + if (log.logged_object(oid)) continue; // already have it logged. // add entry Log::Entry e; e.op = Log::Entry::MODIFY; // FIXME when we do smarter op codes! - e.oid = *it; - osd->store->getattr(*it, + e.oid = oid; + osd->store->getattr(pobject_t(0,0,oid), "version", &e.version, sizeof(e.version)); add[e.version] = e; @@ -1266,7 +1267,7 @@ bool PG::pick_missing_object_rev(object_t& oid) bool PG::pick_object_rev(object_t& oid) { - object_t t = oid; + pobject_t t = oid; if (!osd->store->pick_object_revision_lt(t)) return false; // we have no revisions of this object! @@ -1276,7 +1277,7 @@ bool PG::pick_object_rev(object_t& oid) assert(r >= 0); if (crev <= oid.rev) { dout(10) << "pick_object_rev choosing " << t << " crev " << crev << " for " << oid << dendl; - oid = t; + oid = t.oid; return true; } diff --git a/branches/ebofs/osd/ReplicatedPG.cc b/branches/ebofs/osd/ReplicatedPG.cc index 07ab10fadbd20..592c7ca20d1e5 100644 --- a/branches/ebofs/osd/ReplicatedPG.cc +++ b/branches/ebofs/osd/ReplicatedPG.cc @@ -150,7 +150,7 @@ bool ReplicatedPG::preprocess_op(MOSDOp *op, utime_t now) bool is_balanced = false; bool b; // *** FIXME *** this may block, and we're in the fast path! *** - if (osd->store->getattr(oid, "balance-reads", &b, 1) >= 0) + if (osd->store->getattr(pobject_t(0,0,oid), "balance-reads", &b, 1) >= 0) is_balanced = true; if (!is_balanced && should_balance && @@ -321,13 +321,13 @@ bool ReplicatedPG::preprocess_op(MOSDOp *op, utime_t now) // -- fastpath read? // if this is a read and the data is in the cache, do an immediate read.. if ( g_conf.osd_immediate_read_from_cache ) { - if (osd->store->is_cached( oid , + if (osd->store->is_cached( pobject_t(0,0,oid) , op->get_offset(), op->get_length() ) == 0) { if (!is_primary() && !op->get_source().is_osd()) { // am i allowed? bool v; - if (osd->store->getattr(oid, "balance-reads", &v, 1) < 0) { + if (osd->store->getattr(pobject_t(0,0,oid), "balance-reads", &v, 1) < 0) { dout(-10) << "preprocess_op in-cache but no balance-reads on " << oid << ", fwd to primary" << dendl; osd->messenger->send_message(op, osd->osdmap->get_inst(get_primary())); @@ -1731,15 +1731,18 @@ void ReplicatedPG::clean_up_local(ObjectStore::Transaction& t) assert(info.last_update >= log.bottom); // otherwise we need some help! if (log.backlog) { + + // FIXME: sloppy pobject vs object conversions abound! *** + // be thorough. - list ls; + list ls; osd->store->collection_list(info.pgid, ls); set s; - for (list::iterator i = ls.begin(); + for (list::iterator i = ls.begin(); i != ls.end(); i++) - s.insert(*i); + s.insert(i->oid); set did; for (list::reverse_iterator p = log.log.rbegin(); diff --git a/branches/ebofs/osd/osd_types.h b/branches/ebofs/osd/osd_types.h index abfc7ad7da1e5..babc9fe4c8d2e 100644 --- a/branches/ebofs/osd/osd_types.h +++ b/branches/ebofs/osd/osd_types.h @@ -17,6 +17,7 @@ #include "msg/msg_types.h" #include "include/types.h" +#include "include/pobject.h" /* osdreqid_t - caller name + incarnation# + tid to unique identify this request * use for metadata and osd ops. @@ -67,8 +68,6 @@ typedef uint64_t coll_t; // collection id // pg stuff -#define PG_INO 4 // this should match mds/mdstypes.h MDS_INO_PG - typedef uint16_t ps_t; typedef uint8_t pruleset_t; @@ -119,7 +118,11 @@ public: */ operator uint64_t() const { return u.pg64; } - object_t to_object() const { return object_t(PG_INO, u.pg64 >> 32, u.pg64 & 0xffffffff); } + pobject_t to_object() const { + return pobject_t(1, // volume 1 == osd metadata, for now + 0, + object_t(u.pg64, 0)); + } }; inline ostream& operator<<(ostream& out, pg_t pg) -- 2.39.5