Skip to content

Commit 8a961f8

Browse files
committed
storage/zfs: support shrinking volumes
1 parent 5ca3b70 commit 8a961f8

1 file changed

Lines changed: 3 additions & 26 deletions

File tree

qubes/storage/zfs.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,11 +1412,9 @@ async def resize_volume_async(
14121412
log: logging.Logger,
14131413
) -> None:
14141414
"""
1415-
Enlarge a volume to the specified size.
1415+
Resize a volume to the specified size.
14161416
14171417
The volume must exist.
1418-
1419-
An error will be raised if size is < current size.
14201418
"""
14211419
assert dataset_in_root(volume, self.root)
14221420
async with self._cache.locked():
@@ -2681,33 +2679,12 @@ def is_dirty(self) -> bool:
26812679
@qubes.storage.Volume.locked # type: ignore
26822680
async def resize(self, size: int) -> None:
26832681
"""
2684-
Expands volume.
2685-
2686-
Throws
2687-
:py:class:`qubst.storage.qubes.storage.StoragePoolException` if
2688-
given size is less than current_size.
2689-
"""
2690-
# FIXME: there does not seem to be a pathway to, but there
2691-
# should be a pathway to, reducing the storage size of a
2692-
# volume, whether it be by having to stop the VM first and
2693-
# then making a non-atomic clone / partial copy / rename
2694-
# of a zvol. It is annoying that ZFS prevents volumes from
2695-
# being reduced in size. It is further annoying that
2696-
# reduction of a volume requires the file system in it to
2697-
# be reduced first, which can only be done while the qube
2698-
# is running, but a Towers-of-Hanoi operation with datasets
2699-
# can only be performed with the qube off. Perhaps in the
2700-
# future we can have a qvm feature exposed that allows dom0
2701-
# to coordinate shrinking the file system and defers the
2702-
# Towers-of-Hanoi operation to after the qube has powered off.
2682+
Resizes volume.
2683+
"""
27032684
self.log.debug("Resizing %s to %s", self.volume, size)
27042685
mysize = self.size
27052686
if size == mysize:
27062687
return
2707-
if size < mysize:
2708-
raise qubes.exc.StoragePoolException(
2709-
"Shrinking of ZFS volume %s is not possible" % (self.volume,)
2710-
)
27112688
if await self.pool.accessor.volume_exists_async(
27122689
self.volume,
27132690
log=self.log,

0 commit comments

Comments
 (0)