Whamcloud - gitweb
The "random" addition to the UUID were in fact not very random: dev is time-
authorpschwan <pschwan>
Sun, 3 Nov 2002 20:51:44 +0000 (20:51 +0000)
committerpschwan <pschwan>
Sun, 3 Nov 2002 20:51:44 +0000 (20:51 +0000)
synchronized, and this caused big trouble.

I fixed this by seeding the PRNG from /dev/urandom at startup; my first
multi-line python hackery, so I hope I didn't pooch it.

lustre/utils/lconf

index 8692970..3399248 100755 (executable)
@@ -1002,7 +1002,7 @@ class MDC(Module):
 
         host = socket.gethostname()
         self.name = 'MDC_%s' % (self.mds.name)
-        self.uuid = '%s_%4.4x_UUID' % (self.name , int(random.random() * 100000 ))
+        self.uuid = '%s_%05x_UUID' % (self.name , int(random.random() * 100000))
 
         self.lookup_server(self.mds.uuid)
         self.add_module('lustre/mdc', 'mdc')
@@ -1668,6 +1668,16 @@ def main():
     global TCP_ACCEPTOR, lctl, MAXTCPBUF
     host = socket.gethostname()
 
+    # the PRNG is normally seeded with time(), which is not so good for starting
+    # time-synchronized clusters
+    input = open('/dev/urandom', 'r')
+    if not input:
+        print 'Unable to open /dev/urandom!'
+        sys.exit(1)
+    seed = input.read(32)
+    input.close()
+    random.seed(seed)
+
     sanitise_path()
 
     args = parse_cmdline(sys.argv[1:])