|
|
5bf14f |
From 42e641abeb312a91b841f1b1ea73661e4bd5a31c Mon Sep 17 00:00:00 2001
|
|
|
5bf14f |
From: Kinga Tanska <kinga.tanska@intel.com>
|
|
|
5bf14f |
Date: Tue, 21 Jan 2020 10:38:52 +0100
|
|
|
5bf14f |
Subject: [RHEL7.9 PATCH 57/71] Add support for Tebibytes
|
|
|
5bf14f |
|
|
|
5bf14f |
Adding support for Tebibytes enables display size of
|
|
|
5bf14f |
volumes in Tebibytes and Terabytes when they are
|
|
|
5bf14f |
bigger than 2048 GiB (or GB).
|
|
|
5bf14f |
|
|
|
5bf14f |
Signed-off-by: Kinga Tanska <kinga.tanska@intel.com>
|
|
|
5bf14f |
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
|
5bf14f |
---
|
|
|
5bf14f |
mdadm.8.in | 20 ++++++++++----------
|
|
|
5bf14f |
util.c | 47 +++++++++++++++++++++++++++++++++--------------
|
|
|
5bf14f |
2 files changed, 43 insertions(+), 24 deletions(-)
|
|
|
5bf14f |
|
|
|
5bf14f |
diff --git a/mdadm.8.in b/mdadm.8.in
|
|
|
5bf14f |
index ca02a33..5d00faf 100644
|
|
|
5bf14f |
--- a/mdadm.8.in
|
|
|
5bf14f |
+++ b/mdadm.8.in
|
|
|
5bf14f |
@@ -467,8 +467,8 @@ If this is not specified
|
|
|
5bf14f |
size, though if there is a variance among the drives of greater than 1%, a warning is
|
|
|
5bf14f |
issued.
|
|
|
5bf14f |
|
|
|
5bf14f |
-A suffix of 'K', 'M' or 'G' can be given to indicate Kilobytes, Megabytes or
|
|
|
5bf14f |
-Gigabytes respectively.
|
|
|
5bf14f |
+A suffix of 'K', 'M', 'G' or 'T' can be given to indicate Kilobytes,
|
|
|
5bf14f |
+Megabytes, Gigabytes or Terabytes respectively.
|
|
|
5bf14f |
|
|
|
5bf14f |
Sometimes a replacement drive can be a little smaller than the
|
|
|
5bf14f |
original drives though this should be minimised by IDEMA standards.
|
|
|
5bf14f |
@@ -532,8 +532,8 @@ problems the array can be made bigger again with no loss with another
|
|
|
5bf14f |
.B "\-\-grow \-\-array\-size="
|
|
|
5bf14f |
command.
|
|
|
5bf14f |
|
|
|
5bf14f |
-A suffix of 'K', 'M' or 'G' can be given to indicate Kilobytes, Megabytes or
|
|
|
5bf14f |
-Gigabytes respectively.
|
|
|
5bf14f |
+A suffix of 'K', 'M', 'G' or 'T' can be given to indicate Kilobytes,
|
|
|
5bf14f |
+Megabytes, Gigabytes or Terabytes respectively.
|
|
|
5bf14f |
A value of
|
|
|
5bf14f |
.B max
|
|
|
5bf14f |
restores the apparent size of the array to be whatever the real
|
|
|
5bf14f |
@@ -551,8 +551,8 @@ This is only meaningful for RAID0, RAID4, RAID5, RAID6, and RAID10.
|
|
|
5bf14f |
RAID4, RAID5, RAID6, and RAID10 require the chunk size to be a power
|
|
|
5bf14f |
of 2. In any case it must be a multiple of 4KB.
|
|
|
5bf14f |
|
|
|
5bf14f |
-A suffix of 'K', 'M' or 'G' can be given to indicate Kilobytes, Megabytes or
|
|
|
5bf14f |
-Gigabytes respectively.
|
|
|
5bf14f |
+A suffix of 'K', 'M', 'G' or 'T' can be given to indicate Kilobytes,
|
|
|
5bf14f |
+Megabytes, Gigabytes or Terabytes respectively.
|
|
|
5bf14f |
|
|
|
5bf14f |
.TP
|
|
|
5bf14f |
.BR \-\-rounding=
|
|
|
5bf14f |
@@ -767,8 +767,8 @@ When using an
|
|
|
5bf14f |
bitmap, the chunksize defaults to 64Meg, or larger if necessary to
|
|
|
5bf14f |
fit the bitmap into the available space.
|
|
|
5bf14f |
|
|
|
5bf14f |
-A suffix of 'K', 'M' or 'G' can be given to indicate Kilobytes, Megabytes or
|
|
|
5bf14f |
-Gigabytes respectively.
|
|
|
5bf14f |
+A suffix of 'K', 'M', 'G' or 'T' can be given to indicate Kilobytes,
|
|
|
5bf14f |
+Megabytes, Gigabytes or Terabytes respectively.
|
|
|
5bf14f |
|
|
|
5bf14f |
.TP
|
|
|
5bf14f |
.BR \-W ", " \-\-write\-mostly
|
|
|
5bf14f |
@@ -857,8 +857,8 @@ an array which was originally created using a different version of
|
|
|
5bf14f |
which computed a different offset.
|
|
|
5bf14f |
|
|
|
5bf14f |
Setting the offset explicitly over-rides the default. The value given
|
|
|
5bf14f |
-is in Kilobytes unless a suffix of 'K', 'M' or 'G' is used to explicitly
|
|
|
5bf14f |
-indicate Kilobytes, Megabytes or Gigabytes respectively.
|
|
|
5bf14f |
+is in Kilobytes unless a suffix of 'K', 'M', 'G' or 'T' is used to explicitly
|
|
|
5bf14f |
+indicate Kilobytes, Megabytes, Gigabytes or Terabytes respectively.
|
|
|
5bf14f |
|
|
|
5bf14f |
Since Linux 3.4,
|
|
|
5bf14f |
.B \-\-data\-offset
|
|
|
5bf14f |
diff --git a/util.c b/util.c
|
|
|
5bf14f |
index 64dd409..07f9dc3 100644
|
|
|
5bf14f |
--- a/util.c
|
|
|
5bf14f |
+++ b/util.c
|
|
|
5bf14f |
@@ -389,7 +389,7 @@ int mdadm_version(char *version)
|
|
|
5bf14f |
unsigned long long parse_size(char *size)
|
|
|
5bf14f |
{
|
|
|
5bf14f |
/* parse 'size' which should be a number optionally
|
|
|
5bf14f |
- * followed by 'K', 'M', or 'G'.
|
|
|
5bf14f |
+ * followed by 'K', 'M'. 'G' or 'T'.
|
|
|
5bf14f |
* Without a suffix, K is assumed.
|
|
|
5bf14f |
* Number returned is in sectors (half-K)
|
|
|
5bf14f |
* INVALID_SECTORS returned on error.
|
|
|
5bf14f |
@@ -411,6 +411,10 @@ unsigned long long parse_size(char *size)
|
|
|
5bf14f |
c++;
|
|
|
5bf14f |
s *= 1024 * 1024 * 2;
|
|
|
5bf14f |
break;
|
|
|
5bf14f |
+ case 'T':
|
|
|
5bf14f |
+ c++;
|
|
|
5bf14f |
+ s *= 1024 * 1024 * 1024 * 2LL;
|
|
|
5bf14f |
+ break;
|
|
|
5bf14f |
case 's': /* sectors */
|
|
|
5bf14f |
c++;
|
|
|
5bf14f |
break;
|
|
|
5bf14f |
@@ -893,13 +897,14 @@ char *human_size(long long bytes)
|
|
|
5bf14f |
{
|
|
|
5bf14f |
static char buf[47];
|
|
|
5bf14f |
|
|
|
5bf14f |
- /* We convert bytes to either centi-M{ega,ibi}bytes or
|
|
|
5bf14f |
- * centi-G{igi,ibi}bytes, with appropriate rounding,
|
|
|
5bf14f |
- * and then print 1/100th of those as a decimal.
|
|
|
5bf14f |
+ /* We convert bytes to either centi-M{ega,ibi}bytes,
|
|
|
5bf14f |
+ * centi-G{igi,ibi}bytes or centi-T{era,ebi}bytes
|
|
|
5bf14f |
+ * with appropriate rounding, and then print
|
|
|
5bf14f |
+ * 1/100th of those as a decimal.
|
|
|
5bf14f |
* We allow upto 2048Megabytes before converting to
|
|
|
5bf14f |
- * gigabytes, as that shows more precision and isn't
|
|
|
5bf14f |
+ * gigabytes and 2048Gigabytes before converting to
|
|
|
5bf14f |
+ * terabytes, as that shows more precision and isn't
|
|
|
5bf14f |
* too large a number.
|
|
|
5bf14f |
- * Terabytes are not yet handled.
|
|
|
5bf14f |
*/
|
|
|
5bf14f |
|
|
|
5bf14f |
if (bytes < 5000*1024)
|
|
|
5bf14f |
@@ -909,11 +914,16 @@ char *human_size(long long bytes)
|
|
|
5bf14f |
long cMB = (bytes / ( 1000000LL / 200LL ) +1) /2;
|
|
|
5bf14f |
snprintf(buf, sizeof(buf), " (%ld.%02ld MiB %ld.%02ld MB)",
|
|
|
5bf14f |
cMiB/100, cMiB % 100, cMB/100, cMB % 100);
|
|
|
5bf14f |
- } else {
|
|
|
5bf14f |
+ } else if (bytes < 2*1024LL*1024LL*1024LL*1024LL) {
|
|
|
5bf14f |
long cGiB = (bytes * 200LL / (1LL<<30) +1) / 2;
|
|
|
5bf14f |
long cGB = (bytes / (1000000000LL/200LL ) +1) /2;
|
|
|
5bf14f |
snprintf(buf, sizeof(buf), " (%ld.%02ld GiB %ld.%02ld GB)",
|
|
|
5bf14f |
cGiB/100, cGiB % 100, cGB/100, cGB % 100);
|
|
|
5bf14f |
+ } else {
|
|
|
5bf14f |
+ long cTiB = (bytes * 200LL / (1LL<<40) + 1) / 2;
|
|
|
5bf14f |
+ long cTB = (bytes / (1000000000000LL / 200LL) + 1) / 2;
|
|
|
5bf14f |
+ snprintf(buf, sizeof(buf), " (%ld.%02ld TiB %ld.%02ld TB)",
|
|
|
5bf14f |
+ cTiB/100, cTiB % 100, cTB/100, cTB % 100);
|
|
|
5bf14f |
}
|
|
|
5bf14f |
return buf;
|
|
|
5bf14f |
}
|
|
|
5bf14f |
@@ -922,13 +932,14 @@ char *human_size_brief(long long bytes, int prefix)
|
|
|
5bf14f |
{
|
|
|
5bf14f |
static char buf[30];
|
|
|
5bf14f |
|
|
|
5bf14f |
- /* We convert bytes to either centi-M{ega,ibi}bytes or
|
|
|
5bf14f |
- * centi-G{igi,ibi}bytes, with appropriate rounding,
|
|
|
5bf14f |
- * and then print 1/100th of those as a decimal.
|
|
|
5bf14f |
+ /* We convert bytes to either centi-M{ega,ibi}bytes,
|
|
|
5bf14f |
+ * centi-G{igi,ibi}bytes or centi-T{era,ebi}bytes
|
|
|
5bf14f |
+ * with appropriate rounding, and then print
|
|
|
5bf14f |
+ * 1/100th of those as a decimal.
|
|
|
5bf14f |
* We allow upto 2048Megabytes before converting to
|
|
|
5bf14f |
- * gigabytes, as that shows more precision and isn't
|
|
|
5bf14f |
+ * gigabytes and 2048Gigabytes before converting to
|
|
|
5bf14f |
+ * terabytes, as that shows more precision and isn't
|
|
|
5bf14f |
* too large a number.
|
|
|
5bf14f |
- * Terabytes are not yet handled.
|
|
|
5bf14f |
*
|
|
|
5bf14f |
* If prefix == IEC, we mean prefixes like kibi,mebi,gibi etc.
|
|
|
5bf14f |
* If prefix == JEDEC, we mean prefixes like kilo,mega,giga etc.
|
|
|
5bf14f |
@@ -941,10 +952,14 @@ char *human_size_brief(long long bytes, int prefix)
|
|
|
5bf14f |
long cMiB = (bytes * 200LL / (1LL<<20) +1) /2;
|
|
|
5bf14f |
snprintf(buf, sizeof(buf), "%ld.%02ldMiB",
|
|
|
5bf14f |
cMiB/100, cMiB % 100);
|
|
|
5bf14f |
- } else {
|
|
|
5bf14f |
+ } else if (bytes < 2*1024LL*1024LL*1024LL*1024LL) {
|
|
|
5bf14f |
long cGiB = (bytes * 200LL / (1LL<<30) +1) /2;
|
|
|
5bf14f |
snprintf(buf, sizeof(buf), "%ld.%02ldGiB",
|
|
|
5bf14f |
cGiB/100, cGiB % 100);
|
|
|
5bf14f |
+ } else {
|
|
|
5bf14f |
+ long cTiB = (bytes * 200LL / (1LL<<40) + 1) / 2;
|
|
|
5bf14f |
+ snprintf(buf, sizeof(buf), "%ld.%02ldTiB",
|
|
|
5bf14f |
+ cTiB/100, cTiB % 100);
|
|
|
5bf14f |
}
|
|
|
5bf14f |
}
|
|
|
5bf14f |
else if (prefix == JEDEC) {
|
|
|
5bf14f |
@@ -952,10 +967,14 @@ char *human_size_brief(long long bytes, int prefix)
|
|
|
5bf14f |
long cMB = (bytes / ( 1000000LL / 200LL ) +1) /2;
|
|
|
5bf14f |
snprintf(buf, sizeof(buf), "%ld.%02ldMB",
|
|
|
5bf14f |
cMB/100, cMB % 100);
|
|
|
5bf14f |
- } else {
|
|
|
5bf14f |
+ } else if (bytes < 2*1024LL*1024LL*1024LL*1024LL) {
|
|
|
5bf14f |
long cGB = (bytes / (1000000000LL/200LL ) +1) /2;
|
|
|
5bf14f |
snprintf(buf, sizeof(buf), "%ld.%02ldGB",
|
|
|
5bf14f |
cGB/100, cGB % 100);
|
|
|
5bf14f |
+ } else {
|
|
|
5bf14f |
+ long cTB = (bytes / (1000000000000LL / 200LL) + 1) / 2;
|
|
|
5bf14f |
+ snprintf(buf, sizeof(buf), "%ld.%02ldTB",
|
|
|
5bf14f |
+ cTB/100, cTB % 100);
|
|
|
5bf14f |
}
|
|
|
5bf14f |
}
|
|
|
5bf14f |
else
|
|
|
5bf14f |
--
|
|
|
5bf14f |
2.7.5
|
|
|
5bf14f |
|