Skip to content

Commit

Permalink
mon/MDSMonitor: avoid crash when decoding old FSMap epochs
Browse files Browse the repository at this point in the history
Fixes: https://tracker.ceph.com/issues/52820
Signed-off-by: Patrick Donnelly <[email protected]>
  • Loading branch information
batrick committed Oct 12, 2021
1 parent 79a5ded commit 631360a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/mds/FSMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ void FSMap::encode(bufferlist& bl, uint64_t features) const

void FSMap::decode(bufferlist::const_iterator& p)
{
struct_version = 0;
DECODE_START(STRUCT_VERSION, p);
DECODE_OLDEST(7);
struct_version = struct_v;
Expand Down
7 changes: 6 additions & 1 deletion src/mon/MDSMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2335,7 +2335,12 @@ void MDSMonitor::tick()
derr << "could not get version " << v << dendl;
ceph_abort();
}
fsmap.decode(bl);
try {
fsmap.decode(bl);
} catch (const ceph::buffer::malformed_input& e) {
dout(5) << "flushing old fsmap struct because unable to decode FSMap: " << e.what() << dendl;
}
/* N.B. FSMap::is_struct_old is also true for undecoded (failed to decode) FSMap */
if (fsmap.is_struct_old()) {
dout(5) << "fsmap struct is too old; proposing to flush out old versions" << dendl;
do_propose = true;
Expand Down

0 comments on commit 631360a

Please sign in to comment.