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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 9D071722F0 for ; Mon, 12 Apr 2021 11:25:02 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 870611C5D6 for ; Mon, 12 Apr 2021 11:24:32 +0200 (CEST) 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 5D7BE1C5CB for ; Mon, 12 Apr 2021 11:24:31 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 22ABF42074 for ; Mon, 12 Apr 2021 11:24:31 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Mon, 12 Apr 2021 11:24:29 +0200 Message-Id: <20210412092429.24955-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.166 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 Subject: [pbs-devel] [PATCH proxmox-backup] fix gathering io stats for zpools X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Apr 2021 09:25:02 -0000 if a datastore or root is not used directly on the pool dir (e.g. the installer creates 2 sub datasets ROOT/pbs-1), info in /proc/self/mountinfo returns not the pool, but the path to the dataset, which has no iostats itself in /proc/spl/kstat/zfs/ but only the pool itself so instead of not gathering data at all, gather the info from the underlying pool instead. if one has multiple datastores on the same pool those rrd stats will be the same for all those datastores now (instead of empty) similar to 'normal' directories Signed-off-by: Dominik Csapak --- src/bin/proxmox-backup-proxy.rs | 6 ++++-- src/tools/disks/zfs.rs | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index 7e026455..9b61a7c5 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -41,6 +41,7 @@ use proxmox_backup::tools::{ disks::{ DiskManage, zfs_pool_stats, + get_pool_from_dataset, }, logrotate::LogRotate, socket::{ @@ -870,8 +871,9 @@ fn gather_disk_stats(disk_manager: Arc, path: &Path, rrd_prefix: &st let mut device_stat = None; match fs_type.as_str() { "zfs" => { - if let Some(pool) = source { - match zfs_pool_stats(&pool) { + if let Some(source) = source { + let pool = get_pool_from_dataset(&source).unwrap_or(&source); + match zfs_pool_stats(pool) { Ok(stat) => device_stat = stat, Err(err) => eprintln!("zfs_pool_stats({:?}) failed - {}", pool, err), } diff --git a/src/tools/disks/zfs.rs b/src/tools/disks/zfs.rs index d7c3907e..e0084939 100644 --- a/src/tools/disks/zfs.rs +++ b/src/tools/disks/zfs.rs @@ -16,6 +16,17 @@ lazy_static!{ }; } +/// returns pool from dataset path of the form 'rpool/ROOT/pbs-1' +pub fn get_pool_from_dataset(dataset: &OsStr) -> Option<&OsStr> { + if let Some(dataset) = dataset.to_str() { + if let Some(idx) = dataset.find('/') { + return Some(&dataset[0..idx].as_ref()); + } + } + + None +} + /// Returns kernel IO-stats for zfs pools pub fn zfs_pool_stats(pool: &OsStr) -> Result, Error> { -- 2.20.1