Skip to content

Commit

Permalink
Add support for specifying size for Stratis filesystems
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechtrefny committed Apr 18, 2024
1 parent ca10ce1 commit b027a3f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 4 additions & 3 deletions blivetgui/blivet_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def get_children(self, blivet_device):

childs = blivet_device.children

if blivet_device.type == "lvmvg" and blivet_device.free_space > blivet.size.Size(0):
if blivet_device.type in ("lvmvg", "stratis pool") and blivet_device.free_space > blivet.size.Size(0):
childs.append(FreeSpaceDevice(blivet_device.free_space, self.storage.next_id, None, None, [blivet_device]))

return childs
Expand Down Expand Up @@ -517,7 +517,7 @@ def get_free_device(self, blivet_device):
parents=[blivet_device])
# Stratis Pool -- size of the filesystems is fixed
elif blivet_device.type == "stratis pool":
return FreeSpaceDevice(free_size=blivet.devicelibs.stratis.STRATIS_FS_SIZE,
return FreeSpaceDevice(free_size=blivet_device.free_space,
dev_id=self.storage.next_id,
start=None, end=None,
parents=[blivet_device])
Expand Down Expand Up @@ -1377,7 +1377,8 @@ def _create_stratis_filesystem(self, user_input):
user_input.size_selection.parents[0].parent_device)

new_filesystem = StratisFilesystemDevice(device_name,
parents=[i.parent_device for i in user_input.size_selection.parents])
parents=[i.parent_device for i in user_input.size_selection.parents],
size=user_input.size_selection.total_size)
new_filesystem.format = blivet.formats.get_format("stratis xfs", mountpoint=user_input.mountpoint)
actions.append(blivet.deviceaction.ActionCreateDevice(new_filesystem))
actions.append(blivet.deviceaction.ActionCreateFormat(new_filesystem))
Expand Down
10 changes: 3 additions & 7 deletions blivetgui/dialogs/add_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from gi.repository import Gtk

from blivet import size
from blivet.devicelibs import crypto, lvm, stratis
from blivet.devicelibs import crypto, lvm
from blivet.formats.fs import BTRFS
from blivet.formats.stratis import StratisBlockdev

Expand Down Expand Up @@ -718,10 +718,6 @@ def _get_max_size_limit(self):
elif self.selected_type == "lvmthinpool":
limit = min(self.selected_parent.free_space * POOL_RESERVED, limit)

if self.selected_type == "stratis filesystem":
# stratis filesystem size is always 1 TiB and unrelated to the pool size
return stratis.STRATIS_FS_SIZE

# limit from the parents maximum size
parents_limit = sum(p.max_size for p in self._get_parents())
limit = min(parents_limit, limit)
Expand Down Expand Up @@ -999,8 +995,8 @@ def on_devices_combo_changed(self, _event):
self.hide_widgets(["label", "fs", "advanced", "mdraid", "mountpoint"])

elif device_type == "stratis filesystem":
self.show_widgets(["name", "mountpoint"])
self.hide_widgets(["label", "fs", "encrypt", "size", "advanced", "mdraid"])
self.show_widgets(["name", "mountpoint", "size"])
self.hide_widgets(["label", "fs", "encrypt", "advanced", "mdraid"])

# hide "advanced" encryption widgets if encrypt not checked
self._encryption_chooser.set_advanced_visible(self._encryption_chooser.encrypt)
Expand Down
4 changes: 2 additions & 2 deletions blivetgui/list_partitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ def _add_chilren(childs, parent_iter=None):
self._add_to_store(logical, child_iter)

# lvmvg always has some children, at least a free space
elif selected_device.type == "lvmvg":
elif selected_device.type in ("lvmvg", "stratis pool"):
childs = self.blivet_gui.client.remote_call("get_children", selected_device)
_add_chilren(childs, None)

# for btrfs volumes and mdarrays its necessary to add the device itself to the view
# because these devices don't need to have children (only btrfs volume or only mdarray
# is a valid, usable device)
elif selected_device.type in ("btrfs volume", "stratis pool") or (selected_device.type == "mdarray" and not selected_device.children):
elif selected_device.type in ("btrfs volume",) or (selected_device.type == "mdarray" and not selected_device.children):
parent_iter = self._add_to_store(selected_device)
childs = self.blivet_gui.client.remote_call("get_children", selected_device)
_add_chilren(childs, parent_iter)
Expand Down

0 comments on commit b027a3f

Please sign in to comment.