Diskmanage: also check for filesystem type when determining usage
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>
This commit is contained in:
committed by
Thomas Lamprecht
parent
b6bbc2ab28
commit
59c03cd970
@ -157,7 +157,7 @@ sub get_smart_data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub get_lsblk_info() {
|
sub get_lsblk_info() {
|
||||||
my $cmd = [$LSBLK, '--json', '-o', 'path,parttype'];
|
my $cmd = [$LSBLK, '--json', '-o', 'path,parttype,fstype'];
|
||||||
my $output = "";
|
my $output = "";
|
||||||
my $res = {};
|
my $res = {};
|
||||||
eval {
|
eval {
|
||||||
@ -174,7 +174,10 @@ sub get_lsblk_info() {
|
|||||||
my $list = $parsed->{blockdevices} // [];
|
my $list = $parsed->{blockdevices} // [];
|
||||||
|
|
||||||
$res = { map {
|
$res = { map {
|
||||||
$_->{path} => { parttype => $_->{parttype} }
|
$_->{path} => {
|
||||||
|
parttype => $_->{parttype},
|
||||||
|
fstype => $_->{fstype}
|
||||||
|
}
|
||||||
} @{$list} };
|
} @{$list} };
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
@ -564,6 +567,14 @@ sub get_disks {
|
|||||||
|
|
||||||
$used = 'ZFS' if $zfshash->{$devpath};
|
$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
|
# we replaced cciss/ with cciss! above
|
||||||
# but in the result we need cciss/ again
|
# but in the result we need cciss/ again
|
||||||
# because the caller might want to check the
|
# because the caller might want to check the
|
||||||
|
|||||||
@ -11,3 +11,4 @@ sdj
|
|||||||
sdk
|
sdk
|
||||||
sdl
|
sdl
|
||||||
sdm
|
sdm
|
||||||
|
sdn
|
||||||
|
|||||||
@ -203,5 +203,20 @@
|
|||||||
"rpm" : 0,
|
"rpm" : 0,
|
||||||
"type" : "hdd",
|
"type" : "hdd",
|
||||||
"osdid" : -1
|
"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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"blockdevices": [
|
"blockdevices": [
|
||||||
{"path":"/dev/sdm", "parttype":null},
|
{"path":"/dev/sdm", "parttype":null, "fstype":null},
|
||||||
{"path":"/dev/sdm1", "parttype":"6a898cc3-1dd2-11b2-99a6-080020736631"},
|
{"path":"/dev/sdm1", "parttype":"6a898cc3-1dd2-11b2-99a6-080020736631", "fstype":"zfs_member"},
|
||||||
{"path":"/dev/sdm9", "parttype":"6a945a3b-1dd2-11b2-99a6-080020736631"}
|
{"path":"/dev/sdm9", "parttype":"6a945a3b-1dd2-11b2-99a6-080020736631", "fstype":null},
|
||||||
|
{"path":"/dev/sdn", "parttype":null, "fstype":"xfs"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
1
test/disk_tests/usages/sdn/device/vendor
Normal file
1
test/disk_tests/usages/sdn/device/vendor
Normal file
@ -0,0 +1 @@
|
|||||||
|
ATA
|
||||||
1
test/disk_tests/usages/sdn/queue/rotational
Normal file
1
test/disk_tests/usages/sdn/queue/rotational
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
1
test/disk_tests/usages/sdn/size
Normal file
1
test/disk_tests/usages/sdn/size
Normal file
@ -0,0 +1 @@
|
|||||||
|
3000
|
||||||
14
test/disk_tests/usages/sdn_udevadm
Normal file
14
test/disk_tests/usages/sdn_udevadm
Normal file
@ -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
|
||||||
Reference in New Issue
Block a user