Add --force to vitastor-disk read-sb
parent
f8722a8bd5
commit
6917a32ca8
|
@ -109,8 +109,9 @@ static const char *help_text =
|
||||||
" Commands are passed to systemctl with vitastor-osd@<num> units as arguments.\n"
|
" Commands are passed to systemctl with vitastor-osd@<num> units as arguments.\n"
|
||||||
" When --now is added to enable/disable, OSDs are also immediately started/stopped.\n"
|
" When --now is added to enable/disable, OSDs are also immediately started/stopped.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"vitastor-disk read-sb <device>\n"
|
"vitastor-disk read-sb [--force] <device>\n"
|
||||||
" Try to read Vitastor OSD superblock from <device> and print it in JSON format.\n"
|
" Try to read Vitastor OSD superblock from <device> and print it in JSON format.\n"
|
||||||
|
" --force allows to bypass \"does not refer to the device itself\" errors.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"vitastor-disk write-sb <device>\n"
|
"vitastor-disk write-sb <device>\n"
|
||||||
" Read JSON from STDIN and write it into Vitastor OSD superblock on <device>.\n"
|
" Read JSON from STDIN and write it into Vitastor OSD superblock on <device>.\n"
|
||||||
|
|
|
@ -111,7 +111,7 @@ struct disk_tool_t
|
||||||
int systemd_start_stop_osds(std::vector<std::string> cmd, std::vector<std::string> devices);
|
int systemd_start_stop_osds(std::vector<std::string> cmd, std::vector<std::string> devices);
|
||||||
int pre_exec_osd(std::string device);
|
int pre_exec_osd(std::string device);
|
||||||
|
|
||||||
json11::Json read_osd_superblock(std::string device, bool expect_exist = true);
|
json11::Json read_osd_superblock(std::string device, bool expect_exist = true, bool ignore_nonref = false);
|
||||||
uint32_t write_osd_superblock(std::string device, json11::Json params);
|
uint32_t write_osd_superblock(std::string device, json11::Json params);
|
||||||
|
|
||||||
int prepare_one(std::map<std::string, std::string> options, int is_hdd = -1);
|
int prepare_one(std::map<std::string, std::string> options, int is_hdd = -1);
|
||||||
|
|
|
@ -54,7 +54,7 @@ int disk_tool_t::udev_import(std::string device)
|
||||||
|
|
||||||
int disk_tool_t::read_sb(std::string device)
|
int disk_tool_t::read_sb(std::string device)
|
||||||
{
|
{
|
||||||
json11::Json sb = read_osd_superblock(device);
|
json11::Json sb = read_osd_superblock(device, true, options.find("force") != options.end());
|
||||||
if (sb.is_null())
|
if (sb.is_null())
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -123,7 +123,7 @@ uint32_t disk_tool_t::write_osd_superblock(std::string device, json11::Json para
|
||||||
return sb_size;
|
return sb_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
json11::Json disk_tool_t::read_osd_superblock(std::string device, bool expect_exist)
|
json11::Json disk_tool_t::read_osd_superblock(std::string device, bool expect_exist, bool ignore_nonref)
|
||||||
{
|
{
|
||||||
vitastor_disk_superblock_t *sb = NULL;
|
vitastor_disk_superblock_t *sb = NULL;
|
||||||
uint8_t *buf = NULL;
|
uint8_t *buf = NULL;
|
||||||
|
@ -226,7 +226,7 @@ json11::Json disk_tool_t::read_osd_superblock(std::string device, bool expect_ex
|
||||||
{
|
{
|
||||||
device_type = "journal";
|
device_type = "journal";
|
||||||
}
|
}
|
||||||
else
|
else if (!ignore_nonref)
|
||||||
{
|
{
|
||||||
if (expect_exist)
|
if (expect_exist)
|
||||||
fprintf(stderr, "Invalid OSD superblock on %s: does not refer to the device itself\n", device.c_str());
|
fprintf(stderr, "Invalid OSD superblock on %s: does not refer to the device itself\n", device.c_str());
|
||||||
|
|
Loading…
Reference in New Issue