]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: jerasure implementation of chunk size helpers
authorLoic Dachary <loic@dachary.org>
Wed, 18 Dec 2013 09:17:15 +0000 (10:17 +0100)
committerLoic Dachary <loic@dachary.org>
Fri, 10 Jan 2014 18:43:58 +0000 (19:43 +0100)
The encode methode uses the get_chunk_size method which is a translation
of the code it previously used for the same purpose. The chunk_count and
chunk_data_count methods return k+m and k respectively. But that will
no longer be the case after local parity is implemented.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.cc
src/osd/ErasureCodePluginJerasure/ErasureCodeJerasure.h

index 2659d9740de7b7e1b5cfc057ba79457002cef0a2..f1de0e4f8974d3b876c66f27cb6092c1a39cd28a 100644 (file)
@@ -43,6 +43,15 @@ void ErasureCodeJerasure::init(const map<std::string,std::string> &parameters)
   prepare();
 }
 
+unsigned int ErasureCodeJerasure::get_chunk_size(unsigned int object_size) const
+{
+  unsigned alignment = get_alignment();
+  unsigned tail = object_size % alignment;
+  unsigned padded_length = object_size + ( tail ?  ( alignment - tail ) : 0 );
+  assert(padded_length % k == 0);
+  return padded_length / k;
+}
+
 int ErasureCodeJerasure::minimum_to_decode(const set<int> &want_to_read,
                                            const set<int> &available_chunks,
                                            set<int> *minimum) 
@@ -77,9 +86,8 @@ int ErasureCodeJerasure::encode(const set<int> &want_to_encode,
                                 const bufferlist &in,
                                 map<int, bufferlist> *encoded)
 {
-  unsigned alignment = get_alignment();
-  unsigned tail = in.length() % alignment;
-  unsigned padded_length = in.length() + ( tail ?  ( alignment - tail ) : 0 );
+  unsigned blocksize = get_chunk_size(in.length());
+  unsigned padded_length = blocksize * k;
   dout(10) << "encode adjusted buffer length from " << in.length()
           << " to " << padded_length << dendl;
   assert(padded_length % k == 0);
@@ -90,7 +98,6 @@ int ErasureCodeJerasure::encode(const set<int> &want_to_encode,
     out.push_back(pad);
     out.rebuild_page_aligned();
   }
-  unsigned blocksize = padded_length / k;
   unsigned coding_length = blocksize * m;
   bufferptr coding(buffer::create_page_aligned(coding_length));
   out.push_back(coding);
@@ -196,7 +203,7 @@ int ErasureCodeJerasureReedSolomonVandermonde::jerasure_decode(int *erasures,
                                erasures, data, coding, blocksize);
 }
 
-unsigned ErasureCodeJerasureReedSolomonVandermonde::get_alignment()
+unsigned ErasureCodeJerasureReedSolomonVandermonde::get_alignment() const
 {
   unsigned alignment = k*w*sizeof(int);
   if ( ((w*sizeof(int))%LARGEST_VECTOR_WORDSIZE) )
@@ -240,7 +247,7 @@ int ErasureCodeJerasureReedSolomonRAID6::jerasure_decode(int *erasures,
   return jerasure_matrix_decode(k, m, w, matrix, 1, erasures, data, coding, blocksize);
 }
 
-unsigned ErasureCodeJerasureReedSolomonRAID6::get_alignment()
+unsigned ErasureCodeJerasureReedSolomonRAID6::get_alignment() const
 {
   unsigned alignment = k*w*sizeof(int);
   if ( ((w*sizeof(int))%LARGEST_VECTOR_WORDSIZE) )
@@ -285,7 +292,7 @@ int ErasureCodeJerasureCauchy::jerasure_decode(int *erasures,
                                       erasures, data, coding, blocksize, packetsize, 1);
 }
 
-unsigned ErasureCodeJerasureCauchy::get_alignment()
+unsigned ErasureCodeJerasureCauchy::get_alignment() const
 {
   unsigned alignment = k*w*packetsize*sizeof(int);
   if ( ((w*packetsize*sizeof(int))%LARGEST_VECTOR_WORDSIZE) )
@@ -355,7 +362,7 @@ int ErasureCodeJerasureLiberation::jerasure_decode(int *erasures,
                                       coding, blocksize, packetsize, 1);
 }
 
-unsigned ErasureCodeJerasureLiberation::get_alignment()
+unsigned ErasureCodeJerasureLiberation::get_alignment() const
 {
   unsigned alignment = k*w*packetsize*sizeof(int);
   if ( ((w*packetsize*sizeof(int))%LARGEST_VECTOR_WORDSIZE) )
index a5f4c9f2476e049638ff1d9fe61b5a8d73d44543..a0db6a02b1c4d9af6bd0593b2f4b148270fc8f3c 100644 (file)
@@ -32,6 +32,16 @@ public:
 
   virtual ~ErasureCodeJerasure() {}
   
+  virtual unsigned int get_chunk_count() const {
+    return k + m;
+  }
+
+  virtual unsigned int get_data_chunk_count() const {
+    return k;
+  }
+
+  virtual unsigned int get_chunk_size(unsigned int object_size) const;
+
   virtual int minimum_to_decode(const set<int> &want_to_read,
                                 const set<int> &available_chunks,
                                 set<int> *minimum);
@@ -56,7 +66,7 @@ public:
                                char **data,
                                char **coding,
                                int blocksize) = 0;
-  virtual unsigned get_alignment() = 0;
+  virtual unsigned get_alignment() const = 0;
   virtual void parse(const map<std::string,std::string> &parameters) = 0;
   virtual void prepare() = 0;
   static int to_int(const std::string &name,
@@ -88,7 +98,7 @@ public:
                                char **data,
                                char **coding,
                                int blocksize);
-  virtual unsigned get_alignment();
+  virtual unsigned get_alignment() const;
   virtual void parse(const map<std::string,std::string> &parameters);
   virtual void prepare();
 };
@@ -115,7 +125,7 @@ public:
                                char **data,
                                char **coding,
                                int blocksize);
-  virtual unsigned get_alignment();
+  virtual unsigned get_alignment() const;
   virtual void parse(const map<std::string,std::string> &parameters);
   virtual void prepare();
 };
@@ -149,7 +159,7 @@ public:
                                char **data,
                                char **coding,
                                int blocksize);
-  virtual unsigned get_alignment();
+  virtual unsigned get_alignment() const;
   virtual void parse(const map<std::string,std::string> &parameters);
   void prepare_schedule(int *matrix);
 };
@@ -196,7 +206,7 @@ public:
                                char **data,
                                char **coding,
                                int blocksize);
-  virtual unsigned get_alignment();
+  virtual unsigned get_alignment() const;
   virtual void parse(const map<std::string,std::string> &parameters);
   virtual void prepare();
 };