summaryrefslogtreecommitdiffstats
path: root/src/crimson/osd/osd_operation.cc
blob: 69ec5b7607b8e3cf076436081e8fa1b028442c8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#include "osd_operation.h"

namespace ceph::osd {

void Operation::dump(Formatter *f)
{
  f->open_object_section("operation");
  f->dump_string("type", get_type_name());
  f->dump_unsigned("id", id);
  {
    f->open_object_section("detail");
    dump_detail(f);
    f->close_section();
  }
  f->open_array_section("blockers");
  for (auto &blocker : blockers) {
    blocker->dump(f);
  }
  f->close_section();
  f->close_section();
}

void Operation::dump_brief(Formatter *f)
{
  f->open_object_section("operation");
  f->dump_string("type", get_type_name());
  f->dump_unsigned("id", id);
  f->close_section();
}

std::ostream &operator<<(std::ostream &lhs, const Operation &rhs) {
  lhs << rhs.get_type_name() << "(id=" << rhs.get_id() << ", detail=";
  rhs.print(lhs);
  lhs << ")";
  return lhs;
}

void Blocker::dump(Formatter *f) const
{
  f->open_object_section("blocker");
  f->dump_string("op_type", get_type_name());
  {
    f->open_object_section("detail");
    dump_detail(f);
    f->close_section();
  }
  f->close_section();
}

void OrderedPipelinePhase::Handle::exit()
{
  if (phase) {
    phase->mutex.unlock();
    phase = nullptr;
  }
}

blocking_future<> OrderedPipelinePhase::Handle::enter(
  OrderedPipelinePhase &new_phase)
{
  auto fut = new_phase.mutex.lock();
  exit();
  phase = &new_phase;
  return new_phase.make_blocking_future(std::move(fut));
}

OrderedPipelinePhase::Handle::~Handle()
{
  exit();
}

void OrderedPipelinePhase::dump_detail(Formatter *f) const
{
}

}