[pve-devel] [PATCH storage 04/14] Diskmanage: also check for filesystem type when determining usage
Fabian Ebner
f.ebner at proxmox.com
Tue Jan 26 12:45:20 CET 2021
Like this, a non-ZFS filesystem living on a whole disk will also be detected
when it is not mounted.
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
PVE/Diskmanage.pm | 15 +++++++++++++--
test/disk_tests/usages/disklist | 1 +
test/disk_tests/usages/disklist_expected.json | 15 +++++++++++++++
test/disk_tests/usages/lsblk | 7 ++++---
test/disk_tests/usages/sdn/device/vendor | 1 +
test/disk_tests/usages/sdn/queue/rotational | 1 +
test/disk_tests/usages/sdn/size | 1 +
test/disk_tests/usages/sdn_udevadm | 14 ++++++++++++++
8 files changed, 50 insertions(+), 5 deletions(-)
create mode 100644 test/disk_tests/usages/sdn/device/vendor
create mode 100644 test/disk_tests/usages/sdn/queue/rotational
create mode 100644 test/disk_tests/usages/sdn/size
create mode 100644 test/disk_tests/usages/sdn_udevadm
diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm
index e20484b..5672d0f 100644
--- a/PVE/Diskmanage.pm
+++ b/PVE/Diskmanage.pm
@@ -158,7 +158,7 @@ sub get_smart_data {
}
sub get_lsblk_info() {
- my $cmd = [$LSBLK, '--json', '-o', 'path,parttype'];
+ my $cmd = [$LSBLK, '--json', '-o', 'path,parttype,fstype'];
my $output = "";
my $res = {};
eval {
@@ -175,7 +175,10 @@ sub get_lsblk_info() {
my $list = $parsed->{blockdevices} // [];
$res = { map {
- $_->{path} => { parttype => $_->{parttype} }
+ $_->{path} => {
+ parttype => $_->{parttype},
+ fstype => $_->{fstype}
+ }
} @{$list} };
return $res;
@@ -565,6 +568,14 @@ sub get_disks {
$used = 'ZFS' if $zfshash->{$devpath};
+ if (defined($lsblk_info->{$devpath})) {
+ my $fstype = $lsblk_info->{$devpath}->{fstype};
+ if (defined($fstype)) {
+ $used = $fstype;
+ $used .= ' (mounted)' if $mounted->{$devpath};
+ }
+ }
+
# we replaced cciss/ with cciss! above
# but in the result we need cciss/ again
# because the caller might want to check the
diff --git a/test/disk_tests/usages/disklist b/test/disk_tests/usages/disklist
index 92c3622..648bea5 100644
--- a/test/disk_tests/usages/disklist
+++ b/test/disk_tests/usages/disklist
@@ -11,3 +11,4 @@ sdj
sdk
sdl
sdm
+sdn
diff --git a/test/disk_tests/usages/disklist_expected.json b/test/disk_tests/usages/disklist_expected.json
index b2e37c0..93dc251 100644
--- a/test/disk_tests/usages/disklist_expected.json
+++ b/test/disk_tests/usages/disklist_expected.json
@@ -203,5 +203,20 @@
"rpm" : 0,
"type" : "hdd",
"osdid" : -1
+ },
+ "sdn" : {
+ "serial" : "SERIAL1",
+ "vendor" : "ATA",
+ "wwn" : "0x0000000000000000",
+ "devpath" : "/dev/sdn",
+ "model" : "MODEL1",
+ "used" : "xfs",
+ "wearout" : "N/A",
+ "health" : "UNKNOWN",
+ "gpt" : 0,
+ "size" : 1536000,
+ "rpm" : 0,
+ "type" : "hdd",
+ "osdid" : -1
}
}
diff --git a/test/disk_tests/usages/lsblk b/test/disk_tests/usages/lsblk
index cbb18b9..6a725ab 100644
--- a/test/disk_tests/usages/lsblk
+++ b/test/disk_tests/usages/lsblk
@@ -1,7 +1,8 @@
{
"blockdevices": [
- {"path":"/dev/sdm", "parttype":null},
- {"path":"/dev/sdm1", "parttype":"6a898cc3-1dd2-11b2-99a6-080020736631"},
- {"path":"/dev/sdm9", "parttype":"6a945a3b-1dd2-11b2-99a6-080020736631"}
+ {"path":"/dev/sdm", "parttype":null, "fstype":null},
+ {"path":"/dev/sdm1", "parttype":"6a898cc3-1dd2-11b2-99a6-080020736631", "fstype":"zfs_member"},
+ {"path":"/dev/sdm9", "parttype":"6a945a3b-1dd2-11b2-99a6-080020736631", "fstype":null},
+ {"path":"/dev/sdn", "parttype":null, "fstype":"xfs"}
]
}
diff --git a/test/disk_tests/usages/sdn/device/vendor b/test/disk_tests/usages/sdn/device/vendor
new file mode 100644
index 0000000..531030d
--- /dev/null
+++ b/test/disk_tests/usages/sdn/device/vendor
@@ -0,0 +1 @@
+ATA
diff --git a/test/disk_tests/usages/sdn/queue/rotational b/test/disk_tests/usages/sdn/queue/rotational
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/test/disk_tests/usages/sdn/queue/rotational
@@ -0,0 +1 @@
+1
diff --git a/test/disk_tests/usages/sdn/size b/test/disk_tests/usages/sdn/size
new file mode 100644
index 0000000..13de30f
--- /dev/null
+++ b/test/disk_tests/usages/sdn/size
@@ -0,0 +1 @@
+3000
diff --git a/test/disk_tests/usages/sdn_udevadm b/test/disk_tests/usages/sdn_udevadm
new file mode 100644
index 0000000..5ec4a92
--- /dev/null
+++ b/test/disk_tests/usages/sdn_udevadm
@@ -0,0 +1,14 @@
+E: DEVNAME=/dev/sdn
+E: DEVTYPE=disk
+E: ID_ATA_ROTATION_RATE_RPM=0
+E: ID_BUS=ata
+E: ID_MODEL=MODEL1
+E: ID_SERIAL=SERIAL1
+E: ID_SERIAL_SHORT=SERIAL1
+E: ID_TYPE=disk
+E: ID_FS_UUID=ab54fba8-48fe-4d37-bbe7-b403f94d3bed
+E: ID_FS_UUID_ENC=ab54fba8-48fe-4d37-bbe7-b403f94d3bed
+E: ID_FS_TYPE=xfs
+E: ID_FS_USAGE=filesystem
+E: ID_WWN=0x0000000000000000
+E: ID_WWN_WITH_EXTENSION=0x0000000000000000
--
2.20.1
More information about the pve-devel
mailing list