From fd9422edfe9452bbd570873c04d341f4f5e2ca80 Mon Sep 17 00:00:00 2001 From: sageweil Date: Fri, 23 Feb 2007 22:47:21 +0000 Subject: [PATCH] fixed osd failure reporting; monitorstore mkfs; monitorstore cleanup git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1123 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/riccardo/monitor2/client/Client.cc | 4 +- branches/riccardo/monitor2/client/Client.h | 2 +- .../riccardo/monitor2/mon/MonitorStore.cc | 43 +++++++++++-------- branches/riccardo/monitor2/msg/Dispatcher.h | 2 +- .../riccardo/monitor2/msg/SimpleMessenger.cc | 2 +- branches/riccardo/monitor2/osd/OSD.cc | 3 ++ 6 files changed, 33 insertions(+), 23 deletions(-) diff --git a/branches/riccardo/monitor2/client/Client.cc b/branches/riccardo/monitor2/client/Client.cc index 2b85f1a7ad97d..928096ace4667 100644 --- a/branches/riccardo/monitor2/client/Client.cc +++ b/branches/riccardo/monitor2/client/Client.cc @@ -2617,8 +2617,10 @@ int Client::lazyio_synchronize(int fd, off_t offset, size_t count) } -void Client::ms_handle_failure(Message *m, entity_name_t dest, const entity_inst_t& inst) +void Client::ms_handle_failure(Message *m, const entity_inst_t& inst) { + msg_addr_t dest = inst.name; + if (dest.is_mon()) { // resend to a different monitor. int mon = monmap->pick_mon(true); diff --git a/branches/riccardo/monitor2/client/Client.h b/branches/riccardo/monitor2/client/Client.h index de16639c89e64..e00c6eae3ca48 100644 --- a/branches/riccardo/monitor2/client/Client.h +++ b/branches/riccardo/monitor2/client/Client.h @@ -582,7 +582,7 @@ protected: int describe_layout(char *fn, list& result); - void ms_handle_failure(Message*, entity_name_t dest, const entity_inst_t& inst); + void ms_handle_failure(Message*, const entity_inst_t& inst); }; #endif diff --git a/branches/riccardo/monitor2/mon/MonitorStore.cc b/branches/riccardo/monitor2/mon/MonitorStore.cc index cce0d759393a7..a56dcb229e4f0 100644 --- a/branches/riccardo/monitor2/mon/MonitorStore.cc +++ b/branches/riccardo/monitor2/mon/MonitorStore.cc @@ -43,9 +43,9 @@ void MonitorStore::mkfs() dout(1) << "mkfs" << endl; char cmd[200]; - sprintf(cmd, "/bin/rm -rf %s/*", dir.c_str()); + sprintf(cmd, "/bin/rm -r %s ; mkdir %s", dir.c_str(), dir.c_str()); dout(1) << cmd << endl; - //system(cmd); + system(cmd); } @@ -68,9 +68,9 @@ version_t MonitorStore::get_int(const char *a, const char *b) version_t val = atoi(buf); if (b) { - dout(10) << "get_int " << a << "/" << b << " = " << val << endl; + dout(15) << "get_int " << a << "/" << b << " = " << val << endl; } else { - dout(10) << "get_int " << a << " = " << val << endl; + dout(15) << "get_int " << a << " = " << val << endl; } return val; } @@ -82,18 +82,23 @@ void MonitorStore::put_int(version_t val, const char *a, const char *b) sprintf(fn, "%s/%s", dir.c_str(), a); if (b) { ::mkdir(fn, 0755); - dout(10) << "set_int " << a << "/" << b << " = " << val << endl; + dout(15) << "set_int " << a << "/" << b << " = " << val << endl; sprintf(fn, "%s/%s/%s", dir.c_str(), a, b); } else { - dout(10) << "set_int " << a << " = " << val << endl; + dout(15) << "set_int " << a << " = " << val << endl; } + char vs[30]; + sprintf(vs, "%lld\n", val); + char tfn[200]; sprintf(tfn, "%s.new", fn); - FILE *f = ::fopen(tfn, "w"); - assert(f); - ::fprintf(f, "%lld\n", val); - ::fclose(f); + + int fd = ::open(tfn, O_WRONLY|O_CREAT); + assert(fd > 0); + ::fchmod(fd, 0644); + ::write(fd, vs, strlen(vs)); + ::close(fd); ::rename(tfn, fn); } @@ -105,10 +110,10 @@ bool MonitorStore::exists_bl(const char *a, const char *b) { char fn[200]; if (b) { - dout(10) << "exists_bl " << a << "/" << b << endl; + dout(15) << "exists_bl " << a << "/" << b << endl; sprintf(fn, "%s/%s/%s", dir.c_str(), a, b); } else { - dout(10) << "exists_bl " << a << endl; + dout(15) << "exists_bl " << a << endl; sprintf(fn, "%s/%s", dir.c_str(), a); } @@ -130,9 +135,9 @@ int MonitorStore::get_bl(bufferlist& bl, const char *a, const char *b) int fd = ::open(fn, O_RDONLY); if (!fd) { if (b) { - dout(10) << "get_bl " << a << "/" << b << " DNE" << endl; + dout(15) << "get_bl " << a << "/" << b << " DNE" << endl; } else { - dout(10) << "get_bl " << a << " DNE" << endl; + dout(15) << "get_bl " << a << " DNE" << endl; } return 0; } @@ -149,9 +154,9 @@ int MonitorStore::get_bl(bufferlist& bl, const char *a, const char *b) ::close(fd); if (b) { - dout(10) << "get_bl " << a << "/" << b << " = " << bl.length() << " bytes" << endl; + dout(15) << "get_bl " << a << "/" << b << " = " << bl.length() << " bytes" << endl; } else { - dout(10) << "get_bl " << a << " = " << bl.length() << " bytes" << endl; + dout(15) << "get_bl " << a << " = " << bl.length() << " bytes" << endl; } return len; @@ -163,10 +168,10 @@ int MonitorStore::put_bl(bufferlist& bl, const char *a, const char *b) sprintf(fn, "%s/%s", dir.c_str(), a); if (b) { ::mkdir(fn, 0755); - dout(10) << "put_bl " << a << "/" << b << " = " << bl.length() << " bytes" << endl; + dout(15) << "put_bl " << a << "/" << b << " = " << bl.length() << " bytes" << endl; sprintf(fn, "%s/%s/%s", dir.c_str(), a, b); } else { - dout(10) << "put_bl " << a << " = " << bl.length() << " bytes" << endl; + dout(15) << "put_bl " << a << " = " << bl.length() << " bytes" << endl; } char tfn[200]; @@ -183,7 +188,7 @@ int MonitorStore::put_bl(bufferlist& bl, const char *a, const char *b) it != bl.buffers().end(); it++) ::write(fd, it->c_str(), it->length()); - + ::fchmod(fd, 0644); ::fsync(fd); ::close(fd); ::rename(tfn, fn); diff --git a/branches/riccardo/monitor2/msg/Dispatcher.h b/branches/riccardo/monitor2/msg/Dispatcher.h index 97e59bbb7819d..8b6fe92381427 100644 --- a/branches/riccardo/monitor2/msg/Dispatcher.h +++ b/branches/riccardo/monitor2/msg/Dispatcher.h @@ -27,7 +27,7 @@ class Dispatcher { virtual void dispatch(Message *m) = 0; // how i deal with transmission failures. - virtual void ms_handle_failure(Message *m, entity_name_t dest, const entity_addr_t& addr) { delete m; } + virtual void ms_handle_failure(Message *m, const entity_inst_t& inst) { delete m; } }; #endif diff --git a/branches/riccardo/monitor2/msg/SimpleMessenger.cc b/branches/riccardo/monitor2/msg/SimpleMessenger.cc index 99a04a8291898..f31f8378b6487 100644 --- a/branches/riccardo/monitor2/msg/SimpleMessenger.cc +++ b/branches/riccardo/monitor2/msg/SimpleMessenger.cc @@ -683,7 +683,7 @@ void Rank::Pipe::fail(list& out) k != j->second.end(); ++k) { derr(1) << "pipe(" << peer_addr << ' ' << this << ").fail on " << **k << " to " << j->first << " inst " << peer_addr << endl; - i->first->ms_handle_failure(*k, j->first, peer_addr); + i->first->ms_handle_failure(*k, (*k)->get_dest_inst()); } } diff --git a/branches/riccardo/monitor2/osd/OSD.cc b/branches/riccardo/monitor2/osd/OSD.cc index 7e3bcc5568eed..1799a4109cb75 100644 --- a/branches/riccardo/monitor2/osd/OSD.cc +++ b/branches/riccardo/monitor2/osd/OSD.cc @@ -731,6 +731,7 @@ void OSD::ms_handle_failure(Message *m, const entity_inst_t& inst) entity_name_t dest = inst.name; if (g_conf.ms_die_on_failure) { + dout(0) << "ms_handle_failure " << inst << " on " << *m << endl; exit(0); } @@ -1018,6 +1019,8 @@ void OSD::advance_map(ObjectStore::Transaction& t) //cerr << "osdmap " << osdmap->get_ctime() << " logger start " << logger->get_start() << endl; logger->set_start( osdmap->get_ctime() ); + assert(g_conf.osd_mkfs); // make sure we did a mkfs! + // create PGs for (int nrep = 1; nrep <= MIN(g_conf.num_osd, g_conf.osd_max_rep); // for low osd counts.. hackish bleh -- 2.39.5