]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: avoid bufferlist::push_front
authorSage Weil <sage@redhat.com>
Tue, 3 Apr 2018 15:06:07 +0000 (10:06 -0500)
committerSage Weil <sage@redhat.com>
Tue, 3 Apr 2018 15:07:05 +0000 (10:07 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/erasure-code/ErasureCode.cc
src/erasure-code/shec/ErasureCodeShec.cc
src/test/erasure-code/ErasureCodeExample.h
src/test/erasure-code/TestErasureCodeExample.cc
src/test/erasure-code/TestErasureCodeIsa.cc
src/test/erasure-code/TestErasureCodeJerasure.cc
src/test/erasure-code/TestErasureCodeLrc.cc

index fa5d8e29a4e5b82a14add0703fdd7b65f48a3219..45607bf2f4b2a7e5a640820d66a9bdb4f94a0236 100644 (file)
@@ -221,8 +221,11 @@ int ErasureCode::_decode(const set<int> &want_to_read,
   unsigned blocksize = (*chunks.begin()).second.length();
   for (unsigned int i =  0; i < k + m; i++) {
     if (chunks.find(i) == chunks.end()) {
+      bufferlist tmp;
       bufferptr ptr(buffer::create_aligned(blocksize, SIMD_ALIGN));
-      (*decoded)[i].push_front(ptr);
+      tmp.push_back(ptr);
+      tmp.claim_append((*decoded)[i]);
+      (*decoded)[i].swap(tmp);
     } else {
       (*decoded)[i] = chunks.find(i)->second;
       (*decoded)[i].rebuild_aligned(SIMD_ALIGN);
index ebcffadd05f92227233c6dd1d062ee61c129ae96..2c31958ce444f0d7c7a60fdcc35bf4b5d11aac4e 100644 (file)
@@ -198,8 +198,11 @@ int ErasureCodeShec::_decode(const set<int> &want_to_read,
   unsigned blocksize = (*chunks.begin()).second.length();
   for (unsigned int i =  0; i < k + m; i++) {
     if (chunks.find(i) == chunks.end()) {
+      bufferlist tmp;
       bufferptr ptr(buffer::create_aligned(blocksize, SIMD_ALIGN));
-      (*decoded)[i].push_front(ptr);
+      tmp.push_back(ptr);
+      tmp.claim_append((*decoded)[i]);
+      (*decoded)[i].swap(tmp);
     } else {
       (*decoded)[i] = chunks.find(i)->second;
       (*decoded)[i].rebuild_aligned(SIMD_ALIGN);
index cd4bac41c38b40dbe0b5ddc6ba5e12aebe1e47ea..1258465388a62517ae05acb5d020ba4467fe1aff 100644 (file)
@@ -117,8 +117,11 @@ public:
     for (set<int>::iterator j = want_to_encode.begin();
          j != want_to_encode.end();
          ++j) {
+      bufferlist tmp;
       bufferptr chunk(ptr, (*j) * chunk_length, chunk_length);
-      (*encoded)[*j].push_front(chunk);
+      tmp.push_back(chunk);
+      tmp.claim_append((*encoded)[*j]);
+      (*encoded)[*j].swap(tmp);
     }
     return 0;
   }
@@ -165,7 +168,11 @@ public:
         for (unsigned j = 0; j < chunk_length; j++) {
           c[j] = a[j] ^ b[j];
         }
-        (*decoded)[*i].push_front(chunk);
+
+       bufferlist tmp;
+       tmp.append(chunk);
+       tmp.claim_append((*decoded)[*i]);
+       (*decoded)[*i].swap(tmp);
       }
     }
     return 0;
index bdf7fbd0053b895a296b69db6b6071feb6f80385..826f3bef177e433f0c846b0284d94fa95c824c1b 100644 (file)
@@ -180,7 +180,7 @@ TEST(ErasureCodeExample, decode)
     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
   in_ptr.append(payload, strlen(payload));
   bufferlist in;
-  in.push_front(in_ptr);
+  in.push_back(in_ptr);
   int want_to_encode[] = { 0, 1, 2 };
   map<int, bufferlist> encoded;
   EXPECT_EQ(0, example.encode(set<int>(want_to_encode, want_to_encode+3),
index 4a288e3ff508aba436c242dd4a96ffa045b61f66..6d8e1681fc24965001bf59339fc133dfd95be775 100644 (file)
@@ -442,7 +442,7 @@ TEST_F(IsaErasureCodeTest, isa_vandermonde_exhaustive)
     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
   in_ptr.append(payload, strlen(payload));
   bufferlist in;
-  in.push_front(in_ptr);
+  in.push_back(in_ptr);
 
   set<int>want_to_encode;
 
@@ -569,7 +569,7 @@ TEST_F(IsaErasureCodeTest, isa_cauchy_exhaustive)
     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
   in_ptr.append(payload, strlen(payload));
   bufferlist in;
-  in.push_front(in_ptr);
+  in.push_back(in_ptr);
 
   set<int>want_to_encode;
 
@@ -696,7 +696,7 @@ TEST_F(IsaErasureCodeTest, isa_cauchy_cache_trash)
     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
   in_ptr.append(payload, strlen(payload));
   bufferlist in;
-  in.push_front(in_ptr);
+  in.push_back(in_ptr);
 
   set<int>want_to_encode;
 
@@ -822,7 +822,7 @@ TEST_F(IsaErasureCodeTest, isa_xor_codec)
     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
   in_ptr.append(payload, strlen(payload));
   bufferlist in;
-  in.push_front(in_ptr);
+  in.push_back(in_ptr);
 
   set<int>want_to_encode;
 
index 5201b02a38b6b6ff9c6f15a0b19279a47c9c4657..54930e5ed0bb1ec280905772e980532ca140d175 100644 (file)
@@ -81,7 +81,7 @@ TYPED_TEST(ErasureCodeTest, encode_decode)
       "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
     in_ptr.append(payload, strlen(payload));
     bufferlist in;
-    in.push_front(in_ptr);
+    in.push_back(in_ptr);
     int want_to_encode[] = { 0, 1, 2, 3 };
     map<int, bufferlist> encoded;
     EXPECT_EQ(0, jerasure.encode(set<int>(want_to_encode, want_to_encode+4),
index 842ffa8e053f04815c18e3f444518d8a81f26127..21926af2b93eb8e496eb6d46d0824f1fc70c6532 100644 (file)
@@ -623,7 +623,10 @@ TEST(ErasureCodeLrc, encode_decode)
   for (unsigned int i = 0; i < lrc.get_chunk_count(); ++i) {
     want_to_encode.insert(i);
     bufferptr ptr(buffer::create_page_aligned(chunk_size));
-    encoded[i].push_front(ptr);
+    bufferlist tmp;
+    tmp.push_back(ptr);
+    tmp.claim_append(encoded[i]);
+    encoded[i].swap(tmp);
   }
   const vector<int> &mapping = lrc.get_chunk_mapping();
   char c = 'A';
@@ -753,7 +756,10 @@ TEST(ErasureCodeLrc, encode_decode_2)
   for (unsigned int i = 0; i < lrc.get_chunk_count(); ++i) {
     want_to_encode.insert(i);
     bufferptr ptr(buffer::create_page_aligned(chunk_size));
-    encoded[i].push_front(ptr);
+    bufferlist tmp;
+    tmp.push_back(ptr);
+    tmp.claim_append(encoded[i]);
+    encoded[i].swap(tmp);
   }
   const vector<int> &mapping = lrc.get_chunk_mapping();
   char c = 'A';