datastore: add new Lookup for operations tracking
We sometimes need to do some in-memory only stuff, e.g., to check if GC is already running for a datastore, which is a try_lock on a mutex that is in-memory. Actually the whole thing would be nicer if we could guarantee to hold the correct contract statically, e.g., like https://docs.rust-embedded.org/book/static-guarantees/design-contracts.html Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
@ -133,7 +133,7 @@ impl DataStore {
|
||||
|
||||
if let Some(maintenance_mode) = config.get_maintenance_mode() {
|
||||
if let Err(error) = maintenance_mode.check(operation) {
|
||||
bail!("datastore '{}' is in {}", name, error);
|
||||
bail!("datastore '{name}' is in {error}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,7 @@ pub fn update_active_operations(name: &str, operation: Operation, count: i64) ->
|
||||
match operation {
|
||||
Operation::Read => task.active_operations.read += count,
|
||||
Operation::Write => task.active_operations.write += count,
|
||||
Operation::Lookup => (), // no IO must happen there
|
||||
};
|
||||
}
|
||||
Some(task.clone())
|
||||
@ -98,6 +99,7 @@ pub fn update_active_operations(name: &str, operation: Operation, count: i64) ->
|
||||
active_operations: match operation {
|
||||
Operation::Read => ActiveOperationStats { read: 1, write: 0 },
|
||||
Operation::Write => ActiveOperationStats { read: 0, write: 1 },
|
||||
Operation::Lookup => ActiveOperationStats { read: 0, write: 0 },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user