From dcfbc72fcbb48f4ced0c1a2d46a77f43bff38c9f Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Fri, 23 Sep 2016 15:55:24 +0800 Subject: [PATCH] os/bluestore: fix potential access violation during shard-key scan Signed-off-by: xie xingguo --- src/os/bluestore/BlueStore.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 966d429c31b2c..069f8a0ce100f 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 " -- 2.39.5