openzfs/zfs

Fix the ambiguous units in OpenZFS

Open

#11,046 opened on Oct 10, 2020

View on GitHub
 (16 comments) (16 reactions) (0 assignees)C (9,908 stars) (1,703 forks)batch import
Type: Defectgood first issue

Description

The issue I just saw a bug report that contained the output of a ‘zpool status’ command and realised that the units are actually oddly ambiguous for a filesystem. "2.84T scanned at 586M/s, 852G issued at 172M/s, 9.52T total”.

SI defines prefixes such as the T as tera (1012), the G as giga (109) and the M as mega (106) but that should be followed by the actual unit. That unit is missing here.

It’s obvious that OpenZFS is not reporting Megawatts or Terahertz. It is, however, not clear whether it actually means TB or TiB, GB or GiB and MB or MiB. Is “172M/s” 172 Megabyte or Megabit per second? If I have a file that is reported to be 0.98GiB in Nautilus, will that fit on a dataset that ‘zfs list’ reports as having “1G” available? And a file that mac OS Finder reports as being 1GB?

What should the actual unit be here, MB (10002) and equivalents or MiB (10242) and equivalents? With the size of modern day data sets the 7% difference between the two is getting quite big in actual sizes and it’s important for a file system to report this correctly. People can currently come across unclear mismatches between GUIs and the CLI or between various operating systems.

The solution Microsoft has made quite a mess with this on Windows by pairing 10242 values with 10002 units, showing everyone how not to do it (https://www.nextofwindows.com/gb-gigabyte-and-mb-megabyte-is-not-what-you-think-is-in-windows). Fortunately macOS solved the issue in 2007 (https://support.apple.com/en-us/HT201402), Debian in 2009 (https://wiki.debian.org/ConsistentUnitPrefixes), Ubuntu in 2010 (https://wiki.ubuntu.com/UnitsPolicy). Linux now has a man page dedicated to units (https://man7.org/linux/man-pages/man7/units.7.html)

Some higher level applications such as Nautilus, XigmaNAS, TrueNAS etc. have dealt with this by opting for IEC units and values, Finder in macOS has opted for SI units and values. Personally I don’t care if the displayed unit is MB or MiB as long as it’s the correct unit to go with the actual value.

Is it time to make this less ambiguous and replace T, G and M for the correct units throughout the OpenZFS code? Perhaps as a goal for v3.0?

Contributor guide