]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ErasureCodeJerasure: fill in decoded if all shards are included
authorSamuel Just <sam.just@inktank.com>
Tue, 4 Feb 2014 01:09:28 +0000 (17:09 -0800)
committerSamuel Just <sam.just@inktank.com>
Mon, 17 Feb 2014 22:24:56 +0000 (14:24 -0800)
This causes it to match minimum_to_decode.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/erasure-code/jerasure/ErasureCodeJerasure.cc
src/test/erasure-code/TestErasureCodeJerasure.cc

index 9200da25ea7c0500df23cb8b2390ef62b49cae3a..26f978dad58b91c6ff841487df7b441b3d72fbc7 100644 (file)
@@ -136,6 +136,22 @@ int ErasureCodeJerasure::decode(const set<int> &want_to_read,
                                 const map<int, bufferlist> &chunks,
                                 map<int, bufferlist> *decoded)
 {
+  vector<int> have;
+  have.reserve(chunks.size());
+  for (map<int, bufferlist>::const_iterator i = chunks.begin();
+       i != chunks.end();
+       ++i) {
+    have.push_back(i->first);
+  }
+  if (includes(
+       have.begin(), have.end(), want_to_read.begin(), want_to_read.end())) {
+    for (set<int>::iterator i = want_to_read.begin();
+        i != want_to_read.end();
+        ++i) {
+      (*decoded)[*i] = chunks.find(*i)->second;
+    }
+    return 0;
+  }
   unsigned blocksize = (*chunks.begin()).second.length();
   int erasures[k + m + 1];
   int erasures_count = 0;
index a3d603bea5409ec3db89a6fc895957891fd057a9..87f59667baaaa64d084cf17f88981f6812ed982f 100644 (file)
@@ -82,8 +82,7 @@ TYPED_TEST(ErasureCodeTest, encode_decode)
     EXPECT_EQ(0, jerasure.decode(set<int>(want_to_decode, want_to_decode+2),
                                 encoded,
                                 &decoded));
-    // always decode all, regardless of want_to_decode
-    EXPECT_EQ(4u, decoded.size()); 
+    EXPECT_EQ(2u, decoded.size()); 
     EXPECT_EQ(length, decoded[0].length());
     EXPECT_EQ(0, strncmp(decoded[0].c_str(), in.c_str(), length));
     EXPECT_EQ(0, strncmp(decoded[1].c_str(), in.c_str() + length,