diff --git a/pkg/storaged/client.js b/pkg/storaged/client.js index 615503a21e1b..1f12efb8c693 100644 --- a/pkg/storaged/client.js +++ b/pkg/storaged/client.js @@ -1020,6 +1020,7 @@ function stratis3_start() { client.features.stratis_crypto_binding = true; client.features.stratis_encrypted_caches = true; client.features.stratis_managed_fsys_sizes = true; + client.features.stratis_grow_blockdevs = true; client.stratis_pools = client.stratis_manager.client.proxies("org.storage.stratis3.pool." + stratis3_interface_revision, "/org/storage/stratis3", diff --git a/pkg/storaged/lvol-tabs.jsx b/pkg/storaged/lvol-tabs.jsx index 6a8962b06b50..65e0ad67d016 100644 --- a/pkg/storaged/lvol-tabs.jsx +++ b/pkg/storaged/lvol-tabs.jsx @@ -33,6 +33,7 @@ import { dialog_open, TextInput, SizeSlider, BlockingMessage, TeardownMessage, init_active_usage_processes } from "./dialog.jsx"; +import { std_reply } from "./stratis-utils.js"; const _ = cockpit.gettext; @@ -56,6 +57,7 @@ function lvol_and_fsys_resize(client, lvol, size, offline, passphrase) { let fsys; let crypto_overhead; let vdo; + let stratis_bdev; const orig_size = lvol.Size; const block = client.lvols_block[lvol.path]; @@ -69,6 +71,7 @@ function lvol_and_fsys_resize(client, lvol, size, offline, passphrase) { return; fsys = client.blocks_fsys[cleartext.path]; vdo = client.legacy_vdo_overlay.find_by_backing_block(cleartext); + stratis_bdev = client.blocks_stratis_blockdev[cleartext.path]; if (crypto.MetadataSize !== undefined) crypto_overhead = crypto.MetadataSize; else @@ -76,6 +79,7 @@ function lvol_and_fsys_resize(client, lvol, size, offline, passphrase) { } else { fsys = client.blocks_fsys[block.path]; vdo = client.legacy_vdo_overlay.find_by_backing_block(block); + stratis_bdev = client.blocks_stratis_blockdev[block.path]; crypto_overhead = 0; } @@ -110,6 +114,14 @@ function lvol_and_fsys_resize(client, lvol, size, offline, passphrase) { return Promise.reject(_("VDO backing devices can not be made smaller")); else return Promise.resolve(); + } else if (stratis_bdev) { + if (size - crypto_overhead > Number(stratis_bdev.TotalPhysicalSize)) { + const pool = client.stratis_pools[stratis_bdev.Pool]; + return pool.GrowPhysicalDevice(stratis_bdev.Uuid).then(std_reply); + } else if (size - crypto_overhead < Number(stratis_bdev.TotalPhysicalSize)) + return Promise.reject(_("Stratis blockdevs can not be made smaller")); + else + return Promise.resolve(); } else if (size < orig_size) { // This shouldn't happen. But if it does, continuing is harmful, so we throw an error. return Promise.reject(_("Unrecognized data can not be made smaller here.")); @@ -185,6 +197,13 @@ function get_resize_info(client, block, to_fit) { grow_excuse = cockpit.format(_("$0 filesystems can not be made larger."), block.IdType); } + } else if (client.blocks_stratis_blockdev[block.path] && client.features.stratis_grow_blockdevs) { + info = { + can_shrink: false, + can_grow: true, + grow_needs_unmount: false + }; + shrink_excuse = _("Stratis blockdevs can not be made smaller"); } else if (block.IdUsage == 'raid') { info = { }; shrink_excuse = grow_excuse = _("Physical volumes can not be resized here."); @@ -331,6 +350,10 @@ function lvol_shrink(client, lvol, info, to_fit) { if (vdo) shrink_size = vdo.physical_size + crypto_overhead; + const stratis_bdev = client.blocks_stratis_blockdev[content_path]; + if (stratis_bdev) + shrink_size = Number(stratis_bdev.TotalPhysicalSize) + crypto_overhead; + if (shrink_size === undefined) { console.warn("Couldn't determine size to shrink to."); return; diff --git a/pkg/storaged/warnings.jsx b/pkg/storaged/warnings.jsx index a35312362c58..78aedf5c10c9 100644 --- a/pkg/storaged/warnings.jsx +++ b/pkg/storaged/warnings.jsx @@ -72,6 +72,7 @@ export function find_warnings(client) { const fsys = client.blocks_fsys[content_path]; const content_block = client.blocks[content_path]; const vdo = content_block ? client.legacy_vdo_overlay.find_by_backing_block(content_block) : null; + const stratis_bdev = client.blocks_stratis_blockdev[content_path]; if (fsys && fsys.Size && (lvol.Size - fsys.Size - crypto_overhead) > vgroup.ExtentSize && fsys.Resize) { enter_warning(path, { @@ -88,6 +89,14 @@ export function find_warnings(client) { content_size: vdo.physical_size }); } + + if (stratis_bdev && (lvol.Size - Number(stratis_bdev.TotalPhysicalSize) - crypto_overhead) > vgroup.ExtentSize) { + enter_warning(path, { + warning: "unused-space", + volume_size: lvol.Size - crypto_overhead, + content_size: Number(stratis_bdev.TotalPhysicalSize) + }); + } } for (const path in client.blocks) {