summaryrefslogtreecommitdiffstats
path: root/src/crimson/osd/pg_interval_interrupt_condition.cc
blob: 7a8cceb7f6285f8c755a527f1bddca9efe4cb01a (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
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#include "pg_interval_interrupt_condition.h"
#include "pg.h"

#include "crimson/common/log.h"

SET_SUBSYS(osd);

namespace crimson::interruptible {
template thread_local interrupt_cond_t<crimson::osd::IOInterruptCondition>
interrupt_cond<crimson::osd::IOInterruptCondition>;
}

namespace crimson::osd {

IOInterruptCondition::IOInterruptCondition(Ref<PG>& pg, epoch_t epoch_started)
  : pg(pg), epoch_started(epoch_started) {}

IOInterruptCondition::~IOInterruptCondition() {
  // for the sake of forward declaring PG (which is a detivate of
  // intrusive_ref_counter<...>)
}

bool IOInterruptCondition::new_interval_created() {
  LOG_PREFIX(IOInterruptCondition::new_interval_created);
  const epoch_t interval_start = pg->get_interval_start_epoch();
  bool ret = epoch_started < interval_start;
  if (ret) {
    DEBUGDPP("stored epoch_started e{} < interval_start e{}", *pg, epoch_started, interval_start);
  }
  return ret;
}

bool IOInterruptCondition::is_stopping() {
  LOG_PREFIX(IOInterruptCondition::is_stopping);
  if (pg->stopping) {
    DEBUGDPP("pg stopping", *pg);
  }
  return pg->stopping;
}

bool IOInterruptCondition::is_primary() {
  return pg->is_primary();
}

} // namespace crimson::osd