Allow to specify tags and weights during prepare
This commit is contained in:
@@ -95,6 +95,8 @@ Options (single-device mode):
|
|||||||
Options (both modes):
|
Options (both modes):
|
||||||
|
|
||||||
```
|
```
|
||||||
|
--tags tag1,tag2 Set new OSD tag(s)
|
||||||
|
--weight <number> Set new OSD weight (between 0 to 1)
|
||||||
--journal_size 1G/32M Set journal size (area or partition size)
|
--journal_size 1G/32M Set journal size (area or partition size)
|
||||||
--block_size 1M/128k Set blockstore object size
|
--block_size 1M/128k Set blockstore object size
|
||||||
--bitmap_granularity 4k Set bitmap granularity
|
--bitmap_granularity 4k Set bitmap granularity
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ vitastor-disk - инструмент командной строки для уп
|
|||||||
Опции для обоих режимов:
|
Опции для обоих режимов:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
--tags tag1,tag2 Задать теги для новых OSD
|
||||||
|
--weight <number> Задать вес для новых OSD (от 0 до 1)
|
||||||
--journal_size 1G/32M Задать размер журнала (области или раздела журнала)
|
--journal_size 1G/32M Задать размер журнала (области или раздела журнала)
|
||||||
--block_size 1M/128k Задать размер объекта хранилища
|
--block_size 1M/128k Задать размер объекта хранилища
|
||||||
--bitmap_granularity 4k Задать гранулярность битовых карт
|
--bitmap_granularity 4k Задать гранулярность битовых карт
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ static const char *help_text =
|
|||||||
" --force Bypass partition safety checks (for emptiness and so on)\n"
|
" --force Bypass partition safety checks (for emptiness and so on)\n"
|
||||||
" \n"
|
" \n"
|
||||||
" Options (both modes):\n"
|
" Options (both modes):\n"
|
||||||
|
" --tags tag1,tag2 Set new OSD tag(s)\n"
|
||||||
|
" --weight <number> Set new OSD weight (between 0 and 1)\n"
|
||||||
" --journal_size 32M/1G Set journal size (area or partition size)\n"
|
" --journal_size 32M/1G Set journal size (area or partition size)\n"
|
||||||
" --block_size 128k/1M Set blockstore object size\n"
|
" --block_size 128k/1M Set blockstore object size\n"
|
||||||
" --bitmap_granularity 4k Set bitmap granularity\n"
|
" --bitmap_granularity 4k Set bitmap granularity\n"
|
||||||
|
|||||||
@@ -78,6 +78,15 @@ int disk_tool_t::prepare_one(std::map<std::string, std::string> options, int is_
|
|||||||
if (check_existing_partition(dev) != 0)
|
if (check_existing_partition(dev) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (options.find("weight") != options.end())
|
||||||
|
{
|
||||||
|
double reweight = json11::Json(options["weight"]).number_value();
|
||||||
|
if (reweight < 0 || reweight > 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "OSD weight must be between 0 and 1\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (options.find("atomic_write_size") == options.end())
|
if (options.find("atomic_write_size") == options.end())
|
||||||
{
|
{
|
||||||
@@ -238,6 +247,25 @@ int disk_tool_t::prepare_one(std::map<std::string, std::string> options, int is_
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
sb["osd_num"] = osd_num;
|
sb["osd_num"] = osd_num;
|
||||||
|
if (options.find("weight") != options.end() || options.find("tags") != options.end())
|
||||||
|
{
|
||||||
|
std::vector<std::string> cmd = { "vitastor-cli", "modify-osd", std::to_string(osd_num) };
|
||||||
|
if (options.find("weight") != options.end())
|
||||||
|
{
|
||||||
|
cmd.push_back("--reweight");
|
||||||
|
cmd.push_back(options["weight"]);
|
||||||
|
}
|
||||||
|
if (options.find("tags") != options.end())
|
||||||
|
{
|
||||||
|
cmd.push_back("--tags");
|
||||||
|
cmd.push_back(options["tags"]);
|
||||||
|
}
|
||||||
|
if (shell_exec(cmd, "", NULL, NULL) != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to modify OSD %ju tags and/or reweight\n", osd_num);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Zero out metadata and journal
|
// Zero out metadata and journal
|
||||||
if (write_zero(dsk.meta_fd, sb["meta_offset"].uint64_value(), dsk.meta_area_size) != 0 ||
|
if (write_zero(dsk.meta_fd, sb["meta_offset"].uint64_value(), dsk.meta_area_size) != 0 ||
|
||||||
write_zero(dsk.journal_fd, sb["journal_offset"].uint64_value(), dsk.journal_len) != 0)
|
write_zero(dsk.journal_fd, sb["journal_offset"].uint64_value(), dsk.journal_len) != 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user