From 6783d4a13c49cfcb4231c2bad301a54cb375ed23 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 10 Mar 2024 18:08:57 +0300 Subject: [PATCH] Implement fool protection for FS pools --- docs/config/pool.en.md | 20 ++++++++++++++++++++ docs/config/pool.ru.md | 22 ++++++++++++++++++++++ docs/usage/cli.en.md | 2 +- src/cli.cpp | 5 ++--- src/cli_create.cpp | 22 +++++++++++++++++----- src/cli_pool_cfg.cpp | 11 +++++------ src/cli_pool_ls.cpp | 3 +-- src/cli_pool_modify.cpp | 18 ++++++++++++++++++ src/etcd_state_client.cpp | 4 ++-- src/etcd_state_client.h | 2 +- src/nfs_kv.cpp | 21 ++++++++++++++++++++- src/nfs_kv.h | 1 + src/nfs_kv_create.cpp | 8 ++++---- src/osd_cluster.cpp | 2 +- tests/test_nfs.sh | 1 + 15 files changed, 116 insertions(+), 26 deletions(-) diff --git a/docs/config/pool.en.md b/docs/config/pool.en.md index c7043896..d442e648 100644 --- a/docs/config/pool.en.md +++ b/docs/config/pool.en.md @@ -41,6 +41,7 @@ Parameters: - [osd_tags](#osd_tags) - [primary_affinity_tags](#primary_affinity_tags) - [scrub_interval](#scrub_interval) +- [used_for_fs](#used_for_fs) Examples: @@ -299,6 +300,25 @@ of the OSDs containing a data chunk for a PG. Automatic scrubbing interval for this pool. Overrides [global scrub_interval setting](osd.en.md#scrub_interval). +## used_for_fs + +- Type: string + +If non-empty, the pool is marked as used for VitastorFS with metadata stored +in block image (regular Vitastor volume) named as the value of this pool parameter. + +When a pool is marked as used for VitastorFS, regular block volume creation in it +is disabled (vitastor-cli refuses to create images without --force) to protect +the user from block volume and FS file ID collisions and data loss. + +[vitastor-nfs](../usage/nfs.ru.md), in its turn, refuses to use pools not marked +for the corresponding FS when starting. This also implies that you can use one +pool only for one VitastorFS. + +The second thing that is disabled for VitastorFS pools is reporting per-inode space +usage statistics in etcd because a FS pool may store a very large number of files +and statistics for them all would take a lot of space in etcd. + # Examples ## Replicated pool diff --git a/docs/config/pool.ru.md b/docs/config/pool.ru.md index 52bd3bf6..44abb707 100644 --- a/docs/config/pool.ru.md +++ b/docs/config/pool.ru.md @@ -40,6 +40,7 @@ - [osd_tags](#osd_tags) - [primary_affinity_tags](#primary_affinity_tags) - [scrub_interval](#scrub_interval) +- [used_for_fs](#used_for_fs) Примеры: @@ -306,6 +307,27 @@ OSD с "all". Интервал скраба, то есть, автоматической фоновой проверки данных для данного пула. Переопределяет [глобальную настройку scrub_interval](osd.ru.md#scrub_interval). +## used_for_fs + +- Type: string + +Если непусто, пул помечается как используемый для файловой системы VitastorFS с +метаданными, хранимыми в блочном образе Vitastor с именем, равным значению +этого параметра. + +Когда пул помечается как используемый для VitastorFS, создание обычных блочных +образов в нём отключается (vitastor-cli отказывается создавать образы без --force), +чтобы защитить пользователя от коллизий ID файлов и блочных образов и, таким +образом, от потери данных. + +[vitastor-nfs](../usage/nfs.ru.md), в свою очередь, при запуске отказывается +использовать для ФС пулы, не выделенные для неё. Это также означает, что один +пул может использоваться только для одной VitastorFS. + +Также для ФС-пулов отключается передача статистики в etcd по отдельным инодам, +так как ФС-пул может содержать очень много файлов и статистика по ним всем +заняла бы очень много места в etcd. + # Примеры ## Реплицированный пул diff --git a/docs/usage/cli.en.md b/docs/usage/cli.en.md index 94d1680b..bcf46076 100644 --- a/docs/usage/cli.en.md +++ b/docs/usage/cli.en.md @@ -267,7 +267,7 @@ Optional parameters: | `--immediate_commit none` | Put pool only on OSDs with this or larger immediate_commit (none < small < all) | | `--primary_affinity_tags tags` | Prefer to put primary copies on OSDs with all specified tags | | `--scrub_interval