}
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);
}
}
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();
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;
}
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();