From d5f7005ddd012aed91d92ff66a112b36cd6a68c9 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 5 Sep 2024 02:20:35 +0300 Subject: [PATCH] Add dd and rm --exact|--matching documentation --- docs/usage/cli.en.md | 56 +++++++++++++++++++++++++++++++++++++------ docs/usage/cli.ru.md | 57 +++++++++++++++++++++++++++++++++++++------- src/cmd/cli.cpp | 34 +++++++++++++------------- 3 files changed, 114 insertions(+), 33 deletions(-) diff --git a/docs/usage/cli.en.md b/docs/usage/cli.en.md index 4e8132b2..d7f216f9 100644 --- a/docs/usage/cli.en.md +++ b/docs/usage/cli.en.md @@ -16,6 +16,7 @@ It supports the following commands: - [create](#create) - [snap-create](#create) - [modify](#modify) +- [dd](#dd) - [rm](#rm) - [flatten](#flatten) - [rm-data](#rm-data) @@ -148,19 +149,60 @@ You should resize file system in the image, if present, before shrinking it. * `-f|--force` - Proceed with shrinking or setting readwrite flag even if the image has children. * `--down-ok` - Proceed with shrinking even if some data will be left on unavailable OSDs. +## dd + +``` +vitastor-cli dd [iimg= | if=] [oimg= | of=] [bs=1M] \ + [count=N] [seek/oseek=N] [skip/iseek=M] [iodepth=N] [status=progress] \ + [conv=nocreat,noerror,nofsync,trunc,nosparse] [iflag=direct] [oflag=direct,append] +``` + +Copy data between Vitastor images, files and pipes. + +Options can be specified in classic dd style (`key=value`) or like usual (`--key value`). + +| | | +|-----------------|-------------------------------------------------------------------------| +| `iimg=` | Copy from Vitastor image `` | +| `if=` | Copy from file `` | +| `oimg=` | Copy to Vitastor image `` | +| `of=` | Copy to file `` | +| `bs=1M` | Set copy block size | +| `count=N` | Copy only N input blocks. If N ends in B it counts bytes, not blocks | +| `seek/oseek=N` | Skip N output blocks. If N ends in B it counts bytes, not blocks | +| `skip/iseek=N` | Skip N input blocks. If N ends in B it counts bytes, not blocks | +| `iodepth=N` | Send N reads or writes in parallel (default 4) | +| `status=LEVEL` | The LEVEL of information to print to stderr: none/noxfer/progress | +| `size=N` | Specify size for the created output file/image (defaults to input size) | +| `iflag=direct` | For input files only: use direct I/O | +| `oflag=direct` | For output files only: use direct I/O | +| `oflag=append` | For files only: append to output file | +| `conv=nocreat` | Do not create output file/image | +| `conv=trunc` | Truncate output file/image | +| `conv=noerror` | Continue copying after errors | +| `conv=nofsync` | Do not call fsync before finishing (default behaviour is fsync) | +| `conv=nosparse` | Write all output blocks including all-zero blocks | + ## rm `vitastor-cli rm [] [--writers-stopped] [--down-ok]` -Remove `` or all layers between `` and `` (`` must be a child of ``), -rebasing all their children accordingly. --writers-stopped allows merging to be a bit -more effective in case of a single 'slim' read-write child and 'fat' removed parent: -the child is merged into parent and parent is renamed to child in that case. -In other cases parent layers are always merged into children. +`vitastor-cli rm (--exact|--matching) ...` -Other options: +Remove layer(s) and rebase all their children accordingly. -* `--down-ok` - Continue deletion/merging even if some data will be left on unavailable OSDs. +In the first form, remove `` or layers between `` and its child ``. + +In the second form, remove all images with exact or pattern-matched names. + +Options: + +* `--writers-stopped` allows optimised removal in case of a single 'slim' read-write + child and 'fat' removed parent: the child is merged into parent and parent is renamed + to child in that case. In other cases parent layers are always merged into children. +* `--exact` - remove multiple images with names matching given glob patterns. +* `--matching` - remove multiple images with given names +* `--down-ok` - continue deletion/merging even if some data will be left on unavailable OSDs. ## flatten diff --git a/docs/usage/cli.ru.md b/docs/usage/cli.ru.md index c4bfac42..b1e70e2b 100644 --- a/docs/usage/cli.ru.md +++ b/docs/usage/cli.ru.md @@ -17,6 +17,7 @@ vitastor-cli - интерфейс командной строки для адм - [create](#create) - [snap-create](#create) - [modify](#modify) +- [dd](#dd) - [rm](#rm) - [flatten](#flatten) - [rm-data](#rm-data) @@ -151,23 +152,61 @@ vitastor-cli snap-create [-p|--pool ] @ * `-f|--force` - Разрешить уменьшение или перевод в чтение-запись образа, у которого есть клоны. * `--down-ok` - Разрешить уменьшение, даже если часть данных останется неудалённой на недоступных OSD. +## dd + +``` +vitastor-cli dd [iimg= | if=] [oimg= | of=] [bs=1M] \ + [count=N] [seek/oseek=N] [skip/iseek=M] [iodepth=N] [status=progress] \ + [conv=nocreat,noerror,nofsync,trunc,nosparse] [iflag=direct] [oflag=direct,append] +``` + +Копировать данные между образами Vitastor, файлами и каналами. + +Опции можно передавать в классическом стиле dd (`key=value`) или как обычно (`--key value`). + +| | | +|-----------------|-------------------------------------------------------------------------| +| `iimg=` | Копировать из образа Vitastor `` | +| `if=` | Копировать из файла `` | +| `oimg=` | Копировать в образ Vitastor `` | +| `of=` | Копировать в файл `` | +| `bs=1M` | Задать размер блока копирования | +| `count=N` | Копировать не более N блоков. Если N заканчивается на B - то N байт. | +| `seek/oseek=N` | Пропустить N выходных блоков. Если N заканчивается на B - то N байт. | +| `skip/iseek=N` | Пропустить N входных блоков. Если N заканчивается на B - то N байт. | +| `iodepth=N` | Отправлять N чтений/записей параллельно (по умолчанию 4). | +| `status=LEVEL` | Уровень вывода в консоль: none/noxfer/progress | +| `size=N` | Задать размер выходного файла/образа (по умолчанию равен размеру входа).| +| `iflag=direct` | Только для входного файла: использовать прямой ввод-вывод | +| `oflag=direct` | Только для выходного файла: использовать прямой ввод-вывод | +| `oflag=append` | Только для файлов: дописывать в конец выходного файла | +| `conv=nocreat` | Не создавать выходной файл/образ | +| `conv=trunc` | Обрезать выходной файл/образ до размера входа | +| `conv=noerror` | Продолжать копирование после ошибок | +| `conv=nofsync` | Не вызывать fsync перед завершением | +| `conv=nosparse` | Записывать все выходные блоки, включая пустые | + ## rm `vitastor-cli rm [] [--writers-stopped] [--down-ok]` -Удалить образ `` или все слои от `` до `` (`` должен быть дочерним -образом ``), одновременно меняя родительские образы их клонов (если таковые есть). +`vitastor-cli rm (--exact|--matching) ...` -`--writers-stopped` позволяет чуть более эффективно удалять образы в частом случае, когда -у удаляемой цепочки есть только один дочерний образ, содержащий небольшой объём данных. -В этом случае дочерний образ вливается в родительский и удаляется, а родительский -переименовывается в дочерний. +Удалить образ(ы), корректно перебазируя их дочерние образы. -В других случаях родительские слои вливаются в дочерние. +В первой форме удаляет один образ `` или все слои между `` и его дочерним ``. -Другие опции: +Во второй форме, удаляет все образы с точными именами или именами, подходящими под шаблон(ы). -* `--down-ok` - Продолжать удаление/слияние, даже если часть данных останется неудалённой на недоступных OSD. +Опции: + +* `--writers-stopped` позволяет чуть более эффективно удалять образы в частом случае, когда + у удаляемой цепочки есть только один дочерний образ, содержащий небольшой объём данных. + В этом случае дочерний образ вливается в родительский и удаляется, а родительский + переименовывается в дочерний. +* `--exact` - удалить все образы с именами, подходящими под переданные glob-шаблоны. +* `--matching` - удалить все образы с точно заданными именами. +* `--down-ok` - продолжать удаление/слияние, даже если часть данных останется неудалённой на недоступных OSD. ## flatten diff --git a/src/cmd/cli.cpp b/src/cmd/cli.cpp index a92dfaf4..9b5a88f0 100644 --- a/src/cmd/cli.cpp +++ b/src/cmd/cli.cpp @@ -54,19 +54,6 @@ static const char* help_text = " -f|--force Proceed with shrinking or setting readwrite flag even if the image has children.\n" " --down-ok Proceed with shrinking even if some data will be left on unavailable OSDs.\n" "\n" - "vitastor-cli rm []\n" - "vitastor-cli rm (--exact|--matching) ...\n" - " Remove layer(s) and rebase all their children accordingly.\n" - " In the first form, remove or layers between and its child .\n" - " In the second form, remove all images with exact or pattern-matched names.\n" - " --writers-stopped allows optimised removal in case of a single 'slim' read-write\n" - " child and 'fat' removed parent: the child is merged into parent and parent is renamed\n" - " to child in that case. In other cases parent layers are always merged into children.\n" - " --exact Remove multiple images with names matching given glob patterns.\n" - " --matching Remove multiple images with given names\n" - " --writers-stopped Allow renaming inodes over their read/write children.\n" - " --down-ok Continue deletion/merging even if some data will be left on unavailable OSDs.\n" - "\n" "vitastor-cli dd [iimg= | if=] [oimg= | of=] [bs=1M]\n" " [count=N] [seek/oseek=N] [skip/iseek=M] [iodepth=N] [status=progress]\n" " [conv=nocreat,noerror,nofsync,trunc,nosparse] [iflag=direct] [oflag=direct,append]\n" @@ -83,15 +70,28 @@ static const char* help_text = " iodepth=N Send N reads or writes in parallel (default 4)\n" " status=LEVEL The LEVEL of information to print to stderr: none/noxfer/progress\n" " size=N Specify size for the created output file/image (defaults to input size)\n" - " iflag=direct For files only: use direct I/O\n" - " oflag=direct For files only: use direct I/O\n" + " iflag=direct For input files only: use direct I/O\n" + " oflag=direct For output files only: use direct I/O\n" " oflag=append For files only: append to output file\n" " conv=nocreat Do not create output file/image\n" - " conv=trunc For files only: truncate output file\n" - " conv=noerror Continue read after errors\n" + " conv=trunc Truncate output file/image\n" + " conv=noerror Continue copying after errors\n" " conv=nofsync Do not call fsync before finishing (default behaviour is fsync)\n" " conv=nosparse Write all output blocks including all-zero blocks\n" "\n" + "vitastor-cli rm []\n" + "vitastor-cli rm (--exact|--matching) ...\n" + " Remove layer(s) and rebase all their children accordingly.\n" + " In the first form, remove or layers between and its child .\n" + " In the second form, remove all images with exact or pattern-matched names.\n" + " --writers-stopped allows optimised removal in case of a single 'slim' read-write\n" + " child and 'fat' removed parent: the child is merged into parent and parent is renamed\n" + " to child in that case. In other cases parent layers are always merged into children.\n" + " --exact Remove multiple images with names matching given glob patterns.\n" + " --matching Remove multiple images with given names\n" + " --writers-stopped Allow renaming inodes over their read/write children.\n" + " --down-ok Continue deletion/merging even if some data will be left on unavailable OSDs.\n" + "\n" "vitastor-cli flatten \n" " Flatten a layer, i.e. merge data and detach it from parents.\n" "\n"