From 4d66d1a757521dd2e7c4adc31f6620f04d689cd5 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Thu, 6 Jul 2023 15:41:59 +0300 Subject: [PATCH] storage: Detect unused space in Stratis pools in general --- pkg/storaged/stratis-details.jsx | 28 ++++++++++++++++++++++++++++ pkg/storaged/warnings.jsx | 3 +++ 2 files changed, 31 insertions(+) diff --git a/pkg/storaged/stratis-details.jsx b/pkg/storaged/stratis-details.jsx index 7ff56069137f..8e7d6021f030 100644 --- a/pkg/storaged/stratis-details.jsx +++ b/pkg/storaged/stratis-details.jsx @@ -20,6 +20,7 @@ import cockpit from "cockpit"; import React from "react"; +import { Alert } from "@patternfly/react-core/dist/esm/components/Alert/index.js"; import { Card, CardBody, CardHeader, CardTitle } from '@patternfly/react-core/dist/esm/components/Card/index.js'; import { DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js"; import { List, ListItem } from "@patternfly/react-core/dist/esm/components/List/index.js"; @@ -53,6 +54,14 @@ import { std_reply, with_keydesc, with_stored_passphrase } from "./stratis-utils const _ = cockpit.gettext; +export function check_stratis_warnings(client, enter_warning) { + for (const p in client.stratis_pools) { + const blockdevs = client.stratis_pool_blockdevs[p] || []; + if (blockdevs.some(bd => bd.NewPhysicalSize[0] && Number(bd.NewPhysicalSize[1]) > Number(bd.TotalPhysicalSize))) + enter_warning(p, { warning: "unused-blockdevs" }); + } +} + function teardown_block(block) { return for_each_async(block.Configuration, c => block.RemoveConfigurationItem(c, {})); } @@ -171,9 +180,27 @@ export function validate_pool_name(client, pool, name) { export const StratisPoolDetails = ({ client, pool }) => { const filesystems = client.stratis_pool_filesystems[pool.path]; + const blockdevs = client.stratis_pool_blockdevs[pool.path] || []; const forced_options = ["x-systemd.requires=stratis-fstab-setup@" + pool.Uuid + ".service"]; + function grow_blockdevs() { + return for_each_async(blockdevs, bd => pool.GrowPhysicalDevice(bd.Uuid)); + } + + let alert = null; + if (blockdevs.some(bd => bd.NewPhysicalSize[0] && Number(bd.NewPhysicalSize[1]) > Number(bd.TotalPhysicalSize))) { + alert = ( + {_("Some block devices of this pool have grown in size after the pool was created. The pool can be safely grown to use the newly available space.")} +
+ {_("Grow the pool to take all space")} +
+
); + } + function delete_() { const location = cockpit.location; const usage = get_active_usage(client, pool.path, _("delete")); @@ -640,6 +667,7 @@ export const StratisPoolDetails = ({ client, pool }) => { ); return ; diff --git a/pkg/storaged/warnings.jsx b/pkg/storaged/warnings.jsx index 78aedf5c10c9..a346d2c7fb2b 100644 --- a/pkg/storaged/warnings.jsx +++ b/pkg/storaged/warnings.jsx @@ -19,6 +19,7 @@ import { get_parent } from "./utils.js"; import { check_mismounted_fsys } from "./fsys-tab.jsx"; +import { check_stratis_warnings } from "./stratis-details.jsx"; export function find_warnings(client) { const path_warnings = { }; @@ -104,5 +105,7 @@ export function find_warnings(client) { check_mismounted_fsys(client, path, enter_warning); } + check_stratis_warnings(client, enter_warning); + return path_warnings; }