summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@hq.newdream.net>2009-02-12 15:05:12 -0800
committerYehuda Sadeh <yehuda@hq.newdream.net>2009-02-12 15:05:12 -0800
commitaf812a06214976297e8d2b716d90342116ab1eee (patch)
treead4a3bc9bf0dacead0d91ef105aa518860cc69ea
parent5dc7beaf16c2f495d3ec08c4982538122221ca0f (diff)
downloadceph-af812a06214976297e8d2b716d90342116ab1eee.tar.gz
cosd: change some assert to assert_warn and clean exit
-rw-r--r--src/cosd.cc5
-rw-r--r--src/include/assert.h5
-rw-r--r--src/osd/OSD.cc11
3 files changed, 17 insertions, 4 deletions
diff --git a/src/cosd.cc b/src/cosd.cc
index 0c6cded6b22..e58b2921434 100644
--- a/src/cosd.cc
+++ b/src/cosd.cc
@@ -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();
diff --git a/src/include/assert.h b/src/include/assert.h
index b13ef657e07..d1ba746b964 100644
--- a/src/include/assert.h
+++ b/src/include/assert.h
@@ -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
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc
index 638d3bdc404..1221247808e 100644
--- a/src/osd/OSD.cc
+++ b/src/osd/OSD.cc
@@ -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];