From 378881764a48784fe3ab704be61575c7f2aeed28 Mon Sep 17 00:00:00 2001 From: Jos Collin Date: Thu, 20 Apr 2017 17:20:24 +0530 Subject: [PATCH] mon: handle cases where store->get() may return error Handled cases where store->get() may return error. Fixed the review comments too in this commit. Fixes: http://tracker.ceph.com/issues/19601 Signed-off-by: Jos Collin --- src/mon/Monitor.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index af44df8e392f..d3a0be615e4e 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -1433,8 +1433,10 @@ void Monitor::handle_sync_get_chunk(MonOpRequestRef op) while (sp.last_committed < paxos->get_version() && left > 0) { bufferlist bl; sp.last_committed++; - store->get(paxos->get_name(), sp.last_committed, bl); - // TODO: what if store->get returns error or empty bl? + + int err = store->get(paxos->get_name(), sp.last_committed, bl); + assert(err == 0); + tx->put(paxos->get_name(), sp.last_committed, bl); left -= bl.length(); dout(20) << __func__ << " including paxos state " << sp.last_committed @@ -4844,14 +4846,16 @@ bool Monitor::_scrub(ScrubResult *r, } bufferlist bl; - //TODO: what when store->get returns error or empty bl? - store->get(k.first, k.second, bl); + int err = store->get(k.first, k.second, bl); + assert(err == 0); + uint32_t key_crc = bl.crc32c(0); dout(30) << __func__ << " " << k << " bl " << bl.length() << " bytes" << " crc " << key_crc << dendl; r->prefix_keys[k.first]++; - if (r->prefix_crc.count(k.first) == 0) + if (r->prefix_crc.count(k.first) == 0) { r->prefix_crc[k.first] = 0; + } r->prefix_crc[k.first] = bl.crc32c(r->prefix_crc[k.first]); if (cct->_conf->mon_scrub_inject_crc_mismatch > 0.0 && -- 2.47.3