diff --git a/docs/usage/cli.en.md b/docs/usage/cli.en.md index 8e504e2b..b8adcb5b 100644 --- a/docs/usage/cli.en.md +++ b/docs/usage/cli.en.md @@ -28,7 +28,8 @@ It supports the following commands: Global options: ``` ---etcd_address ADDR Etcd connection address +--config_file FILE Path to Vitastor configuration file +--etcd_address URL Etcd connection address --iodepth N Send N operations in parallel to each OSD when possible (default 32) --parallel_osds M Work with M osds in parallel when possible (default 4) --progress 1|0 Report progress (default 1) diff --git a/docs/usage/cli.ru.md b/docs/usage/cli.ru.md index f91ee21f..6d6b8a1c 100644 --- a/docs/usage/cli.ru.md +++ b/docs/usage/cli.ru.md @@ -27,7 +27,8 @@ vitastor-cli - интерфейс командной строки для адм Глобальные опции: ``` ---etcd_address ADDR Адрес соединения с etcd +--config_file FILE Путь к файлу конфигурации Vitastor +--etcd_address URL Адрес соединения с etcd --iodepth N Отправлять параллельно N операций на каждый OSD (по умолчанию 32) --parallel_osds M Работать параллельно с M OSD (по умолчанию 4) --progress 1|0 Печатать прогресс выполнения (по умолчанию 1) diff --git a/docs/usage/nbd.en.md b/docs/usage/nbd.en.md index b53b2481..b2e24cfb 100644 --- a/docs/usage/nbd.en.md +++ b/docs/usage/nbd.en.md @@ -20,16 +20,16 @@ See also [VDUSE](qemu.en.md#vduse). To create a local block device for a Vitastor image run: ``` -vitastor-nbd map --etcd_address 10.115.0.10:2379/v3 --image testimg +vitastor-nbd map --image testimg ``` It will output a block device name like /dev/nbd0 which you can then use as a normal disk. You can also use `--pool --inode --size ` instead of `--image ` if you want. -Additional options for map command: +vitastor-nbd supports all usual Vitastor configuration options like `--config_file ` plus NBD-specific: -* `--nbd_timeout 30` \ +* `--nbd_timeout 300` \ Timeout for I/O operations in seconds after exceeding which the kernel stops the device. You can set it to 0 to disable the timeout, but beware that you won't be able to stop the device at all if vitastor-nbd process dies. @@ -44,6 +44,9 @@ Additional options for map command: * `--foreground 1` \ Stay in foreground, do not daemonize. +Note that `nbd_timeout`, `nbd_max_devices` and `nbd_max_part` options may also be specified +in `/etc/vitastor/vitastor.conf` or in other configuration file specified with `--config_file`. + ## Unmap image To unmap the device run: diff --git a/docs/usage/nbd.ru.md b/docs/usage/nbd.ru.md index 38f34505..a4f5ea80 100644 --- a/docs/usage/nbd.ru.md +++ b/docs/usage/nbd.ru.md @@ -23,7 +23,7 @@ CSI-драйвер Kubernetes Vitastor основан на NBD. Чтобы создать локальное блочное устройство для образа, выполните команду: ``` -vitastor-nbd map --etcd_address 10.115.0.10:2379/v3 --image testimg +vitastor-nbd map --image testimg ``` Команда напечатает название блочного устройства вида /dev/nbd0, которое потом можно @@ -32,7 +32,8 @@ vitastor-nbd map --etcd_address 10.115.0.10:2379/v3 --image testimg Для обращения по номеру инода, аналогично другим командам, можно использовать опции `--pool --inode --size ` вместо `--image testimg`. -Дополнительные опции для команды подключения NBD-устройства: +vitastor-nbd поддерживает все обычные опции Vitastor, например, `--config_file `, +плюс специфичные для NBD: * `--nbd_timeout 30` \ Максимальное время выполнения любой операции чтения/записи в секундах, при @@ -53,6 +54,10 @@ vitastor-nbd map --etcd_address 10.115.0.10:2379/v3 --image testimg * `--foreground 1` \ Не уводить процесс в фоновый режим. +Обратите внимание, что опции `nbd_timeout`, `nbd_max_devices` и `nbd_max_part` можно +также задавать в `/etc/vitastor/vitastor.conf` или в другом файле конфигурации, +заданном опцией `--config_file`. + ## Отключить устройство Для отключения устройства выполните: diff --git a/docs/usage/nfs.en.md b/docs/usage/nfs.en.md index cafdea6a..95c009cc 100644 --- a/docs/usage/nfs.en.md +++ b/docs/usage/nfs.en.md @@ -23,7 +23,7 @@ balancer or any failover method you want to in that case. vitastor-nfs usage: ``` -vitastor-nfs [--etcd_address ADDR] [OTHER OPTIONS] +vitastor-nfs [STANDARD OPTIONS] [OTHER OPTIONS] --subdir export images prefixed / (default empty - export all images) --portmap 0 do not listen on port 111 (portmap/rpcbind, requires root) diff --git a/docs/usage/nfs.ru.md b/docs/usage/nfs.ru.md index 10603db1..e0d76e82 100644 --- a/docs/usage/nfs.ru.md +++ b/docs/usage/nfs.ru.md @@ -22,7 +22,7 @@ Использование vitastor-nfs: ``` -vitastor-nfs [--etcd_address ADDR] [ДРУГИЕ ОПЦИИ] +vitastor-nfs [СТАНДАРТНЫЕ ОПЦИИ] [ДРУГИЕ ОПЦИИ] --subdir экспортировать "поддиректорию" - образы с префиксом имени / (по умолчанию пусто - экспортировать все образы) --portmap 0 отключить сервис portmap/rpcbind на порту 111 (по умолчанию включён и требует root привилегий) diff --git a/src/cli.cpp b/src/cli.cpp index 647b99fb..301c7d8b 100644 --- a/src/cli.cpp +++ b/src/cli.cpp @@ -116,7 +116,8 @@ static const char* help_text = "Use vitastor-cli --help for command details or vitastor-cli --help --all for all details.\n" "\n" "GLOBAL OPTIONS:\n" - " --etcd_address \n" + " --config_file FILE Path to Vitastor configuration file\n" + " --etcd_address URL Etcd connection address\n" " --iodepth N Send N operations in parallel to each OSD when possible (default 32)\n" " --parallel_osds M Work with M osds in parallel when possible (default 4)\n" " --progress 1|0 Report progress (default 1)\n" diff --git a/src/nbd_proxy.cpp b/src/nbd_proxy.cpp index 812b3958..93f1a656 100644 --- a/src/nbd_proxy.cpp +++ b/src/nbd_proxy.cpp @@ -30,7 +30,7 @@ protected: std::string image_name; uint64_t inode = 0; uint64_t device_size = 0; - int nbd_timeout = 30; + int nbd_timeout = 300; int nbd_max_devices = 64; int nbd_max_part = 3; inode_watch_t *watch = NULL; @@ -135,14 +135,16 @@ public: " %s unmap /dev/nbd0\n" " %s ls [--json]\n" "OPTIONS:\n" - " All usual Vitastor config options like --etcd_address plus NBD-specific:\n" - " --nbd_timeout 30\n" + " All usual Vitastor config options like --config_file plus NBD-specific:\n" + " --nbd_timeout 300\n" " Timeout for I/O operations in seconds after exceeding which the kernel stops\n" " the device. You can set it to 0 to disable the timeout, but beware that you\n" " won't be able to stop the device at all if vitastor-nbd process dies.\n" " --nbd_max_devices 64 --nbd_max_part 3\n" " Options for the \"nbd\" kernel module when modprobing it (nbds_max and max_part).\n" " note that maximum allowed (nbds_max)*(1+max_part) is 256.\n" + " Note that nbd_timeout, nbd_max_devices and nbd_max_part options may also be specified\n" + " in /etc/vitastor/vitastor.conf or in other configuration file specified with --config_file.\n" " --logfile /path/to/log/file.txt\n" " Wite log messages to the specified file instead of dropping them (in background mode)\n" " or printing them to the standard output (in foreground mode).\n" @@ -204,17 +206,18 @@ public: exit(1); } } - if (cfg["nbd_max_devices"].is_number() || cfg["nbd_max_devices"].is_string()) + auto file_config = osd_messenger_t::read_config(cfg); + if (file_config["nbd_max_devices"].is_number() || file_config["nbd_max_devices"].is_string()) { - nbd_max_devices = cfg["nbd_max_devices"].uint64_value(); + nbd_max_devices = file_config["nbd_max_devices"].uint64_value(); } - if (cfg["nbd_max_part"].is_number() || cfg["nbd_max_part"].is_string()) + if (file_config["nbd_max_part"].is_number() || file_config["nbd_max_part"].is_string()) { - nbd_max_part = cfg["nbd_max_part"].uint64_value(); + nbd_max_part = file_config["nbd_max_part"].uint64_value(); } - if (cfg["nbd_timeout"].is_number() || cfg["nbd_timeout"].is_string()) + if (file_config["nbd_timeout"].is_number() || file_config["nbd_timeout"].is_string()) { - nbd_timeout = cfg["nbd_timeout"].uint64_value(); + nbd_timeout = file_config["nbd_timeout"].uint64_value(); } if (cfg["client_writeback_allowed"].is_null()) { @@ -272,7 +275,7 @@ public: int i = 0; while (true) { - int r = run_nbd(sockfd, i, device_size, NBD_FLAG_SEND_FLUSH, 30, bg); + int r = run_nbd(sockfd, i, device_size, NBD_FLAG_SEND_FLUSH, nbd_timeout, bg); if (r == 0) { printf("/dev/nbd%d\n", i); diff --git a/src/nfs_proxy.cpp b/src/nfs_proxy.cpp index 7d75cbd7..a3c9f5c7 100644 --- a/src/nfs_proxy.cpp +++ b/src/nfs_proxy.cpp @@ -56,7 +56,7 @@ json11::Json::object nfs_proxy_t::parse_args(int narg, const char *args[]) "(c) Vitaliy Filippov, 2021-2022 (VNPL-1.1)\n" "\n" "USAGE:\n" - " %s [--etcd_address ADDR] [OTHER OPTIONS]\n" + " %s [STANDARD OPTIONS] [OTHER OPTIONS]\n" " --subdir export images prefixed / (default empty - export all images)\n" " --portmap 0 do not listen on port 111 (portmap/rpcbind, requires root)\n" " --bind bind service to address (default 0.0.0.0)\n"