~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/crush/CrushCompiler.cc

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-07-16 09:56:24 UTC
  • mfrom: (0.3.11)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120716095624-azr2w4hbhei1rxmx
Tags: upstream-0.48
ImportĀ upstreamĀ versionĀ 0.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
179
179
 
180
180
int CrushCompiler::decompile(ostream &out)
181
181
{
182
 
  out << "# begin crush map\n\n";
183
 
 
184
 
  out << "# devices\n";
 
182
  out << "# begin crush map\n";
 
183
 
 
184
  // only dump tunables if they differ from the defaults
 
185
  if (crush.get_choose_local_tries() != 2)
 
186
    out << "tunable choose_local_tries " << crush.get_choose_local_tries() << "\n";
 
187
  if (crush.get_choose_local_fallback_tries() != 5)
 
188
    out << "tunable choose_local_fallback_tries " << crush.get_choose_local_fallback_tries() << "\n";
 
189
  if (crush.get_choose_total_tries() != 19)
 
190
    out << "tunable choose_total_tries " << crush.get_choose_total_tries() << "\n";
 
191
 
 
192
  out << "\n# devices\n";
185
193
  for (int i=0; i<crush.get_max_devices(); i++) {
186
194
    out << "device " << i << " ";
187
195
    print_item_name(out, i, crush);
322
330
  return 0;
323
331
}
324
332
 
 
333
int CrushCompiler::parse_tunable(iter_t const& i)
 
334
{
 
335
  string name = string_node(i->children[1]);
 
336
  int val = int_node(i->children[2]);
 
337
 
 
338
  if (name == "choose_local_tries")
 
339
    crush.set_choose_local_tries(val);
 
340
  else if (name == "choose_local_fallback_tries")
 
341
    crush.set_choose_local_fallback_tries(val);
 
342
  else if (name == "choose_total_tries")
 
343
    crush.set_choose_total_tries(val);
 
344
  else {
 
345
    err << "tunable " << name << " not recognized" << std::endl;
 
346
    return -1;
 
347
  }
 
348
 
 
349
  if (!unsafe_tunables) {
 
350
    err << "tunables are NOT FULLY IMPLEMENTED; enable with --enable-unsafe-tunables to enable this feature" << std::endl;
 
351
    return -1;
 
352
  }
 
353
 
 
354
  if (verbose) err << "tunable " << name << " " << val << std::endl;
 
355
  return 0;
 
356
}
 
357
 
325
358
int CrushCompiler::parse_bucket_type(iter_t const& i)
326
359
{
327
360
  int id = int_node(i->children[1]);
595
628
  int r = 0;
596
629
  for (iter_t p = i->children.begin(); p != i->children.end(); p++) {
597
630
    switch (p->value.id().to_long()) {
 
631
    case crush_grammar::_tunable:
 
632
      r = parse_tunable(p);
 
633
      break;
598
634
    case crush_grammar::_device: 
599
635
      r = parse_device(p);
600
636
      break;