]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | /* | |
3 | * Ceph - scalable distributed file system | |
4 | * | |
5 | * Copyright (C) 2013 Sage Weil <sage@inktank.com> | |
6 | * | |
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. | |
11 | * | |
12 | */ | |
13 | ||
14 | #ifndef CEPH_OSD_TIERAGENT_H | |
15 | #define CEPH_OSD_TIERAGENT_H | |
16 | ||
17 | struct TierAgentState { | |
18 | /// current position iterating across pool | |
19 | hobject_t position; | |
20 | /// Count of agent_work since "start" position of object hash space | |
21 | int started; | |
22 | hobject_t start; | |
23 | bool delaying; | |
24 | ||
25 | /// histogram of ages we've encountered | |
26 | pow2_hist_t temp_hist; | |
27 | int hist_age; | |
28 | ||
29 | /// past HitSet(s) (not current) | |
30 | map<time_t,HitSetRef> hit_set_map; | |
31 | ||
32 | /// a few recent things we've seen that are clean | |
33 | list<hobject_t> recent_clean; | |
34 | ||
35 | enum flush_mode_t { | |
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) { | |
41 | switch (m) { | |
42 | case FLUSH_MODE_IDLE: return "idle"; | |
43 | case FLUSH_MODE_LOW: return "low"; | |
44 | case FLUSH_MODE_HIGH: return "high"; | |
11fdf7f2 | 45 | default: ceph_abort_msg("bad flush mode"); |
7c673cae FG |
46 | } |
47 | } | |
48 | const char *get_flush_mode_name() const { | |
49 | return get_flush_mode_name(flush_mode); | |
50 | } | |
51 | ||
52 | enum evict_mode_t { | |
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) { | |
58 | switch (m) { | |
59 | case EVICT_MODE_IDLE: return "idle"; | |
60 | case EVICT_MODE_SOME: return "some"; | |
61 | case EVICT_MODE_FULL: return "full"; | |
11fdf7f2 | 62 | default: ceph_abort_msg("bad evict mode"); |
7c673cae FG |
63 | } |
64 | } | |
65 | const char *get_evict_mode_name() const { | |
66 | return get_evict_mode_name(evict_mode); | |
67 | } | |
68 | ||
69 | /// approximate ratio of objects (assuming they are uniformly | |
70 | /// distributed) that i should aim to evict. | |
71 | unsigned evict_effort; | |
72 | ||
73 | TierAgentState() | |
74 | : started(0), | |
75 | delaying(false), | |
76 | hist_age(0), | |
77 | flush_mode(FLUSH_MODE_IDLE), | |
78 | evict_mode(EVICT_MODE_IDLE), | |
79 | evict_effort(0) | |
80 | {} | |
81 | ||
82 | /// false if we have any work to do | |
83 | bool is_idle() const { | |
84 | return | |
85 | delaying || | |
86 | (flush_mode == FLUSH_MODE_IDLE && | |
87 | evict_mode == EVICT_MODE_IDLE); | |
88 | } | |
89 | ||
90 | /// add archived HitSet | |
91 | void add_hit_set(time_t start, HitSetRef hs) { | |
92 | hit_set_map.insert(make_pair(start, hs)); | |
93 | } | |
94 | ||
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()); | |
99 | } | |
100 | ||
101 | /// discard all open hit sets | |
102 | void discard_hit_sets() { | |
103 | hit_set_map.clear(); | |
104 | } | |
105 | ||
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"); | |
112 | temp_hist.dump(f); | |
113 | f->close_section(); | |
114 | } | |
115 | }; | |
116 | ||
117 | #endif |