]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: bluestore_debug_prefill = <fill ratio>
authorSage Weil <sage@redhat.com>
Fri, 8 Jan 2016 20:22:25 +0000 (15:22 -0500)
committerSage Weil <sage@redhat.com>
Fri, 8 Jan 2016 20:22:25 +0000 (15:22 -0500)
Prefill the objectstore by fragmenting the freespace.  Max free allocations
are bluestore_debug_prefragment_max bytes (default 1M).  Prefill defaults
to 0, of course.  One would normally just set this to .8 to get something
resembling an aged disk.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config_opts.h
src/os/bluestore/BlueStore.cc

index 9587d5542c7bec358b715d0015b0b105a82e73cf..f7ac5a60dc2c0564f03f793e04e92e79be66f90d 100644 (file)
@@ -891,6 +891,8 @@ OPTION(bluestore_debug_misc, OPT_BOOL, false)
 OPTION(bluestore_debug_no_reuse_blocks, OPT_BOOL, false)
 OPTION(bluestore_debug_small_allocations, OPT_INT, 0)
 OPTION(bluestore_debug_freelist, OPT_BOOL, false)
+OPTION(bluestore_debug_prefill, OPT_FLOAT, 0)
+OPTION(bluestore_debug_prefragment_max, OPT_INT, 1048576)
 
 OPTION(kstore_max_ops, OPT_U64, 512)
 OPTION(kstore_max_bytes, OPT_U64, 64*1024*1024)
index a99fda36eeb77a65878d3cd276902d22b7e1f621..38fb369e5ce3d58feea8021cf7347e63bf19284c 100644 (file)
@@ -1602,7 +1602,29 @@ int BlueStore::mkfs()
     } else {
       reserved = BLUEFS_START;
     }
-    fm->release(reserved, bdev->get_size() - reserved, t);
+    uint64_t end = bdev->get_size() - reserved;
+    if (g_conf->bluestore_debug_prefill > 0) {
+      dout(1) << __func__ << " pre-fragmenting freespace, using "
+             << g_conf->bluestore_debug_prefill << " with max free extent "
+             << g_conf->bluestore_debug_prefragment_max << dendl;
+      uint64_t min_alloc_size = g_conf->bluestore_min_alloc_size;
+      uint64_t start = ROUND_UP_TO(reserved, min_alloc_size);
+      uint64_t max_b = g_conf->bluestore_debug_prefragment_max / min_alloc_size;
+      float r = g_conf->bluestore_debug_prefill;
+      while (start < end) {
+       uint64_t l = (rand() % max_b + 1) * min_alloc_size;
+       if (start + l > end)
+         l = end - start;
+       l = ROUND_UP_TO(l, min_alloc_size);
+       fm->release(start, l, t);
+       uint64_t u = 1 + (uint64_t)(r * (double)l / (1.0 - r));
+       u = ROUND_UP_TO(u, min_alloc_size);
+       dout(20) << "  free " << start << "~" << l << " use " << u << dendl;
+       start += l + u;
+      }
+    } else {
+      fm->release(reserved, end, t);
+    }
     db->submit_transaction_sync(t);
   }