vitastor-disk: make update-sb write only the given parameters and check them #188

Open
koolkhel wants to merge 4 commits from koolkhel/vitastor:disk-update-sb-checks into master
Contributor

Description

Two small fixes to vitastor-disk update-sb:

  1. update-sb copied every entry of the tool's options into the superblock. read_osd_superblock() looks options["io"] up with operator[], which adds an empty "io", so every update-sb also wrote "io": "" into the superblock. Now only the parameters given on the command line are written, except --io, which only sets how vitastor-disk itself opens the devices (it was written as "io": "cached" when given).
  2. update-sb wrote any value, so for example --meta_block_size 4294967296 left an OSD that refused to start. Now it loads the resulting parameters the way the OSD does at start (parse them, open the devices, calculate and check the layout lengths) and refuses to write them if that fails, so --journal_size 1T is refused too, leaving the superblock as it was. The check doesn't take the device lock, so update-sb still works while the OSD is running. --force still writes them, as it already skips the superblock validation.

Found: by a tester passing out-of-range values to update-sb on a loop device, then reading the superblock back (the empty "io" showed up there). Unlikely in operation, cheap to prevent.

Tested: tests/test_resize_auto.sh, plain and OLD=1. The new update-sb checks at its end (the first one passes --io cached) fail without the fixes.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description Two small fixes to `vitastor-disk update-sb`: 1. update-sb copied every entry of the tool's options into the superblock. read_osd_superblock() looks `options["io"]` up with `operator[]`, which adds an empty "io", so every update-sb also wrote `"io": ""` into the superblock. Now only the parameters given on the command line are written, except `--io`, which only sets how vitastor-disk itself opens the devices (it was written as `"io": "cached"` when given). 2. update-sb wrote any value, so for example `--meta_block_size 4294967296` left an OSD that refused to start. Now it loads the resulting parameters the way the OSD does at start (parse them, open the devices, calculate and check the layout lengths) and refuses to write them if that fails, so `--journal_size 1T` is refused too, leaving the superblock as it was. The check doesn't take the device lock, so update-sb still works while the OSD is running. `--force` still writes them, as it already skips the superblock validation. Found: by a tester passing out-of-range values to update-sb on a loop device, then reading the superblock back (the empty "io" showed up there). Unlikely in operation, cheap to prevent. Tested: tests/test_resize_auto.sh, plain and OLD=1. The new update-sb checks at its end (the first one passes `--io cached`) fail without the fixes. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 2 commits 2026-11-25 18:14:43 +03:00
update-sb copied every entry of the tool's options into the superblock.
read_osd_superblock() looks options["io"] up with operator[], which adds
an empty "io", so every update-sb also wrote "io": "" into the
superblock. Copy the requested parameters before reading the superblock.
update-sb wrote any value, so for example --meta_block_size 4294967296
left an OSD that refused to start. Load the resulting parameters the way
dump-meta does (parse them, open the devices, calculate the layout) and
refuse to write them if that fails, leaving the superblock as it was.
--force writes them anyway, as it already skips the superblock validation.
koolkhel added 1 commit 2026-11-26 06:06:25 +03:00
--io only sets how vitastor-disk itself opens the devices, but update-sb
wrote it into the superblock too, for example "io": "cached". Leave it
out like --force.
koolkhel added 1 commit 2026-11-26 13:54:09 +03:00
update-sb checked the new parameters with calc_lengths() only, so for
example --journal_size 1T was written and the OSD then refused to start
with "Requested journal_size is too large". Also run check_lengths(),
as the OSD does after calc_lengths(). dump-meta keeps the lighter check,
so it can still read an OSD that doesn't start.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u disk-update-sb-checks:koolkhel-disk-update-sb-checks
git checkout koolkhel-disk-update-sb-checks
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#188
No description provided.