Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1970119

Summary: Cockpit Storage: Show base-10 units by default
Product: Red Hat Enterprise Linux 8 Reporter: Jonathan Earl Brassow <jbrassow>
Component: cockpit-appstreamAssignee: Martin Pitt <mpitt>
Status: CLOSED ERRATA QA Contact: Jan Ščotka <jscotka>
Severity: low Docs Contact:
Priority: low    
Version: 8.0CC: mmarusak, mpitt, nyewale
Target Milestone: betaKeywords: Reopened, Triaged
Target Release: 8.7Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: cockpit-appstream-269-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-08 09:38:48 UTC Type: Feature Request
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
image of problem none

Description Jonathan Earl Brassow 2021-06-09 20:15:55 UTC
Volume Group capacity is given in powers of 10

Logical volumes are given in powers of 2 (with incorrect 'iB' label).

Comment 1 Jonathan Earl Brassow 2021-06-09 20:18:45 UTC
Created attachment 1789653 [details]
image of problem

Comment 2 Martin Pitt 2021-06-11 13:23:04 UTC
Agreed -- The storage world mostly uses base-10 units now, let's make it consistently so. I think the only place where base-2 makes sense is (total) RAM size.

Comment 14 Martin Pitt 2021-08-31 06:17:49 UTC
> Logical volumes are given in powers of 2 (with incorrect 'iB' label).

For the record: this is *not* incorrect, it's the official unit name of base-2 units (KiB, MiB, etc.). It would be just plain wrong to label a base-2 unit with "MB". The page currently does show consistent numbers and units, and often it shows both base-2 and base-10 units at the same place. So this is not wrong, it's just a matter of opinion which units to display (and I'm afraid that's a topic which is very hard to get agreement on 😀)

I would be fine with always just showing base-10 units. Physical storage devices have been labelled with base-10 units for many many years by now. However, Marius rightfully points out that this may confuse a different set of people who are still being used to seeing base-2 units.

Comment 15 Nitin U. Yewale 2021-08-31 11:36:05 UTC
Agree. common lvm commands like pvs, vgs, lvs display size in base2 unit.

For Volume groups, sizes are being displayed in both formats. 

>> Logical volumes are given in powers of 2 (with incorrect 'iB' label).

GiB = 2 to the 30th power (1,073,741,824) bytes (base 2) 
GB = 10 to the 9th power (1,000,000,000) bytes (base 10)

Comment 16 Nitin U. Yewale 2021-08-31 18:06:27 UTC
No changes are needed other than the attached proposed patches for the raid devices and nfs mounts.

Please see attached screenshot -  raid_and_nfs.png

At some places size is being shown is both units. In case that needs to be changed, we need to replace `fmt_size_long` with `fmt_size`. Example changes could be seen for the size of the VG.

In all following changes have been made so far and based on what features we need (do not need), need modifications in below patch


# git diff main
diff --git a/pkg/storaged/block-details.jsx b/pkg/storaged/block-details.jsx
index 0c37dc1db..e59166e1c 100644
--- a/pkg/storaged/block-details.jsx
+++ b/pkg/storaged/block-details.jsx
@@ -46,7 +46,7 @@ export class BlockDetails extends React.Component {
                     <DescriptionList className="pf-m-horizontal-on-sm">
                         <DescriptionListGroup>
                             <DescriptionListTerm>{_("storage", "Capacity")}</DescriptionListTerm>
-                            <DescriptionListDescription>{ utils.fmt_size_long(block.Size) }</DescriptionListDescription>
+                            <DescriptionListDescription>{ utils.fmt_size(block.Size) }</DescriptionListDescription>
                         </DescriptionListGroup>
                         <DescriptionListGroup>
                             <DescriptionListTerm>{_("storage", "Device file")}</DescriptionListTerm>
diff --git a/pkg/storaged/drive-details.jsx b/pkg/storaged/drive-details.jsx
index ab7c9b295..e53c06561 100644
--- a/pkg/storaged/drive-details.jsx
+++ b/pkg/storaged/drive-details.jsx
@@ -81,7 +81,7 @@ export class DriveDetails extends React.Component {
                         <DriveDetailsRow title={_("storage", "Firmware version")} value={drive.Revision} />
                         <DriveDetailsRow title={_("storage", "Serial number")} value={drive.Serial} />
                         <DriveDetailsRow title={_("storage", "World wide name")} value={drive.WWN} />
-                        <DriveDetailsRow title={_("storage", "Capacity")} value={drive.Size ? utils.fmt_size_long(drive.Size) : _("No media inserted")} />
+                        <DriveDetailsRow title={_("storage", "Capacity")} value={drive.Size ? utils.fmt_size(drive.Size) : _("No media inserted")} />
                         { assessment }
                         <DriveDetailsRow title={_("storage", "Device file")} value={drive_block ? utils.block_name(drive_block) : "-"} />
                         {multipath_blocks.length > 0 && (
diff --git a/pkg/storaged/utils.js b/pkg/storaged/utils.js
index 4a091f5b9..edda5bd8f 100644
--- a/pkg/storaged/utils.js
+++ b/pkg/storaged/utils.js
@@ -85,7 +85,7 @@ export function encode_filename(decoded) {
 }
 
 export function fmt_size(bytes) {
-    return cockpit.format_bytes(bytes, 1024);
+    return cockpit.format_bytes(bytes, 1000);
 }
 
 export function fmt_size_long(bytes) {
@@ -107,7 +107,7 @@ export function format_temperature(kelvin) {
 
 export function format_fsys_usage(used, total) {
     var text = "";
-    var units = 1024;
+    var units = 1000;
     var parts = cockpit.format_bytes(total, units, true);
     text = " / " + parts.join(" ");
     units = parts[1];
diff --git a/pkg/storaged/vgroup-details.jsx b/pkg/storaged/vgroup-details.jsx
index 75ede2dbc..90eaad274 100644
--- a/pkg/storaged/vgroup-details.jsx
+++ b/pkg/storaged/vgroup-details.jsx
@@ -234,7 +234,7 @@ export class VGroupDetails extends React.Component {
 
                         <DescriptionListGroup>
                             <DescriptionListTerm>{_("storage", "Capacity")}</DescriptionListTerm>
-                            <DescriptionListDescription>{ utils.fmt_size_long(vgroup.Size) }</DescriptionListDescription>
+                            <DescriptionListDescription>{ utils.fmt_size(vgroup.Size) }</DescriptionListDescription>
                         </DescriptionListGroup>
                     </DescriptionList>
                 </CardBody>
(END)


Thank you,
Nitin Yewale

Comment 18 Nitin U. Yewale 2021-09-01 13:05:39 UTC
Final changes have been mentioned in comment #16. All changes may or may not be needed. Please suggest on next action.

Thank you,
Nitin Yewale

Comment 19 Jonathan Earl Brassow 2021-09-02 13:51:47 UTC
(In reply to Nitin Yewale from comment #18)
> Final changes have been mentioned in comment #16. All changes may or may not
> be needed. Please suggest on next action.
> 
> Thank you,
> Nitin Yewale

thanks for looking at this.  If sizes are consistently reported, then I am happy.  I don't particularly care if it is pow2 or pow10.

Also, sorry about getting 'B' and 'iB' backwards in the initial description.  :)

Comment 20 Marius Vollmer 2022-02-14 08:42:59 UTC
(In reply to Martin Pitt from comment #2)
> The storage world mostly uses base-10 units now, let's make it
> consistently so.

But is this really true?  lsblk, vgs, "ls -lh", "du -h" all use powers of 1024 by default (without being explicit about it).  "1M" means 1024*1024 to dd.

I am not convinced that switching to powers of 1000 instead of 1024 in Cockpit is motivated enough.  The storage world is a mess, and trying to align with it might just mean that we change Cockpit from "MB" to "MiB" and back again every couple of years.

But GNOME Disks uses 1000s.  This is a strong argument to also use 1000s in Cockpit: alignment with GNOME, to reuse their UX experience.

Cockpits Metrics page is a bit inconsistent, showing available RAM in 1024s and used RAM in 1000s. and disk IO rates in 1024s and free space in 1000s.  The servies page shows used RAM in 1024s.  Cockpit-podman uses 1000s, except for memory usage and limits of containers, where it used 1024s.  Cockpit-machines uses 1024s.

In any case, I don't see this as a bug.  Cockpit uses the units correctly.

Comment 21 Martin Pitt 2022-03-02 14:37:22 UTC
We re-discussed that in our team meeting, and we eventually decided to switch all units in cockpit to base-10, with the exception of the total memory size on the overview. The other exception is the individual RAM DIMM bars on the hardware information page, as (1) we just parrot the information from dmidecode, and (2) these have a natural base-2 unit and are sold that way.

Comment 23 Martin Pitt 2022-03-22 06:38:14 UTC
I recently worked on a lot of unit cleanup in cockpit, and https://github.com/cockpit-project/cockpit/pull/17163 is the final piece of this. (This is more generic than the initially proposed patch here)

Comment 30 errata-xmlrpc 2022-11-08 09:38:48 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (cockpit-appstream bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7554