]>
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
17 struct TierAgentState
{
18 /// current position iterating across pool
20 /// Count of agent_work since "start" position of object hash space
25 /// histogram of ages we've encountered
26 pow2_hist_t temp_hist
;
29 /// past HitSet(s) (not current)
30 map
<time_t,HitSetRef
> hit_set_map
;
32 /// a few recent things we've seen that are clean
33 list
<hobject_t
> recent_clean
;
36 FLUSH_MODE_IDLE
, // nothing to flush
37 FLUSH_MODE_LOW
, // flush dirty objects with a low speed
38 FLUSH_MODE_HIGH
, //flush dirty objects with a high speed
39 } flush_mode
; ///< current flush behavior
40 static const char *get_flush_mode_name(flush_mode_t m
) {
42 case FLUSH_MODE_IDLE
: return "idle";
43 case FLUSH_MODE_LOW
: return "low";
44 case FLUSH_MODE_HIGH
: return "high";
45 default: assert(0 == "bad flush mode");
48 const char *get_flush_mode_name() const {
49 return get_flush_mode_name(flush_mode
);
53 EVICT_MODE_IDLE
, // no need to evict anything
54 EVICT_MODE_SOME
, // evict some things as we are near the target
55 EVICT_MODE_FULL
, // evict anything
56 } evict_mode
; ///< current evict behavior
57 static const char *get_evict_mode_name(evict_mode_t m
) {
59 case EVICT_MODE_IDLE
: return "idle";
60 case EVICT_MODE_SOME
: return "some";
61 case EVICT_MODE_FULL
: return "full";
62 default: assert(0 == "bad evict mode");
65 const char *get_evict_mode_name() const {
66 return get_evict_mode_name(evict_mode
);
69 /// approximate ratio of objects (assuming they are uniformly
70 /// distributed) that i should aim to evict.
71 unsigned evict_effort
;
77 flush_mode(FLUSH_MODE_IDLE
),
78 evict_mode(EVICT_MODE_IDLE
),
82 /// false if we have any work to do
83 bool is_idle() const {
86 (flush_mode
== FLUSH_MODE_IDLE
&&
87 evict_mode
== EVICT_MODE_IDLE
);
90 /// add archived HitSet
91 void add_hit_set(time_t start
, HitSetRef hs
) {
92 hit_set_map
.insert(make_pair(start
, hs
));
95 /// remove old/trimmed HitSet
96 void remove_oldest_hit_set() {
97 if (!hit_set_map
.empty())
98 hit_set_map
.erase(hit_set_map
.begin());
101 /// discard all open hit sets
102 void discard_hit_sets() {
106 void dump(Formatter
*f
) const {
107 f
->dump_string("flush_mode", get_flush_mode_name());
108 f
->dump_string("evict_mode", get_evict_mode_name());
109 f
->dump_unsigned("evict_effort", evict_effort
);
110 f
->dump_stream("position") << position
;
111 f
->open_object_section("temp_hist");