From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 2ACEA6B3C1 for ; Tue, 26 Jan 2021 12:45:43 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 702E515AF6 for ; Tue, 26 Jan 2021 12:45:42 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id CF8751596A for ; Tue, 26 Jan 2021 12:45:35 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9B2BB4610E for ; Tue, 26 Jan 2021 12:45:35 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Tue, 26 Jan 2021 12:45:20 +0100 Message-Id: <20210126114530.8753-5-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210126114530.8753-1-f.ebner@proxmox.com> References: <20210126114530.8753-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.006 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [diskmanage.pm] Subject: [pve-devel] [PATCH storage 04/14] Diskmanage: also check for filesystem type when determining usage X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2021 11:45:43 -0000 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 --- 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