From f761113abefc55c6d70c3804d895df4a62069cc3 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Tue, 26 Jan 2016 17:03:49 +0800 Subject: [PATCH] BlueStore: add a guard for overlay loading Signed-off-by: xie xingguo --- src/os/bluestore/BlueStore.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 09536de979427..7efe431acf9eb 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -2510,7 +2510,13 @@ int BlueStore::_do_read( bufferlist v; string key; get_overlay_key(o->onode.nid, op->second.key, &key); - db->get(PREFIX_OVERLAY, key, &v); + r = db->get(PREFIX_OVERLAY, key, &v); + if (r < 0) { + derr << " failed to fetch overlay(nid = " << o->onode.nid + << ", key = " << key + << "): " << cpp_strerror(r) << dendl; + goto out; + } bufferlist frag; frag.substr_of(v, x_off, x_len); bl.claim_append(frag); @@ -4653,7 +4659,8 @@ void BlueStore::_do_read_all_overlays(bluestore_wal_op_t& wo) string key; get_overlay_key(wo.nid, q->key, &key); bufferlist bl, bl_data; - db->get(PREFIX_OVERLAY, key, &bl); + int r = db->get(PREFIX_OVERLAY, key, &bl); + assert(r >= 0); bl_data.substr_of(bl, q->value_offset, q->length); wo.data.claim_append(bl_data); } -- 2.39.5