]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: isa uses per chunk alignment constraints
authorLoic Dachary <loic-201408@dachary.org>
Mon, 22 Sep 2014 12:02:08 +0000 (14:02 +0200)
committerLoic Dachary <loic-201408@dachary.org>
Thu, 25 Sep 2014 15:39:10 +0000 (17:39 +0200)
Copy code from the jerasure plugin to enforce alignment constraints per
chunk instead of using the total object size. It is simpler and reduces
the size of the chunks. See
https://github.com/ceph/ceph/commit/c7daaaf5e63d0bd1d444385e62611fe276f6ce29
for more information.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
src/erasure-code/isa/ErasureCodeIsa.cc

index 427c293125784e819f125c0b56188adc791afcad..bfa72c568cee61f191d7965125257e76928ad63d 100644 (file)
@@ -84,10 +84,16 @@ unsigned int
 ErasureCodeIsa::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;
+  unsigned chunk_size = ( object_size + k - 1 ) / k;
+  dout(20) << "get_chunk_size: chunk_size " << chunk_size
+           << " must be modulo " << alignment << dendl;
+  unsigned modulo = chunk_size % alignment;
+  if (modulo) {
+    dout(10) << "get_chunk_size: " << chunk_size
+             << " padded to " << chunk_size + alignment - modulo << dendl;
+    chunk_size += alignment - modulo;
+  }
+  return chunk_size;
 }
 
 // -----------------------------------------------------------------------------
@@ -326,7 +332,7 @@ ErasureCodeIsaDefault::isa_decode(int *erasures,
 unsigned
 ErasureCodeIsaDefault::get_alignment() const
 {
-  return k * EC_ISA_ADDRESS_ALIGNMENT;
+  return EC_ISA_ADDRESS_ALIGNMENT;
 }
 
 // -----------------------------------------------------------------------------