5
0
mirror of git://git.proxmox.com/git/proxmox-backup.git synced 2025-01-20 14:03:53 +03:00

datastore: fix problem with operations counting

... if `.chunks/` is not available(deleted/moved) ChunkStore::open
fails, but that would happen after updating the active operations on the
datastore, so no reference that could be dropped is returned. Leading to
the operations counter to always increase. This only updates the counter
when a reference is returned, not before.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
This commit is contained in:
Hannes Laimer 2024-04-25 11:01:50 +02:00 committed by Fabian Grünbichler
parent c3e6770104
commit 0020601d52

View File

@ -158,13 +158,6 @@ impl DataStore {
}
}
if let Some(operation) = operation {
update_active_operations(name, operation, 1)?;
}
// Our operation is registered, unlock the config.
drop(config_lock);
let mut datastore_cache = DATASTORE_MAP.lock().unwrap();
let entry = datastore_cache.get(name);
@ -172,6 +165,9 @@ impl DataStore {
let chunk_store = if let Some(datastore) = &entry {
let last_digest = datastore.last_digest.as_ref();
if let Some(true) = last_digest.map(|last_digest| last_digest == &digest) {
if let Some(operation) = operation {
update_active_operations(name, operation, 1)?;
}
return Ok(Arc::new(Self {
inner: Arc::clone(datastore),
operation,
@ -195,6 +191,10 @@ impl DataStore {
let datastore = Arc::new(datastore);
datastore_cache.insert(name.to_string(), datastore.clone());
if let Some(operation) = operation {
update_active_operations(name, operation, 1)?;
}
Ok(Arc::new(Self {
inner: datastore,
operation,