]>
git.proxmox.com Git - ceph.git/blob - ceph/src/osd/TierAgentState.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
3 * Ceph - scalable distributed file system
5 * Copyright (C) 2013 Sage Weil <sage@inktank.com>
7 * This is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License version 2.1, as published by the Free Software
10 * Foundation. See file COPYING.
14 #ifndef CEPH_OSD_TIERAGENT_H
15 #define CEPH_OSD_TIERAGENT_H
22 #include "common/Formatter.h"
23 #include "common/histogram.h"
24 #include "common/hobject.h"
26 #include "osd/HitSet.h"
28 struct TierAgentState
{
29 /// current position iterating across pool
31 /// Count of agent_work since "start" position of object hash space
36 /// histogram of ages we've encountered
37 pow2_hist_t temp_hist
;
40 /// past HitSet(s) (not current)
41 std::map
<time_t,HitSetRef
> hit_set_map
;
43 /// a few recent things we've seen that are clean
44 std::list
<hobject_t
> recent_clean
;
47 FLUSH_MODE_IDLE
, // nothing to flush
48 FLUSH_MODE_LOW
, // flush dirty objects with a low speed
49 FLUSH_MODE_HIGH
, //flush dirty objects with a high speed
50 } flush_mode
; ///< current flush behavior
51 static const char *get_flush_mode_name(flush_mode_t m
) {
53 case FLUSH_MODE_IDLE
: return "idle";
54 case FLUSH_MODE_LOW
: return "low";
55 case FLUSH_MODE_HIGH
: return "high";
56 default: ceph_abort_msg("bad flush mode");
59 const char *get_flush_mode_name() const {
60 return get_flush_mode_name(flush_mode
);
64 EVICT_MODE_IDLE
, // no need to evict anything
65 EVICT_MODE_SOME
, // evict some things as we are near the target
66 EVICT_MODE_FULL
, // evict anything
67 } evict_mode
; ///< current evict behavior
68 static const char *get_evict_mode_name(evict_mode_t m
) {
70 case EVICT_MODE_IDLE
: return "idle";
71 case EVICT_MODE_SOME
: return "some";
72 case EVICT_MODE_FULL
: return "full";
73 default: ceph_abort_msg("bad evict mode");
76 const char *get_evict_mode_name() const {
77 return get_evict_mode_name(evict_mode
);
80 /// approximate ratio of objects (assuming they are uniformly
81 /// distributed) that i should aim to evict.
82 unsigned evict_effort
;
88 flush_mode(FLUSH_MODE_IDLE
),
89 evict_mode(EVICT_MODE_IDLE
),
93 /// false if we have any work to do
94 bool is_idle() const {
97 (flush_mode
== FLUSH_MODE_IDLE
&&
98 evict_mode
== EVICT_MODE_IDLE
);
101 /// add archived HitSet
102 void add_hit_set(time_t start
, HitSetRef hs
) {
103 hit_set_map
.insert(std::make_pair(start
, hs
));
106 /// remove old/trimmed HitSet
107 void remove_oldest_hit_set() {
108 if (!hit_set_map
.empty())
109 hit_set_map
.erase(hit_set_map
.begin());
112 /// discard all open hit sets
113 void discard_hit_sets() {
117 void dump(ceph::Formatter
*f
) const {
118 f
->dump_string("flush_mode", get_flush_mode_name());
119 f
->dump_string("evict_mode", get_evict_mode_name());
120 f
->dump_unsigned("evict_effort", evict_effort
);
121 f
->dump_stream("position") << position
;
122 f
->open_object_section("temp_hist");