]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: clean up mkfs vs peek_super
authorSage Weil <sage@newdream.net>
Thu, 20 Nov 2008 22:40:08 +0000 (14:40 -0800)
committerSage Weil <sage@newdream.net>
Thu, 20 Nov 2008 22:40:08 +0000 (14:40 -0800)
src/cosd.cc
src/osd/OSD.cc
src/osd/OSD.h

index 1215ff8d45932c390ccc5ed1a8c2b0476562ebbd..27aa62d55d29a9066682c7f373312ba0984b2941 100644 (file)
@@ -98,9 +98,14 @@ int main(int argc, const char **argv)
   }
 
   if (whoami < 0) {
-    whoami = OSD::peek_whoami(monmap.fsid, dev);
-    if (whoami < 0) {
-      cerr << "unable to determine OSD identity from superblock on " << dev << ": " << strerror(-whoami) << std::endl;
+    ceph_fsid fsid;
+    int r = OSD::peek_super(dev, fsid, whoami);
+    if (r < 0) {
+      cerr << "unable to determine OSD identity from superblock on " << dev << ": " << strerror(-r) << std::endl;
+      exit(1);
+    }
+    if (!ceph_fsid_equal(&fsid, &monmap.fsid)) {
+      cerr << "OSD fsid " << fsid << " != monmap fsid " << monmap.fsid << std::endl;
       exit(1);
     }
   }
index 0bb7f8d884775c986a6e307a9713c3d31af2b060..e8fe2da42fd906e9a04cfd502ac4ea079335079e 100644 (file)
@@ -211,7 +211,7 @@ int OSD::mkfs(const char *dev, ceph_fsid fsid, int whoami)
   return 0;
 }
 
-int OSD::peek_whoami(ceph_fsid& fsid, const char *dev)
+int OSD::peek_super(const char *dev, ceph_fsid& fsid, int& whoami)
 {
   ObjectStore *store = create_object_store(dev);
   int err = store->mount();
@@ -230,12 +230,9 @@ int OSD::peek_whoami(ceph_fsid& fsid, const char *dev)
   bufferlist::iterator p = bl.begin();
   ::decode(sb, p);
 
-  if (!ceph_fsid_equal(&sb.fsid, &fsid)) {
-    generic_dout(0) << "dev fsid " << sb.fsid << " != monmap fsid " << fsid << dendl;
-    return -EPERM;
-  }
-
-  return sb.whoami;
+  fsid = sb.fsid;
+  whoami = sb.whoami;
+  return 0;
 }
 
 
index 4fdc323b240091d90165383aa11a3ab706b386f1..727962ba11469ca3b8662b4a59c91caabc07a3b6 100644 (file)
@@ -557,7 +557,7 @@ private:
   static int find_osd_dev(char *result, int whoami);
   static ObjectStore *create_object_store(const char *dev);
   static int mkfs(const char *dev, ceph_fsid fsid, int whoami);
-  static int peek_whoami(ceph_fsid& fsid, const char *dev);
+  static int peek_super(const char *dev, ceph_fsid& fsid, int& whoami);
 
   // startup/shutdown
   int init();