From: Sage Weil Date: Fri, 12 Jul 2013 00:46:48 +0000 (-0700) Subject: mon: clean up check_fsid() a bit X-Git-Tag: v0.67-rc1~59^2~20^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cf9d1e1a100abea9c8b00da50fea198843bd87e6;p=ceph.git mon: clean up check_fsid() a bit Use the uuid_d type instead of kludging string comparisons. Signed-off-by: Sage Weil --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index e1dd354a430..e11fb810382 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -3474,14 +3474,10 @@ void Monitor::tick() int Monitor::check_fsid() { - ostringstream ss; - ss << monmap->get_fsid(); - string us = ss.str(); - bufferlist ebl; - if (!store->exists(MONITOR_NAME, "cluster_uuid")) return -ENOENT; + bufferlist ebl; int r = store->get(MONITOR_NAME, "cluster_uuid", ebl); assert(r == 0); @@ -3493,10 +3489,15 @@ int Monitor::check_fsid() es.resize(pos); dout(10) << "check_fsid cluster_uuid contains '" << es << "'" << dendl; - if (es.length() < us.length() || - strncmp(us.c_str(), es.c_str(), us.length()) != 0) { - derr << "error: cluster_uuid file exists with value '" << es - << "', != our uuid " << monmap->get_fsid() << dendl; + uuid_d ondisk; + if (!ondisk.parse(es.c_str())) { + derr << "error: unable to parse uuid" << dendl; + return -EINVAL; + } + + if (monmap->get_fsid() != ondisk) { + derr << "error: cluster_uuid file exists with value " << ondisk + << ", != our uuid " << monmap->get_fsid() << dendl; return -EEXIST; }