Support listing PGs by OSDs
This commit is contained in:
@@ -355,7 +355,7 @@ Set OSD reweight, tags or noout flag. See detail description in [OSD config docu
|
|||||||
|
|
||||||
## pg-list
|
## pg-list
|
||||||
|
|
||||||
`vitastor-cli pg-list|pg-ls|list-pg|ls-pg|ls-pgs [OPTIONS] [state1+state2] [^state3] [...]`
|
`vitastor-cli pg-list|pg-ls|list-pg|ls-pg|ls-pgs|pgs [OPTIONS] [state1+state2] [^state3] [...]`
|
||||||
|
|
||||||
List PGs with any of listed state filters (^ or ! in the beginning is negation). Options:
|
List PGs with any of listed state filters (^ or ! in the beginning is negation). Options:
|
||||||
|
|
||||||
@@ -363,6 +363,7 @@ List PGs with any of listed state filters (^ or ! in the beginning is negation).
|
|||||||
--pool <pool name or number> Only list PGs of the given pool.
|
--pool <pool name or number> Only list PGs of the given pool.
|
||||||
--min <min pg number> Only list PGs with number >= min.
|
--min <min pg number> Only list PGs with number >= min.
|
||||||
--max <max pg number> Only list PGs with number <= max.
|
--max <max pg number> Only list PGs with number <= max.
|
||||||
|
--osd 1,2,... Only list PGs with some data on specified OSD(s).
|
||||||
```
|
```
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|||||||
@@ -375,9 +375,10 @@ OSD PARENT UP SIZE USED% TAGS WEIGHT BLOCK BITMAP
|
|||||||
в начале фильтра означает отрицание). Опции:
|
в начале фильтра означает отрицание). Опции:
|
||||||
|
|
||||||
```
|
```
|
||||||
--pool <pool name or number> Only list PGs of the given pool.
|
--pool <pool name or number> Вывести только PG в заданном пуле.
|
||||||
--min <min pg number> Only list PGs with number >= min.
|
--min <min pg number> Вывести только PG с номерами >= min.
|
||||||
--max <max pg number> Only list PGs with number <= max.
|
--max <max pg number> Вывести только PG с номерами <= max.
|
||||||
|
--osd 1,2,... Вывести только PG с данными на заданных OSD.
|
||||||
```
|
```
|
||||||
|
|
||||||
Примеры:
|
Примеры:
|
||||||
|
|||||||
+3
-2
@@ -160,11 +160,12 @@ static const char* help_text =
|
|||||||
"vitastor-cli modify-osd [--tags tag1,tag2,...] [--reweight <number>] [--noout true/false] <osd_number>\n"
|
"vitastor-cli modify-osd [--tags tag1,tag2,...] [--reweight <number>] [--noout true/false] <osd_number>\n"
|
||||||
" Set OSD reweight, tags or noout flag.\n"
|
" Set OSD reweight, tags or noout flag.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"vitastor-cli pg-list|pg-ls|list-pg|ls-pg|ls-pgs [OPTIONS] [state1+state2] [^state3] [...]\n"
|
"vitastor-cli pg-list|pg-ls|list-pg|ls-pg|ls-pgs|pgs [OPTIONS] [state1+state2] [^state3] [...]\n"
|
||||||
" List PGs with any of listed state filters (^ or ! in the beginning is negation). Options:\n"
|
" List PGs with any of listed state filters (^ or ! in the beginning is negation). Options:\n"
|
||||||
" --pool <pool name or number> Only list PGs of the given pool.\n"
|
" --pool <pool name or number> Only list PGs of the given pool.\n"
|
||||||
" --min <min pg number> Only list PGs with number >= min.\n"
|
" --min <min pg number> Only list PGs with number >= min.\n"
|
||||||
" --max <max pg number> Only list PGs with number <= max.\n"
|
" --max <max pg number> Only list PGs with number <= max.\n"
|
||||||
|
" --osd 1,2,... Only list PGs with some data on specified OSD(s).\n"
|
||||||
" Examples:\n"
|
" Examples:\n"
|
||||||
" vitastor-cli pg-list active+degraded\n"
|
" vitastor-cli pg-list active+degraded\n"
|
||||||
" vitastor-cli pg-list ^active\n"
|
" vitastor-cli pg-list ^active\n"
|
||||||
@@ -483,7 +484,7 @@ static int run(cli_tool_t *p, json11::Json::object cfg)
|
|||||||
cfg["osd_num"] = cmd[1];
|
cfg["osd_num"] = cmd[1];
|
||||||
action_cb = p->start_modify_osd(cfg);
|
action_cb = p->start_modify_osd(cfg);
|
||||||
}
|
}
|
||||||
else if (cmd[0] == "pg-list" || cmd[0] == "pg-ls" || cmd[0] == "list-pg" || cmd[0] == "ls-pg" || cmd[0] == "ls-pgs")
|
else if (cmd[0] == "pg-list" || cmd[0] == "pg-ls" || cmd[0] == "list-pg" || cmd[0] == "ls-pg" || cmd[0] == "ls-pgs" || cmd[0] == "pgs")
|
||||||
{
|
{
|
||||||
// Modify OSD configuration
|
// Modify OSD configuration
|
||||||
if (cmd.size() > 1)
|
if (cmd.size() > 1)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ struct pg_lister_t
|
|||||||
cli_tool_t *parent;
|
cli_tool_t *parent;
|
||||||
|
|
||||||
uint64_t pool_id = 0;
|
uint64_t pool_id = 0;
|
||||||
|
std::set<osd_num_t> osd_nums;
|
||||||
std::string pool_name;
|
std::string pool_name;
|
||||||
std::vector<std::string> pg_state;
|
std::vector<std::string> pg_state;
|
||||||
uint64_t min_pg_num = 0;
|
uint64_t min_pg_num = 0;
|
||||||
@@ -137,6 +138,22 @@ resume_1:
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (osd_nums.size())
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
for (int i = 0; !found && i < pgp.second.target_set.size(); i++)
|
||||||
|
if (osd_nums.find(pgp.second.target_set[i]) != osd_nums.end())
|
||||||
|
found = true;
|
||||||
|
for (int i = 0; !found && i < pgp.second.target_history.size(); i++)
|
||||||
|
for (int j = 0; !found && j < pgp.second.target_history[i].size(); j++)
|
||||||
|
if (osd_nums.find(pgp.second.target_history[i][j]) != osd_nums.end())
|
||||||
|
found = true;
|
||||||
|
for (int i = 0; !found && i < pgp.second.all_peers.size(); i++)
|
||||||
|
if (osd_nums.find(pgp.second.all_peers[i]) != osd_nums.end())
|
||||||
|
found = true;
|
||||||
|
if (!found)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (masks.size())
|
if (masks.size())
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@@ -274,6 +291,14 @@ std::function<bool(cli_result_t &)> cli_tool_t::start_pg_list(json11::Json cfg)
|
|||||||
pg_lister->pg_state.push_back(cfg["pg_state"].string_value());
|
pg_lister->pg_state.push_back(cfg["pg_state"].string_value());
|
||||||
pg_lister->min_pg_num = cfg["min"].uint64_value();
|
pg_lister->min_pg_num = cfg["min"].uint64_value();
|
||||||
pg_lister->max_pg_num = cfg["max"].uint64_value();
|
pg_lister->max_pg_num = cfg["max"].uint64_value();
|
||||||
|
if (cfg["osd"].is_array())
|
||||||
|
for (auto & osd_num_json: cfg["osd"].array_items())
|
||||||
|
pg_lister->osd_nums.insert(osd_num_json.uint64_value());
|
||||||
|
else if (cfg["osd"].is_string())
|
||||||
|
for (auto & osd_num_str: explode(",", cfg["osd"].string_value(), true))
|
||||||
|
pg_lister->osd_nums.insert(stoull_full(osd_num_str));
|
||||||
|
else if (cfg["osd"].uint64_value())
|
||||||
|
pg_lister->osd_nums.insert(cfg["osd"].uint64_value());
|
||||||
return [pg_lister](cli_result_t & result)
|
return [pg_lister](cli_result_t & result)
|
||||||
{
|
{
|
||||||
pg_lister->loop();
|
pg_lister->loop();
|
||||||
|
|||||||
Reference in New Issue
Block a user