From e936ca8591ca7930bc7699b3ab22d9598fa9a565 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 6 Aug 2008 09:44:33 -0700 Subject: [PATCH] osd: fix pg create peer ordering --- src/dstartnew.sh | 1 + src/ebofs/Ebofs.cc | 6 ++++-- src/include/object.h | 4 +--- src/osd/OSD.cc | 22 +++++++++++++--------- src/vstartnew.sh | 4 ++-- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/dstartnew.sh b/src/dstartnew.sh index fae270e408b88..c21119054b577 100755 --- a/src/dstartnew.sh +++ b/src/dstartnew.sh @@ -45,6 +45,7 @@ do ls -al $dev ssh cosd$host cd ceph/src \; ./cosd --mkfs_for_osd $osd $dev # --osd_auto_weight 1 ssh cosd$host cd ceph/src \; ./cosd $dev -d --debug_ms 1 --debug_osd 20 --debug_filestore 10 +# ssh cosd$host cd ceph/src \; valgrind --leak-check-full --show-reachable-yes ./cosd $dev --debug_ms 1 --debug_osd 20 --debug_filestore 10 1>out/o$osd \& done done diff --git a/src/ebofs/Ebofs.cc b/src/ebofs/Ebofs.cc index 199d45aa9d035..a7274dd35d465 100644 --- a/src/ebofs/Ebofs.cc +++ b/src/ebofs/Ebofs.cc @@ -1179,7 +1179,7 @@ csum_t Ebofs::encode_cnode(Cnode *cn, bufferlist& bl, unsigned& off) off += sizeof(ec); // attr - for (map::iterator i = cn->attr.begin(); + for (map::iterator i = cn->attr.begin(); i != cn->attr.end(); i++) { bl.copy_in(off, i->first.length()+1, i->first.c_str()); @@ -1218,7 +1218,8 @@ void Ebofs::write_cnode(Cnode *cn) allocator.release(cn->cnode_loc); allocator.allocate(cn->cnode_loc, blocks, Allocator::NEAR_LAST_FWD); - dout(10) << "write_cnode " << *cn << " to " << cn->cnode_loc << dendl; + dout(10) << "write_cnode " << *cn << " to " << cn->cnode_loc + << " bufptr " << (void*)bl.c_str() << dendl; // encode unsigned off = 0; @@ -3479,6 +3480,7 @@ bool Ebofs::collection_exists(coll_t cid) ebofs_lock.Lock(); dout(10) << "collection_exists " << hex << cid << dec << dendl; bool r = _collection_exists(cid); + dout(10) << "collection_exists " << hex << cid << dec << " = " << r << dendl; ebofs_lock.Unlock(); return r; } diff --git a/src/include/object.h b/src/include/object.h index 3fb9a6b46789f..c3f7162436c1b 100644 --- a/src/include/object.h +++ b/src/include/object.h @@ -31,8 +31,6 @@ using namespace __gnu_cxx; typedef uint64_t objectrev_t; struct object_t { - static const uint64_t MAXREV = 0xffffffffffffffffULL; - union { __u8 raw[20]; struct { @@ -40,7 +38,7 @@ struct object_t { uint32_t bno; // "block" in that "file" objectrev_t rev; // revision. normally ctime (as epoch). } __attribute__ ((packed)); - }; + } __attribute__ ((packed)); object_t() : ino(0), bno(0), rev(0) {} object_t(uint64_t i, uint32_t b) : ino(i), bno(b), rev(0) {} diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 9f077861feeac..e05312c9523bd 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2121,8 +2121,9 @@ void OSD::handle_pg_create(MOSDPGCreate *m) map< int, map > query_map; map info_map; + ObjectStore::Transaction t; - int created = 0; + vector to_peer; for (map::iterator p = m->mkpg.begin(); p != m->mkpg.end(); @@ -2185,22 +2186,25 @@ void OSD::handle_pg_create(MOSDPGCreate *m) query_map[*p][pgid] = PG::Query(PG::Query::INFO, history); PG *pg = try_create_pg(pgid, t); - if (pg) { - created++; - wake_pg_waiters(pg->info.pgid); - pg->peer(t, query_map, &info_map); - pg->update_stats(); - pg->unlock(); - } + if (pg) + to_peer.push_back(pg); } store->apply_transaction(t); + for (vector::iterator p = to_peer.begin(); p != to_peer.end(); p++) { + PG *pg = *p; + wake_pg_waiters(pg->info.pgid); + pg->peer(t, query_map, &info_map); + pg->update_stats(); + pg->unlock(); + } + do_queries(query_map); do_infos(info_map); kick_pg_split_queue(); - if (created) + if (to_peer.size()) update_heartbeat_peers(); delete m; } diff --git a/src/vstartnew.sh b/src/vstartnew.sh index 46fdbe3462eee..d4f0e2ca4db4b 100755 --- a/src/vstartnew.sh +++ b/src/vstartnew.sh @@ -37,8 +37,8 @@ $CEPH_BIN/cmonctl osd setmap -i .ceph_osdmap for osd in 0 #1 2 3 #4 5 6 7 8 9 10 11 12 13 14 15 do $CEPH_BIN/cosd --mkfs_for_osd $osd dev/osd$osd # initialize empty object store - #valgrind --leak-check=full --show-reachable=yes $CEPH_BIN/cosd dev/osd$osd --debug_ms 1 --debug_osd 20 --debug_filestore 10 1>out/o$osd & #--debug_osd 40 - $CEPH_BIN/cosd -m $IP:12345 dev/osd$osd -d --debug_ms 1 --debug_osd 20 # --debug_filestore 10 + echo valgrind --leak-check=full --show-reachable=yes $CEPH_BIN/cosd dev/osd$osd --debug_ms 1 --debug_osd 20 --debug_filestore 10 --debug_ebofs 20 #1>out/o$osd #& #--debug_osd 40 + #$CEPH_BIN/cosd -m $IP:12345 dev/osd$osd -d --debug_ms 1 --debug_osd 20 # --debug_filestore 10 done # mds -- 2.39.5