Skip to content

fix(internal): only require capacity for the space an expansion adds - #496

Merged
mhkarimi1383 merged 1 commit into
openebs:developfrom
NopeCharon:fix/expand-capacity-check
Nov 7, 2026
Merged

mhkarimi1383 merged 1 commit into
openebs:developfrom
NopeCharon:fix/expand-capacity-check

Conversation

@NopeCharon

Copy link
Copy Markdown
Contributor

Fixes #494

ExpandRawFile refused an expansion unless the pool's remaining capacity could hold the volume's whole new size. get_capacity() already excludes the physical size of every volume in the pool, including the one being expanded, so the volume's existing blocks were counted twice. Once a volume was larger than the space left in its pool, it couldn't be expanded at all, even by a small amount.

Changes:

  • ExpandRawFile now compares the capacity to what the expansion really takes:
    • thin volumes: the size increase, as truncate only grows the file.
    • thick volumes: new_size minus the image's physical size, as fallocate also allocates any holes (for example in an image restored from a sparse snapshot or discarded by mkfs). Using only the size increase would let such an expansion eat into the reserved capacity.
  • tests/unit/test_internal_svc.py covers both provisioning modes, an increase that doesn't fit, and a thick image with holes.
  • docs/user-guide/resize.md and CHANGELOG.md are updated.

Testing:

  • .ci/unit.sh-equivalent run: 26 passed, 1 skipped. On macOS, so I ran pytest directly with the Linux-only _fallocate extension stubbed. CI will be the first run with the real one.
  • With only the old condition restored, the two "larger than remaining capacity" tests fail. With the size increase used for thick volumes too, the holes test fails.
  • ruff check / ruff format --check (v0.17.3, as in pre-commit) are clean.
  • I called ExpandRawFile against a real pool directory with real statvfs, get_capacity and metadata, stubbing only losetup and fallocate. For an 8MiB volume with 4MiB left, expanded to 10MiB:
    • develop: RESOURCE_EXHAUSTED, for both thin and thick.
    • This change: OK, and the image and metadata are 10MiB. With 1MiB left, it is still RESOURCE_EXHAUSTED and the volume is unchanged.

I haven't run this on a cluster, so the smoke and e2e suites are left to CI.

@NopeCharon
NopeCharon requested a review from a team as a code owner November 6, 2026 13:37
@mergify

mergify Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

ExpandRawFile refused an expansion unless the pool's remaining capacity
could hold the volume's whole new size. get_capacity() already excludes
the physical size of every volume in the pool, including the one being
expanded, so its existing blocks were counted twice. Once a volume was
larger than the space left in its pool, it could not be expanded at
all, even by a small amount.

Compare the capacity to what the expansion really takes:

- thin volumes: the size increase, as truncate only grows the file.
- thick volumes: the new size minus the image's physical size, as
  fallocate also allocates any holes (e.g. in an image restored from a
  sparse snapshot or discarded by mkfs). Using only the size increase
  would let such an expansion eat into the reserved capacity.

Fixes openebs#494

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@mhkarimi1383
mhkarimi1383 force-pushed the fix/expand-capacity-check branch from 412261d to a1c7981 Compare November 7, 2026 09:03
@mhkarimi1383
mhkarimi1383 added this pull request to the merge queue Nov 7, 2026
Merged via the queue into openebs:develop with commit 1bc9cac Nov 7, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Volume expansion fails with "Not enough disk space" when the pool can hold the added space

2 participants