From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage 04/14] Diskmanage: also check for filesystem type when determining usage
Date: Tue, 26 Jan 2021 12:45:20 +0100 [thread overview]
Message-ID: <20210126114530.8753-5-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210126114530.8753-1-f.ebner@proxmox.com>
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@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
next prev parent reply other threads:[~2021-01-26 11:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-26 11:45 [pve-devel] [PATCH-SERIES] partially fix #2285: extend Diskmanage to also list partitions Fabian Ebner
2021-01-26 11:45 ` [pve-devel] [PATCH storage 01/14] Disks: return correct journal disk candidates Fabian Ebner
2021-01-26 11:45 ` [pve-devel] [PATCH storage 02/14] Diskmanage: replace closure with direct hash access Fabian Ebner
2021-01-26 11:45 ` [pve-devel] [PATCH storage 03/14] Diskmanage: refactor and rename get_parttype_info Fabian Ebner
2021-01-26 11:45 ` Fabian Ebner [this message]
2021-01-26 11:45 ` [pve-devel] [PATCH storage 05/14] Diskmanage: introduce get_sysdir_size helper Fabian Ebner
2021-01-26 11:45 ` [pve-devel] [PATCH storage 06/14] Diskmanage: collect partitions in hash Fabian Ebner
2021-01-26 11:45 ` [pve-devel] [PATCH storage 07/14] Diskmanage: introduce usage helper Fabian Ebner
2021-01-26 11:45 ` [pve-devel] [PATCH storage 08/14] Diskmanage: also detect BIOS boot, EFI and ZFS reserved type partitions Fabian Ebner
2021-01-26 11:45 ` [pve-devel] [PATCH storage 09/14] Diskmanage: introduce ceph info helper Fabian Ebner
2021-01-26 11:45 ` [pve-devel] [PATCH storage 10/14] Diskmanage: save OSD information for individual partitions Fabian Ebner
2021-01-26 11:45 ` [pve-devel] [PATCH storage 11/14] Diskmanage: also include partitions with get_disks if flag is set Fabian Ebner
2021-01-26 11:45 ` [pve-devel] [PATCH manager 12/14] api: Ceph: add reminder to remove 'disks' call Fabian Ebner
2021-01-26 11:45 ` [pve-devel] [PATCH widget-toolkit 13/14] convert disk list to disk tree including the partitions Fabian Ebner
2021-01-26 11:45 ` [pve-devel] [PATCH widget-toolkit 14/14] move DiskList.js from grid/ to panel/ Fabian Ebner
2021-02-06 13:13 ` [pve-devel] partially-applied: [PATCH-SERIES] partially fix #2285: extend Diskmanage to also list partitions Thomas Lamprecht
2021-02-08 7:58 ` Fabian Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210126114530.8753-5-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox