cli, client: Refuse layer chains that mix bitmap_granularity #171

Open
koolkhel wants to merge 1 commits from koolkhel/vitastor:layer-granularity into master
Contributor

Description

Reads through a layer chain whose pools differ in bitmap_granularity merge the layer bitmaps in the wrong unit. A read through such a parent returns parent data over the child's, and an untouched read that isn't aligned to a coarser parent's granularity aborts the client on assert(left == 0) in add_iov().

This forbids such chains instead of supporting them:

  • vitastor-cli refuses create --parent, snap-create -p, merge-data, flatten and rm (when it has to merge a layer into its child) if they would create or merge a chain across pools with different bitmap_granularity, with an error naming both pools, before anything is written. rm checks every child before marking layers deleted, so a refused rm leaves the chain as it was.
  • The client fails a read through such a parent with -EINVAL unless the child covers the whole range (then the parent isn't read), or covers none of it and the range is aligned to the parent's granularity (then the whole range is read from the parent as before). Chains with equal granularity, including all same-pool chains, behave as before.
  • Help text and docs/usage/cli, docs/config/pool state the rule.

Not covered: an existing chain that already mixes granularities has no migration path (merge/flatten are refused, and chain-bitmap reads such as a sparse dd fail even on untouched ranges). The check walks the whole chain, so a same-pool snap-create of such an image is refused too.

Tested: test_cluster_client (new test_parent_granularity_mismatch, run as a 4096 child over a 512 parent and a 512 child over a 4096 parent; both fail without the client change), new tests/test_layer_pools.sh (refusals of create/snap-create/merge/rm, migration across block sizes and EC/replicated pools), added to run_tests.sh and the CI workflow.

Contributor Name

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

CLA

### Description Reads through a layer chain whose pools differ in `bitmap_granularity` merge the layer bitmaps in the wrong unit. A read through such a parent returns parent data over the child's, and an untouched read that isn't aligned to a coarser parent's granularity aborts the client on `assert(left == 0)` in `add_iov()`. This forbids such chains instead of supporting them: - `vitastor-cli` refuses `create --parent`, `snap-create -p`, `merge-data`, `flatten` and `rm` (when it has to merge a layer into its child) if they would create or merge a chain across pools with different `bitmap_granularity`, with an error naming both pools, before anything is written. `rm` checks every child before marking layers deleted, so a refused `rm` leaves the chain as it was. - The client fails a read through such a parent with `-EINVAL` unless the child covers the whole range (then the parent isn't read), or covers none of it and the range is aligned to the parent's granularity (then the whole range is read from the parent as before). Chains with equal granularity, including all same-pool chains, behave as before. - Help text and `docs/usage/cli`, `docs/config/pool` state the rule. Not covered: an existing chain that already mixes granularities has no migration path (merge/flatten are refused, and chain-bitmap reads such as a sparse `dd` fail even on untouched ranges). The check walks the whole chain, so a same-pool `snap-create` of such an image is refused too. Tested: `test_cluster_client` (new `test_parent_granularity_mismatch`, run as a 4096 child over a 512 parent and a 512 child over a 4096 parent; both fail without the client change), new `tests/test_layer_pools.sh` (refusals of create/snap-create/merge/rm, migration across block sizes and EC/replicated pools), added to `run_tests.sh` and the CI workflow. ### 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-24 08:17:52 +03:00
Reads through a layer chain whose pools differ in bitmap_granularity merge
layer bitmaps in the wrong unit: they return parent data over the child's
or abort the client. Refuse to create or merge such chains in vitastor-cli
(create --parent, snap-create -p, merge-data, flatten, rm), and fail a
read through such a parent unless the child covers the whole range or
covers none of it and the range is aligned to the parent's granularity.
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 layer-granularity:koolkhel-layer-granularity
git checkout koolkhel-layer-granularity
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#171
No description provided.