vitastor-disk: Refuse a disk given both as data and in --fast-devices #135

Merged
vitalif merged 1 commits from koolkhel/vitastor:prepare-fast-data-overlap into master 2026-11-20 19:20:12 +03:00
Contributor

Description

vitastor-disk prepare collects the device list and --fast-devices with two separate collect_devices() calls, so a disk given in both gets two entries, each with its own copy of the partition table read before anything is created. The two then overwrite each other's new partitions.

Seen on loop devices on master with prepare --hybrid --fast-devices B A B (A is 100G, B is 20G):

  • the OSD on A is created normally, with its journal and metadata on B;
  • the data partition created on B is dropped from the table when the journal and metadata partitions for it are added, and its OSD is not initialized: Failed to open data device /dev/disk/by-partuuid/...: No such file or directory;
  • B is left with two unused journal and metadata partitions;
  • prepare exits with 0.

Now prepare refuses such a command with an error before anything is changed, with --dry-run too.

Devices are compared by path, so together with #134 this also covers a disk given under two names. The two PRs do not depend on each other and merge cleanly in either order.

Tested: test_resize_auto.sh and OLD=1 test_resize_auto.sh pass on loop devices. The added check fails without the fix.

Contributor Name

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

CLA

### Description `vitastor-disk prepare` collects the device list and `--fast-devices` with two separate `collect_devices()` calls, so a disk given in both gets two entries, each with its own copy of the partition table read before anything is created. The two then overwrite each other's new partitions. Seen on loop devices on master with `prepare --hybrid --fast-devices B A B` (A is 100G, B is 20G): - the OSD on A is created normally, with its journal and metadata on B; - the data partition created on B is dropped from the table when the journal and metadata partitions for it are added, and its OSD is not initialized: `Failed to open data device /dev/disk/by-partuuid/...: No such file or directory`; - B is left with two unused journal and metadata partitions; - prepare exits with 0. Now prepare refuses such a command with an error before anything is changed, with `--dry-run` too. Devices are compared by path, so together with #134 this also covers a disk given under two names. The two PRs do not depend on each other and merge cleanly in either order. Tested: `test_resize_auto.sh` and `OLD=1 test_resize_auto.sh` pass on loop devices. The added check fails without the fix. ### 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 1 commit 2026-11-20 08:03:18 +03:00
prepare collects the device list and --fast-devices separately, so a
disk given in both got two entries, each with its own copy of the
partition table, and they overwrote each other's new partitions. The
data partition of such a disk was dropped right after it was created,
its OSD was not initialized, and the journal and metadata partitions
made for it were left behind.

Refuse such a command before anything is changed.
vitalif merged commit 63f51d602f into master 2026-11-20 19:20:12 +03:00
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#135
No description provided.