Make deleted inodes vanish from statistics after 60 seconds

rm-left-on-dead
Vitaliy Filippov 2022-06-04 00:37:52 +03:00
parent 088dd15449
commit 1efbbb0c36
7 changed files with 51 additions and 2 deletions

View File

@ -23,6 +23,7 @@ initialization and can be changed with an OSD restart.
- [no_rebalance](#no_rebalance) - [no_rebalance](#no_rebalance)
- [print_stats_interval](#print_stats_interval) - [print_stats_interval](#print_stats_interval)
- [slow_log_interval](#slow_log_interval) - [slow_log_interval](#slow_log_interval)
- [inode_vanish_time](#inode_vanish_time)
- [max_write_iodepth](#max_write_iodepth) - [max_write_iodepth](#max_write_iodepth)
- [min_flusher_count](#min_flusher_count) - [min_flusher_count](#min_flusher_count)
- [max_flusher_count](#max_flusher_count) - [max_flusher_count](#max_flusher_count)
@ -163,6 +164,13 @@ Time interval at which OSDs dump slow or stuck operations on stdout, if
they're any. Also it's the time after which an operation is considered they're any. Also it's the time after which an operation is considered
"slow". "slow".
## inode_vanish_time
- Type: seconds
- Default: 60
Number of seconds after which a deleted inode is removed from OSD statistics.
## max_write_iodepth ## max_write_iodepth
- Type: integer - Type: integer

View File

@ -24,6 +24,7 @@
- [no_rebalance](#no_rebalance) - [no_rebalance](#no_rebalance)
- [print_stats_interval](#print_stats_interval) - [print_stats_interval](#print_stats_interval)
- [slow_log_interval](#slow_log_interval) - [slow_log_interval](#slow_log_interval)
- [inode_vanish_time](#inode_vanish_time)
- [max_write_iodepth](#max_write_iodepth) - [max_write_iodepth](#max_write_iodepth)
- [min_flusher_count](#min_flusher_count) - [min_flusher_count](#min_flusher_count)
- [max_flusher_count](#max_flusher_count) - [max_flusher_count](#max_flusher_count)
@ -169,6 +170,13 @@ OSD.
медленных или зависших операций, если таковые имеются. Также время, при медленных или зависших операций, если таковые имеются. Также время, при
превышении которого операция считается "медленной". превышении которого операция считается "медленной".
## inode_vanish_time
- Тип: секунды
- Значение по умолчанию: 60
Число секунд, через которое удалённые инод удаляется и из статистики OSD.
## max_write_iodepth ## max_write_iodepth
- Тип: целое число - Тип: целое число

View File

@ -158,6 +158,13 @@
Временной интервал, с которым OSD выводят в стандартный вывод список Временной интервал, с которым OSD выводят в стандартный вывод список
медленных или зависших операций, если таковые имеются. Также время, при медленных или зависших операций, если таковые имеются. Также время, при
превышении которого операция считается "медленной". превышении которого операция считается "медленной".
- name: inode_vanish_time
type: sec
default: 60
info: |
Number of seconds after which a deleted inode is removed from OSD statistics.
info_ru: |
Число секунд, через которое удалённые инод удаляется и из статистики OSD.
- name: max_write_iodepth - name: max_write_iodepth
type: int type: int
default: 128 default: 128

View File

@ -105,6 +105,7 @@ const etcd_tree = {
no_rebalance: false, no_rebalance: false,
print_stats_interval: 3, print_stats_interval: 3,
slow_log_interval: 10, slow_log_interval: 10,
inode_vanish_time: 60,
osd_memlock: false, osd_memlock: false,
// blockstore - fixed in superblock // blockstore - fixed in superblock
block_size, block_size,

View File

@ -168,6 +168,9 @@ void osd_t::parse_config(const json11::Json & config)
slow_log_interval = config["slow_log_interval"].uint64_value(); slow_log_interval = config["slow_log_interval"].uint64_value();
if (!slow_log_interval) if (!slow_log_interval)
slow_log_interval = 10; slow_log_interval = 10;
inode_vanish_time = config["inode_vanish_time"].uint64_value();
if (!inode_vanish_time)
inode_vanish_time = 60;
} }
void osd_t::bind_socket() void osd_t::bind_socket()

View File

@ -113,6 +113,7 @@ class osd_t
int autosync_writes = DEFAULT_AUTOSYNC_WRITES; int autosync_writes = DEFAULT_AUTOSYNC_WRITES;
int recovery_queue_depth = DEFAULT_RECOVERY_QUEUE; int recovery_queue_depth = DEFAULT_RECOVERY_QUEUE;
int recovery_sync_batch = DEFAULT_RECOVERY_BATCH; int recovery_sync_batch = DEFAULT_RECOVERY_BATCH;
int inode_vanish_time = 60;
int log_level = 0; int log_level = 0;
// cluster state // cluster state
@ -165,6 +166,7 @@ class osd_t
// op statistics // op statistics
osd_op_stats_t prev_stats; osd_op_stats_t prev_stats;
std::map<uint64_t, inode_stats_t> inode_stats; std::map<uint64_t, inode_stats_t> inode_stats;
std::map<uint64_t, timespec> vanishing_inodes;
const char* recovery_stat_names[2] = { "degraded", "misplaced" }; const char* recovery_stat_names[2] = { "degraded", "misplaced" };
uint64_t recovery_stat_count[2][2] = {}; uint64_t recovery_stat_count[2][2] = {};
uint64_t recovery_stat_bytes[2][2] = {}; uint64_t recovery_stat_bytes[2][2] = {};

View File

@ -186,7 +186,8 @@ void osd_t::report_statistics()
json11::Json::object inode_space; json11::Json::object inode_space;
json11::Json::object last_stat; json11::Json::object last_stat;
pool_id_t last_pool = 0; pool_id_t last_pool = 0;
for (auto kv: bs->get_inode_space_stats()) auto & bs_inode_space = bs->get_inode_space_stats();
for (auto kv: bs_inode_space)
{ {
pool_id_t pool_id = INODE_POOL(kv.first); pool_id_t pool_id = INODE_POOL(kv.first);
uint64_t only_inode_num = INODE_NO_POOL(kv.first); uint64_t only_inode_num = INODE_NO_POOL(kv.first);
@ -204,8 +205,26 @@ void osd_t::report_statistics()
last_stat = json11::Json::object(); last_stat = json11::Json::object();
last_pool = 0; last_pool = 0;
json11::Json::object inode_ops; json11::Json::object inode_ops;
for (auto kv: inode_stats) timespec tv_now;
for (auto st_it = inode_stats.begin(); st_it != inode_stats.end(); )
{ {
auto & kv = *st_it;
if (!bs_inode_space[kv.first])
{
// Is it an empty inode?
if (!tv_now.tv_sec)
clock_gettime(CLOCK_REALTIME, &tv_now);
auto & tv_van = vanishing_inodes[kv.first];
if (!tv_van.tv_sec)
tv_van = tv_now;
else if (tv_van.tv_sec < tv_now.tv_sec-inode_vanish_time)
{
// Inode vanished <inode_vanish_time> seconds ago, remove it from stats
vanishing_inodes.erase(kv.first);
inode_stats.erase(st_it++);
continue;
}
}
pool_id_t pool_id = INODE_POOL(kv.first); pool_id_t pool_id = INODE_POOL(kv.first);
uint64_t only_inode_num = (kv.first & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1)); uint64_t only_inode_num = (kv.first & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1));
if (!last_pool || pool_id != last_pool) if (!last_pool || pool_id != last_pool)
@ -232,6 +251,7 @@ void osd_t::report_statistics()
{ "bytes", kv.second.op_bytes[INODE_STATS_DELETE] }, { "bytes", kv.second.op_bytes[INODE_STATS_DELETE] },
} }, } },
}; };
st_it++;
} }
if (last_pool) if (last_pool)
inode_ops[std::to_string(last_pool)] = last_stat; inode_ops[std::to_string(last_pool)] = last_stat;