}
if (whoami < 0) {
- whoami = OSD::peek_whoami(dev);
+ whoami = OSD::peek_whoami(monmap.fsid, dev);
if (whoami < 0) {
cerr << "unable to determine OSD identity from superblock on " << dev << ": " << strerror(-whoami) << std::endl;
exit(1);
cout << "starting osd" << whoami
<< " at " << rank.get_rank_addr()
<< " dev " << dev
+ << " fsid " << monmap.fsid
<< std::endl;
g_timer.shutdown();
return 0;
}
-int OSD::peek_whoami(const char *dev)
+int OSD::peek_whoami(ceph_fsid& fsid, const char *dev)
{
ObjectStore *store = create_object_store(dev);
int err = store->mount();
err = store->read(0, OSD_SUPERBLOCK_POBJECT, 0, sizeof(sb), bl);
if (err < 0)
return -ENOENT;
- bl.copy(0, sizeof(sb), (char*)&sb);
- store->umount();
delete store;
+ bufferlist::iterator p = bl.begin();
+ ::decode(sb, p);
+ store->umount();
+
+ if (!ceph_fsid_equal(&sb.fsid, &fsid)) {
+ generic_dout(0) << "dev fsid " << sb.fsid << " != monmap fsid " << fsid << dendl;
+ return -EPERM;
+ }
+
return sb.whoami;
}
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(const char *dev);
+ static int peek_whoami(ceph_fsid& fsid, const char *dev);
// startup/shutdown
int init();