]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cosd: change some assert to assert_warn and clean exit
authorYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 12 Feb 2009 23:05:12 +0000 (15:05 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 12 Feb 2009 23:05:12 +0000 (15:05 -0800)
src/cosd.cc
src/include/assert.h
src/osd/OSD.cc

index 0c6cded6b2206e6af2095972005e05f3709cef5d..e58b29214346dfa0ea52101ba41ab3e2414e79d2 100644 (file)
@@ -148,7 +148,10 @@ int main(int argc, const char **argv)
 
   // start osd
   OSD *osd = new OSD(whoami, m, hbm, &monmap, dev);
-  osd->init();
+  if (osd->init() < 0) {
+    cout << "error initializing osd" << std::endl;
+    return 1;
+  }
 
   rank.wait();
 
index b13ef657e075a0c73ee773d31acd13eef0d0e7af..d1ba746b9644adbed8a88d2df67e1fb8d2260fac 100644 (file)
@@ -46,6 +46,11 @@ extern void __ceph_assert_warn(const char *assertion, const char *file, int line
        ? __CEPH_ASSERT_VOID_CAST (0)                                   \
        : __ceph_assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION)); \
   } while (0)
+
+#define assert_warn(expr)                                                      \
+  ((expr)                                                              \
+   ? __CEPH_ASSERT_VOID_CAST (0)                                       \
+   : __ceph_assert_warn (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))
 #endif
 
 #endif
index 638d3bdc40472dba72ea83919c2dabbf4ced46ab..1221247808e4d70fe19215afc7ec0a92cf5c9c6c 100644 (file)
@@ -356,7 +356,8 @@ int OSD::init()
   // mount.
   dout(2) << "mounting " << dev_path << dendl;
   store = create_object_store(dev_path);
-  assert(store);
+  if (!store)
+    return -ENODEV;
   int r = store->mount();
   if (r < 0) return -1;
   
@@ -370,7 +371,9 @@ int OSD::init()
   }
   
   // load up "current" osdmap
-  assert(!osdmap);
+  assert_warn(!osdmap);
+  if (osdmap)
+    return -1;
   osdmap = new OSDMap;
   if (superblock.current_epoch) {
     bufferlist bl;
@@ -382,7 +385,9 @@ int OSD::init()
   load_pgs();
   
   dout(2) << "superblock: i am osd" << superblock.whoami << dendl;
-  assert(whoami == superblock.whoami);
+  assert_warn(whoami == superblock.whoami);
+  if (whoami != superblock.whoami)
+    return -EINVAL;
     
   // log
   char name[80];