]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
TestRados: send aligned appends on erasure pools
authorSamuel Just <sam.just@inktank.com>
Sat, 1 Feb 2014 19:31:25 +0000 (11:31 -0800)
committerSamuel Just <sam.just@inktank.com>
Mon, 17 Feb 2014 22:24:55 +0000 (14:24 -0800)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/test/osd/Object.cc
src/test/osd/Object.h
src/test/osd/RadosModel.h

index 279ae237d6145624907199d071b70c3ca102f116..c98d62d2934e182dd37d1fc4bc05d8bd0611ca01 100644 (file)
@@ -44,13 +44,15 @@ void AppendGenerator::get_ranges_map(
   uint64_t pos = off;
   uint64_t limit = off + get_append_size(cont);
   while (pos < limit) {
-    uint64_t segment_length = (
-      rand() % (max_append_size - min_append_size)) + min_append_size;
-    assert(segment_length < max_append_size);
+    uint64_t segment_length = round_up(
+      rand() % (max_append_size - min_append_size),
+      alignment) + min_append_size;
     assert(segment_length >= min_append_size);
     if (segment_length + pos > limit) {
       segment_length = limit - pos;
     }
+    if (alignment)
+      assert(segment_length % alignment == 0);
     out.insert(make_pair(pos, segment_length));
     pos += segment_length;
   }
index 1f4defdcb67bdd52dd72372ff667b64984edb04e..d39d36c6fd83d6cf4719ccd917cdb6559311c51d 100644 (file)
@@ -238,21 +238,34 @@ public:
 
 class AppendGenerator : public RandGenerator {
   uint64_t off;
+  uint64_t alignment;
   uint64_t min_append_size;
   uint64_t max_append_size;
   uint64_t max_append_total;
+
+  uint64_t round_up(uint64_t in, uint64_t by) {
+    if (by)
+      in += (by - (in % by));
+    return in;
+  }
+
 public:
   AppendGenerator(
     uint64_t off,
+    uint64_t alignment,
     uint64_t min_append_size,
-    uint64_t max_append_size,
-    uint64_t max_append_total) :
-    off(off), min_append_size(min_append_size),
-    max_append_size(max_append_size),
-    max_append_total(max_append_total) {}
+    uint64_t _max_append_size,
+    uint64_t max_append_multiple) :
+    off(off), alignment(alignment),
+    min_append_size(round_up(min_append_size, alignment)),
+    max_append_size(round_up(_max_append_size, alignment)) {
+    if (_max_append_size == min_append_size)
+      max_append_size += alignment;
+    max_append_total = max_append_multiple * max_append_size;
+  }
   uint64_t get_append_size(const ContDesc &in) {
     RandWrap rand(in.seqnum);
-    return rand() % max_append_total;
+    return round_up(rand() % max_append_total, alignment);
   }
   uint64_t get_length(const ContDesc &in) {
     return off + get_append_size(in);
index 4a5b861a856e8fa681e7f4da676c8e44e840f434..1193f4aecccf83aee211349dad8d54fb2dc14ba3 100644 (file)
@@ -708,9 +708,11 @@ public:
        0;
       cont_gen = new AppendGenerator(
        prev_length,
+       (context->io_ctx.pool_requires_alignment() ?
+        context->io_ctx.pool_required_alignment() : 0),
        context->min_stride_size,
        context->max_stride_size,
-       3 * context->max_stride_size);
+       3);
     } else {
       cont_gen = new VarLenGenerator(
        context->max_size, context->min_stride_size, context->max_stride_size);