]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix potential access violation during shard-key scan 11210/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 23 Sep 2016 07:55:24 +0000 (15:55 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 23 Sep 2016 09:08:03 +0000 (17:08 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index 966d429c31b2cb0a9c65d99a47b48706ee8b57c0..069f8a0ce100f3bc3b651915d2d1cf2dc08c957c 100644 (file)
@@ -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 "