Skip to content

Commit

Permalink
storage: Resize Stratis blockdevs together with logical volumes
Browse files Browse the repository at this point in the history
Just like we already did for filesystems and VDO.
  • Loading branch information
mvollmer committed Aug 23, 2023
1 parent 10e719f commit 9dca11d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/storaged/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 23 additions & 0 deletions pkg/storaged/lvol-tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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];
Expand All @@ -69,13 +71,15 @@ 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
crypto_overhead = block.Size - cleartext.Size;
} 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;
}

Expand Down Expand Up @@ -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."));
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions pkg/storaged/warnings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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) {
Expand Down

0 comments on commit 9dca11d

Please sign in to comment.