From a7a7fb00ac315e1ef7af5a90daf400d1b00b182f Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 10 Jan 2014 12:04:26 +0100 Subject: [PATCH] ceph: improve disk usage detection --- PVE/API2/Ceph.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm index 721d7e38..e5fb66c0 100644 --- a/PVE/API2/Ceph.pm +++ b/PVE/API2/Ceph.pm @@ -335,22 +335,30 @@ sub list_disks { my $journal_count = 0; + my $found_partitions; + my $found_lvm; + my $found_mountpoints; dir_glob_foreach("/sys/block/$dev", "$dev.+", sub { my ($part) = @_; + + $found_partitions = 1; + if (my $mp = &$dev_is_mounted("/dev/$part")) { - $used = 'mounted' if !$used; + $found_mountpoints = 1; if ($mp =~ m|^/var/lib/ceph/osd/ceph-(\d+)$|) { $osdid = $1; } } if (!&$dir_is_epmty("/sys/block/$dev/$part/holders")) { - $used = 'LVM' if !$used; + $found_lvm = 1; } - $used = 'partitions' if !$used; - $journal_count++ if $journalhash->{"/dev/$part"}; }); + $used = 'mounted' if $found_mountpoints && !$used; + $used = 'LVM' if $found_lvm && !$used; + $used = 'partitions' if $found_partitions && !$used; + $disklist->{$dev}->{used} = $used if $used; $disklist->{$dev}->{osdid} = $osdid; $disklist->{$dev}->{journals} = $journal_count;