public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage 09/14] Diskmanage: introduce ceph info helper
Date: Tue, 26 Jan 2021 12:45:25 +0100	[thread overview]
Message-ID: <20210126114530.8753-10-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210126114530.8753-1-f.ebner@proxmox.com>

so it can be re-used for partitions.

Also changes the regular expression in get_ceph_volume_info to match the full
device/partition name the LV is on. Not only is this needed for partitions,
especially if there's multiple partitions with an OSD, but it also fixes
handling NVMe devices with an OSD as a side effect. Previuosly those were not
detected here, because of the digits in the name, e.g. /dev/nvme0n1

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 PVE/Diskmanage.pm | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm
index b8ba498..ee04419 100644
--- a/PVE/Diskmanage.pm
+++ b/PVE/Diskmanage.pm
@@ -288,7 +288,7 @@ sub get_ceph_volume_infos {
 	my $fields = [ split(';', $line) ];
 
 	# lvs syntax is /dev/sdX(Y) where Y is the start (which we do not need)
-	my ($dev) = $fields->[0] =~ m|^(/dev/[a-z]+)|;
+	my ($dev) = $fields->[0] =~ m|^(/dev/[a-z]+[^(]*)|;
 	if ($fields->[1] =~ m|^osd-([^-]+)-|) {
 	    my $type = $1;
 	    # $result autovivification is wanted, to not creating empty hashes
@@ -639,6 +639,21 @@ sub get_disks {
 	    return 'partition';
 	};
 
+	my $collect_ceph_info = sub {
+	    my ($devpath) = @_;
+
+	    my $ceph_volume = $ceph_volume_infos->{$devpath} or return;
+	    $journal_count += $ceph_volume->{journal} // 0;
+	    $db_count += $ceph_volume->{db} // 0;
+	    $wal_count += $ceph_volume->{wal} // 0;
+	    if (defined($ceph_volume->{osdid})) {
+		$osdid = $ceph_volume->{osdid};
+		$bluestore = 1 if $ceph_volume->{bluestore};
+		$osdencrypted = 1 if $ceph_volume->{encrypted};
+	    }
+	    return 1;
+	};
+
 	my $partitions = {};
 
 	dir_glob_foreach("$sysdir", "$dev.+", sub {
@@ -651,6 +666,14 @@ sub get_disks {
 	    $partitions->{$part}->{used} =
 		$determine_usage->("$partpath/$part", "$sysdir/$part", 1);
 
+	    my $lvm_based_osd = $collect_ceph_info->("$partpath/$part");
+
+	    # Avoid counting twice (e.g. partition on which the LVM for the
+	    # DB OSD resides is present in the $journalhash)
+	    return if $lvm_based_osd;
+
+	    # Legacy handling for non-LVM based OSDs
+
 	    if (my $mp = $mounted->{"$partpath/$part"}) {
 		if ($mp =~ m|^/var/lib/ceph/osd/ceph-(\d+)$|) {
 		    $osdid = $1;
@@ -665,17 +688,6 @@ sub get_disks {
 	    }
 	});
 
-	if (my $ceph_volume = $ceph_volume_infos->{$devpath}) {
-	    $journal_count += $ceph_volume->{journal} // 0;
-	    $db_count += $ceph_volume->{db} // 0;
-	    $wal_count += $ceph_volume->{wal} // 0;
-	    if (defined($ceph_volume->{osdid})) {
-		$osdid = $ceph_volume->{osdid};
-		$bluestore = 1 if $ceph_volume->{bluestore};
-		$osdencrypted = 1 if $ceph_volume->{encrypted};
-	    }
-	}
-
 	my $used = $determine_usage->($devpath, $sysdir, 0);
 	foreach my $part (sort keys %{$partitions}) {
 	    next if $partitions->{$part}->{used} eq 'partition';
@@ -688,6 +700,9 @@ sub get_disks {
 	$used //= 'Device Mapper' if !dir_is_empty("$sysdir/holders");
 
 	$disklist->{$dev}->{used} = $used if $used;
+
+	$collect_ceph_info->($devpath);
+
 	$disklist->{$dev}->{osdid} = $osdid;
 	$disklist->{$dev}->{journals} = $journal_count if $journal_count;
 	$disklist->{$dev}->{bluestore} = $bluestore if $osdid != -1;
-- 
2.20.1





  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 ` [pve-devel] [PATCH storage 04/14] Diskmanage: also check for filesystem type when determining usage Fabian Ebner
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 ` Fabian Ebner [this message]
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-10-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal