From 7fcd423706f129e83ada2b30bef598bc8136b340 Mon Sep 17 00:00:00 2001 From: Vicente Cheng Date: Tue, 27 Oct 2015 17:11:30 +0800 Subject: [PATCH] osd: check OSDSuperblock in mkfs() when it already have superblock When we remove the ready flag from osd directory, it will execute mkfs again. It will read superblock but can not check osd id and cluster fsid correctly. It need to decode the superblock that we read from osd. It will always failure now, so I modify it for read osd id and fsid correctly. http://tracker.ceph.com/issues/13586 Fixes: #13586 Signed-off-by: Vicente Cheng --- src/osd/OSD.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 5ed8f67d114..aba753184eb 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1351,7 +1351,11 @@ int OSD::mkfs(CephContext *cct, ObjectStore *store, const string &dev, bufferlist sbbl; ret = store->read(coll_t::meta(), OSD_SUPERBLOCK_POBJECT, 0, 0, sbbl); if (ret >= 0) { + /* if we already have superblock, check content of superblock */ dout(0) << " have superblock" << dendl; + bufferlist::iterator p; + p = sbbl.begin(); + ::decode(sb, p); if (whoami != sb.whoami) { derr << "provided osd id " << whoami << " != superblock's " << sb.whoami << dendl; ret = -EINVAL;