]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: rados load-gen add blockalign option 20683/head
authorZengran Zhang <zhzr@sangfor.com>
Tue, 17 Jul 2018 03:20:21 +0000 (11:20 +0800)
committerZengran Zhang <zhangzengran@sangfor.com.cn>
Fri, 2 Nov 2018 01:21:53 +0000 (09:21 +0800)
Signed-off-by: Zengran Zhang <zhangzengran@sangfor.com.cn>
src/tools/rados/rados.cc

index cb4eae2742a6d230d0a4b4f3287522ac909e2969..2a2d437cc37c82f8df3a800f5cca2fe89a263444 100644 (file)
@@ -233,6 +233,7 @@ void usage(ostream& out)
 "   --read-percent                   percent of operations that are read\n"
 "   --target-throughput              target throughput (in bytes)\n"
 "   --run-length                     total time (in seconds)\n"
+"   --offset-align                   at what boundary to align random op offsets"
 "CACHE POOLS OPTIONS:\n"
 "   --with-clones                    include clones when doing flush or evict\n"
 "OMAP OPTIONS:\n"
@@ -566,6 +567,7 @@ public:
   size_t max_ops;
   size_t max_backlog;
   size_t target_throughput;
+  size_t offset_align = 0;
   int run_length;
 
   enum {
@@ -771,6 +773,9 @@ void LoadGen::gen_op(LoadGenOp *op)
   if (off + len > info.len)
     off = info.len - len;
 
+  if (offset_align) 
+    off = p2align(off, offset_align);
+
   op->off = off;
   op->len = len;
 
@@ -1703,6 +1708,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
   snap_t snapid = CEPH_NOSNAP;
   std::map<std::string, std::string>::const_iterator i;
 
+  uint64_t offset_align = 0;
   uint64_t min_obj_len = 0;
   uint64_t max_obj_len = 0;
   uint64_t min_op_len = 0;
@@ -1942,6 +1948,12 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
         omap_key_pretty = "(binary key)";
     }
   }
+  i = opts.find("offset_align");
+  if (i != opts.end()) {
+    if (rados_sistrtoll(i, &offset_align)) {
+      return -EINVAL;
+    }
+  }
   i = opts.find("with-reference");
   if (i != opts.end()) {
     with_reference = true;
@@ -3283,6 +3295,8 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
       lg.num_objs = num_objs;
     if (run_length)
       lg.run_length = run_length;
+    if (offset_align)
+      lg.offset_align = offset_align;
 
     cout << "run length " << run_length << " seconds" << std::endl;
     cout << "preparing " << lg.num_objs << " objects" << std::endl;
@@ -3916,6 +3930,8 @@ int main(int argc, const char **argv)
       opts["max-backlog"] = val;
     } else if (ceph_argparse_witharg(args, i, &val, "--target-throughput", (char*)NULL)) {
       opts["target-throughput"] = val;
+    } else if (ceph_argparse_witharg(args, i, &val, "--offset-align", (char*)NULL)) {
+      opts["offset_align"] = val;
     } else if (ceph_argparse_witharg(args, i, &val, "--read-percent", (char*)NULL)) {
       opts["read-percent"] = val;
     } else if (ceph_argparse_witharg(args, i, &val, "--num-objects", (char*)NULL)) {