From 9bbeec4745fa6f04835587654492fc371fcfdbeb Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Mon, 21 Jun 2010 09:45:43 -0700 Subject: [PATCH] osd: Warn and shutdown on a mismatched fsid, instead of failing an assert --- src/osd/OSD.cc | 8 +++++++- src/osd/OSDMap.h | 9 ++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 881db35f47693..10ad4b4c128cf 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2172,7 +2172,13 @@ void OSD::handle_osd_map(MOSDMap *m) bufferlist::iterator p = bl.begin(); inc.decode(p); - osdmap->apply_incremental(inc); + if (osdmap->apply_incremental(inc)) { + //error out! + dout(0) << "ERROR: Got non-matching FSID from trusted source!" << dendl; + session->put(); + m->put(); + shutdown(); + } // archive the full map bl.clear(); diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 1ca3f6883b962..e780925cedbf8 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -475,11 +475,13 @@ private: } - void apply_incremental(Incremental &inc) { + int apply_incremental(Incremental &inc) { if (inc.epoch == 1) fsid = inc.fsid; else - assert(ceph_fsid_compare(&inc.fsid, &fsid) == 0); + if (ceph_fsid_compare(&inc.fsid, &fsid) == 0) { + return -EINVAL; + } assert(inc.epoch == epoch+1); epoch++; modified = inc.modified; @@ -487,7 +489,7 @@ private: // full map? if (inc.fullmap.length()) { decode(inc.fullmap); - return; + return 0; } // nope, incremental. @@ -586,6 +588,7 @@ private: bufferlist::iterator blp = inc.crush.begin(); crush.decode(blp); } + return 0; } // serialize, unserialize -- 2.39.5