From: xie xingguo Date: Fri, 23 Sep 2016 07:55:24 +0000 (+0800) Subject: os/bluestore: fix potential access violation during shard-key scan X-Git-Tag: v11.0.1~108^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dcfbc72fcbb48f4ced0c1a2d46a77f43bff38c9f;p=ceph.git os/bluestore: fix potential access violation during shard-key scan Signed-off-by: xie xingguo --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 966d429c31b2..069f8a0ce100 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -3936,13 +3936,18 @@ int BlueStore::fsck() expecting_shards.pop_front(); continue; } - while (expecting_shards.empty() || - expecting_shards.front() > it->key()) { - uint32_t offset; - string okey; - get_key_extent_shard(it->key(), &okey, &offset); - derr << __func__ << " stray shard 0x" << std::hex << offset << std::dec - << dendl; + + uint32_t offset; + string okey; + get_key_extent_shard(it->key(), &okey, &offset); + derr << __func__ << " stray shard 0x" << std::hex << offset << std::dec + << dendl; + if (expecting_shards.empty()) { + derr << __func__ << pretty_binary_string(it->key()) + << " is unexpected" << dendl; + continue; + } + while (expecting_shards.front() > it->key()) { derr << __func__ << " saw " << pretty_binary_string(it->key()) << dendl; derr << __func__ << " exp "