8000 volume: Extend raw sparse by aesteve-rh · Pull Request #390 · oVirt/vdsm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

volume: Extend raw sparse #390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/vdsm/storage/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -1380,9 +1380,10 @@ def extendSize(self, new_capacity):
if self.isShared():
raise se.VolumeNonWritable(self.volUUID)

if self.getType() == sc.SPARSE_VOL:
self.log.debug("skipping sparse size extension for volume %s to "
"capacity %s", self.volUUID, new_capacity)
if (self.getFormat() == sc.COW_FORMAT and
self.getType() == sc.SPARSE_VOL):
self.log.debug("skipping cow sparse size extension for volume %s "
"to capacity %s", self.volUUID, new_capacity)
return

# Note: This function previously prohibited extending non-leaf volumes.
Expand Down
35 changes: 35 additions & 0 deletions tests/storage/filevolume_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,41 @@ def test_volume_size_unaligned(monkeypatch, tmpdir, tmp_repo, fake_access,
assert vol.getCapacity() == expected_vol_capacity


def test_extend_volume(tmp_repo, fake_access, fake_task):
"""
Test added to verify fix for https://bugzilla.redhat.com/2210036.
RAW sparse volumes should be extended on command (apparentsize
metadata value shall be updated).
"""
dom = tmp_repo.create_localfs_domain(name="domain", version=5)

img_uuid = str(uuid.uuid4())
vol_uuid = str(uuid.uuid4())
vol_capacity = 3 * GiB
new_capacity = 5 * GiB

dom.createVolume(
imgUUID=img_uuid,
capacity=vol_capacity,
volFormat=sc.RAW_FORMAT,
preallocate=sc.SPARSE_VOL,
diskType=sc.DATA_DISKTYPE,
volUUID=vol_uuid,
desc="Test volume",
srcImgUUID=sc.BLANK_UUID,
srcVolUUID=sc.BLANK_UUID)

# Produce and extend volume to the new capacity.
vol = dom.produceVolume(img_uuid, vol_uuid)
pre_vol_size = dom.getVolumeSize(img_uuid, vol_uuid)
vol.extendSize(new_capacity)

# Check that volume apparent size has changed.
vol_size = dom.getVolumeSize(img_uuid, vol_uuid)
assert vol_size.truesize == pre_vol_size.truesize
assert vol_size.apparentsize == new_capacity


MD_WITH_PARENT = b"""\
CAP=46137344
CTIME=1557522135
Expand Down
0