]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
auto-detect ip for all non-monitor components from initial exchange with monitor
authorSage Weil <sage@newdream.net>
Sun, 11 May 2008 23:54:53 +0000 (16:54 -0700)
committerSage Weil <sage@newdream.net>
Sun, 11 May 2008 23:54:53 +0000 (16:54 -0700)
src/TODO
src/mon/MDSMonitor.cc
src/mon/Monitor.cc
src/mon/OSDMonitor.cc
src/msg/SimpleMessenger.cc
src/msg/SimpleMessenger.h
src/start.sh
src/vstart.sh

index a9d665543a87770b3d95282c533d0d49256a90e7..6f14518c99324b5aa7af9d8f8878c92dfcadbe4e 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -9,7 +9,6 @@ big items
 - cas
 
 - meta vs data crush rules
-- ip-less startup for userspace items
 - use libuuid
 
 userspace client
@@ -26,7 +25,6 @@ userspace client
 
 kernel client
 - direct mds requests intelligently
-- readdir on large directories
 - flush caps on sync, fsync, etc.
   - do we need to block?
 - timeout mds session close on umount
index fb189fac25f93ff218b3c78b4bcb3f2417425ca4..e67c5eb97b9db0b7da65c2eddb8c6d54e0688f8a 100644 (file)
@@ -218,6 +218,12 @@ bool MDSMonitor::preprocess_beacon(MMDSBeacon *m)
     goto out;
   }
 
+  // first time we've seen it?
+  if (m->get_mds_inst().addr.ipaddr.sin_addr.s_addr == htonl(INADDR_ANY)) {
+    m->get_mds_inst() = m->get_source_inst();
+    m->clear_payload();
+  }
+
   dout(12) << "preprocess_beacon " << *m
           << " from " << m->get_mds_inst()
           << dendl;
index 1a36ddef671725965c4ec57cbba111832f9bfacb..3a15a5311afdd61e7a51dfc559ad190d1931651b 100644 (file)
@@ -199,6 +199,12 @@ void Monitor::handle_command(MMonCommand *m)
     return;
   }
 
+  // first time we've seen it?
+  if (m->inst.addr.ipaddr.sin_addr.s_addr == htonl(INADDR_ANY)) {
+    m->inst = m->get_source_inst();
+    m->clear_payload();
+  }
+
   dout(0) << "handle_command " << *m << dendl;
   string rs;
   if (!m->cmd.empty()) {
index f96a5785893a7ec710bb04fcd0d14af1fb11dc0b..df552ef08227e2fecc196497f09a6e3c8002994f 100644 (file)
@@ -467,6 +467,12 @@ bool OSDMonitor::preprocess_boot(MOSDBoot *m)
     return true;
   }
 
+  // first time we've seen it?
+  if (m->inst.addr.ipaddr.sin_addr.s_addr == htonl(INADDR_ANY)) {
+    m->inst = m->get_source_inst();
+    m->clear_payload();
+  }
+
   assert(m->inst.name.is_osd());
   int from = m->inst.name.num();
   
index 65b5cf080ae4d6d9c7d62f9add11f4fb3be4a0c0..72ea9c2562eb06611b71e577881a91e0dd45d2bc 100644 (file)
@@ -92,36 +92,6 @@ int Rank::Accepter::bind(int64_t force_nonce)
   // bind to a socket
   dout(10) << "accepter.bind" << dendl;
   
-  char hostname[100];
-  memset(hostname, 0, 100);
-  gethostname(hostname, 100);
-  dout(2) << "accepter.bind my hostname is " << hostname << dendl;
-
-  // is there a .ceph_hosts file?
-  if (g_conf.ms_hosts) {
-    ifstream fh;
-    fh.open(g_conf.ms_hosts);
-    if (fh.is_open()) {
-      while (1) {
-       string line;
-       getline(fh, line);
-       if (fh.eof()) break;
-       if (line[0] == '#' || line[0] == ';') continue;
-       int ospace = line.find(" ");
-       if (!ospace) continue;
-       string host = line.substr(0, ospace);
-       string addr = line.substr(ospace+1);
-       dout(15) << g_conf.ms_hosts << ": host '" << host << "' -> '" << addr << "'" << dendl;
-       if (host == hostname) {
-         parse_ip_port(addr.c_str(), g_my_addr);
-         dout(1) << g_conf.ms_hosts << ": my addr is " << g_my_addr << dendl;
-         break;
-       }
-      }
-      fh.close();
-    }
-  }
-
   // use whatever user specified (if anything)
   sockaddr_in listen_addr = g_my_addr.ipaddr;
 
@@ -158,28 +128,9 @@ int Rank::Accepter::bind(int64_t force_nonce)
     return -errno;
   }
   
-  // figure out my_addr
-  if (g_my_addr != entity_addr_t()) {
-    // user specified it, easy peasy.
-    rank.rank_addr = g_my_addr;
-  } else {
-    // my IP is... HELP!
-    struct hostent *myhostname = gethostbyname(hostname); 
-    if (!myhostname) {
-      derr(0) << "accepter.bind unable to resolve hostname '" << hostname 
-             << "', please specify your ip with --bind x.x.x.x" 
-             << dendl;
-      return -1;
-    }
-    
-    // look up my hostname.
-    listen_addr.sin_family = myhostname->h_addrtype;
-    memcpy((char*)&listen_addr.sin_addr.s_addr, 
-          myhostname->h_addr_list[0], 
-          myhostname->h_length);
-    rank.rank_addr.ipaddr = listen_addr;
-    rank.rank_addr.set_port(0);
-  }
+  rank.rank_addr = g_my_addr;
+  if (rank.rank_addr != entity_addr_t())
+    rank.need_addr = false;
   if (rank.rank_addr.get_port() == 0) {
     entity_addr_t tmp;
     tmp.ipaddr = listen_addr;
@@ -1405,6 +1356,14 @@ void Rank::Pipe::reader()
        if (erank < rank.max_local && rank.local[erank]) {
          // find entity
          entity = rank.local[erank];
+
+         // first message?
+         if (rank.need_addr) {
+           entity->_myinst.addr = rank.rank_addr = m->get_dest_inst().addr;
+           dout(0) << "reader my rank addr is " << rank.rank_addr << dendl;
+           rank.need_addr = false;
+         }
+
        } else {
          derr(0) << "reader got message " << *m << " for " << m->get_dest() << ", which isn't local" << dendl;
        }
index f3afb8da11f4bed295ed9ef49e15b805b0f757d2..a5b9e5f30622f7aa5e043f516ff7c78dcaf933a1 100644 (file)
@@ -320,6 +320,7 @@ private:
   bool started;
 
   // where i listen
+  bool need_addr;
   entity_addr_t rank_addr;
   
   // local
@@ -344,7 +345,7 @@ private:
   void reaper();
 
 public:
-  Rank() : started(false),
+  Rank() : started(false), need_addr(true),
           max_local(0), num_local(0) { }
   ~Rank() { }
 
index 1709d8456dfd421cc8c75f863f955cf0c36939d2..fbffd92babf007ce905e906bdbcb6a47332fa002 100755 (executable)
@@ -27,7 +27,7 @@ $CEPH_BIN/monmaptool --create --clobber --add $IP:12345 --print .ceph_monmap
 $CEPH_BIN/mkmonfs --clobber mondata/mon0 --mon 0 --monmap .ceph_monmap
 
 # shared args
-ARGS="-d --bind $IP"
+ARGS="-d"
 
 # start monitor
 $CEPH_BIN/cmon $ARGS mondata/mon0 --debug_mon 10 --debug_ms 1
@@ -44,7 +44,7 @@ do
 done
 
 # mds
-$CEPH_BIN/cmds $ARGS # --debug_ms 1 #--debug_mds 20 --debug_ms 20
+$CEPH_BIN/cmds $ARGS  # --debug_ms 1 #--debug_mds 20 --debug_ms 20
 
 echo "started.  stop.sh to stop.  see out/* (e.g. 'tail -f out/????') for debug output."
 
index 865fc9c26d554f04fb98dc3091f3a21912a5f3fc..0abc0595d10ae4c8a05e9809968a16cf6772437a 100755 (executable)
@@ -8,7 +8,7 @@ rm out/*
 
 # figure machine's ip
 HOSTNAME=`hostname`
-IP=`host $HOSTNAME | cut -d ' ' -f 4`
+IP=`host $HOSTNAME | grep $HOSTNAME | cut -d ' ' -f 4`
 [ "$CEPH_BIN" == "" ] && CEPH_BIN=.
 
 echo hostname $HOSTNAME
@@ -27,7 +27,7 @@ $CEPH_BIN/monmaptool --create --clobber --add $IP:12345 --print .ceph_monmap
 $CEPH_BIN/mkmonfs --clobber mondata/mon0 --mon 0 --monmap .ceph_monmap
 
 # shared args
-ARGS="-d --bind $IP"
+ARGS="-d"
 
 # start monitor
 $CEPH_BIN/cmon $ARGS mondata/mon0 --debug_mon 10 --debug_ms 1
@@ -43,7 +43,7 @@ do
 done
 
 # mds
-$CEPH_BIN/cmds $ARGS --debug_ms 1 --debug_mds 20 #--debug_ms 20
+$CEPH_BIN/cmds $ARGS --debug_ms 1 --debug_mds 20 --mds_thrash_fragments 1 #--debug_ms 20
 
 echo "started.  stop.sh to stop.  see out/* (e.g. 'tail -f out/????') for debug output."