* [pbs-devel] [PATCH proxmox-backup 1/2] tools: zfs_dataset_stats: remove dataset <-> obset file mapping on error
@ 2022-03-07 8:13 Dominik Csapak
2022-03-07 8:13 ` [pbs-devel] [PATCH proxmox-backup 2/2] tools: parse_objset_stat: drop the unecessary 'objset-' from the log Dominik Csapak
2022-03-08 8:19 ` [pbs-devel] applied-series: [PATCH proxmox-backup 1/2] tools: zfs_dataset_stats: remove dataset <-> obset file mapping on error Wolfgang Bumiller
0 siblings, 2 replies; 3+ messages in thread
From: Dominik Csapak @ 2022-03-07 8:13 UTC (permalink / raw)
To: pbs-devel
this can only real fail for two reasons:
* the format is wrong:
this should not happen unless the format changed, then it will
happen every time
* the file can't be read:
this can happen if a user deletes and recreates a dataset manually,
since the mapped file does not exist anymore but the dataset does
for the second case, delete the mapping from the hashmap, so that the
next call will refresh the mapping with the correct file
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/tools/disks/zfs.rs | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/tools/disks/zfs.rs b/src/tools/disks/zfs.rs
index 9bca0297..a02baa00 100644
--- a/src/tools/disks/zfs.rs
+++ b/src/tools/disks/zfs.rs
@@ -198,6 +198,14 @@ pub fn zfs_dataset_stats(dataset: &str) -> Result<BlockDevStat, Error> {
}
let (pool, objset_id) =
mapping.ok_or_else(|| format_err!("could not find objset id for dataset"))?;
- let (_, stat) = parse_objset_stat(&pool, &objset_id)?;
- Ok(stat)
+
+ match parse_objset_stat(&pool, &objset_id) {
+ Ok((_, stat)) => Ok(stat),
+ Err(err) => {
+ // on error remove dataset from map, it probably vanished or the
+ // mapping was incorrect
+ ZFS_DATASET_OBJSET_MAP.lock().unwrap().remove(dataset);
+ Err(err)
+ }
+ }
}
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 2/2] tools: parse_objset_stat: drop the unecessary 'objset-' from the log
2022-03-07 8:13 [pbs-devel] [PATCH proxmox-backup 1/2] tools: zfs_dataset_stats: remove dataset <-> obset file mapping on error Dominik Csapak
@ 2022-03-07 8:13 ` Dominik Csapak
2022-03-08 8:19 ` [pbs-devel] applied-series: [PATCH proxmox-backup 1/2] tools: zfs_dataset_stats: remove dataset <-> obset file mapping on error Wolfgang Bumiller
1 sibling, 0 replies; 3+ messages in thread
From: Dominik Csapak @ 2022-03-07 8:13 UTC (permalink / raw)
To: pbs-devel
'objset_id' already contains that, so the error was
"could not parse 'objset-objset-0xFFFF' stat file"
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/tools/disks/zfs.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/tools/disks/zfs.rs b/src/tools/disks/zfs.rs
index a02baa00..30a6cc0c 100644
--- a/src/tools/disks/zfs.rs
+++ b/src/tools/disks/zfs.rs
@@ -124,7 +124,7 @@ fn parse_objset_stat(pool: &str, objset_id: &str) -> Result<(String, BlockDevSta
let text = match proxmox_sys::fs::file_read_optional_string(&path)? {
Some(text) => text,
- None => bail!("could not parse 'objset-{}' stat file", objset_id),
+ None => bail!("could not parse '{}' stat file", objset_id),
};
let mut dataset_name = String::new();
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pbs-devel] applied-series: [PATCH proxmox-backup 1/2] tools: zfs_dataset_stats: remove dataset <-> obset file mapping on error
2022-03-07 8:13 [pbs-devel] [PATCH proxmox-backup 1/2] tools: zfs_dataset_stats: remove dataset <-> obset file mapping on error Dominik Csapak
2022-03-07 8:13 ` [pbs-devel] [PATCH proxmox-backup 2/2] tools: parse_objset_stat: drop the unecessary 'objset-' from the log Dominik Csapak
@ 2022-03-08 8:19 ` Wolfgang Bumiller
1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Bumiller @ 2022-03-08 8:19 UTC (permalink / raw)
To: Dominik Csapak; +Cc: pbs-devel
applied both patches, thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-08 8:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 8:13 [pbs-devel] [PATCH proxmox-backup 1/2] tools: zfs_dataset_stats: remove dataset <-> obset file mapping on error Dominik Csapak
2022-03-07 8:13 ` [pbs-devel] [PATCH proxmox-backup 2/2] tools: parse_objset_stat: drop the unecessary 'objset-' from the log Dominik Csapak
2022-03-08 8:19 ` [pbs-devel] applied-series: [PATCH proxmox-backup 1/2] tools: zfs_dataset_stats: remove dataset <-> obset file mapping on error Wolfgang Bumiller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox