datastore: swap ConfigVersionCache with digest for change detection
We got the digest available anyway, and it's only 16 bytes more to save (compared to last_generation and the recently removed last_time, both being 64 bit = 8 bytes each) Side benefit, we detect config changes made manually (e.g., `vim datacenter.cfg`) immediately. Note that we could restructure the maintenance mode checking to only be done after checking if there's a cached datastore, in which case using the generation could make sense to decide if we need to re-load it again before blindly loading the config anyway. As that's not only some (not exactly hard but not really trivial like a typo fix either) restructuring work but also means we'd lose the "detect manual changes" again I'd rather keep using the digest. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
@ -26,6 +26,7 @@ struct ConfigVersionCacheDataInner {
|
||||
// Traffic control (traffic-control.cfg) generation/version.
|
||||
traffic_control_generation: AtomicUsize,
|
||||
// datastore (datastore.cfg) generation/version
|
||||
// FIXME: remove with PBS 3.0
|
||||
datastore_generation: AtomicUsize,
|
||||
// Add further atomics here
|
||||
}
|
||||
@ -144,15 +145,8 @@ impl ConfigVersionCache {
|
||||
.fetch_add(1, Ordering::AcqRel);
|
||||
}
|
||||
|
||||
/// Returns the datastore generation number.
|
||||
pub fn datastore_generation(&self) -> usize {
|
||||
self.shmem
|
||||
.data()
|
||||
.datastore_generation
|
||||
.load(Ordering::Acquire)
|
||||
}
|
||||
|
||||
/// Increase the datastore generation number.
|
||||
// FIXME: remove with PBS 3.0 or make actually useful again in datastore lookup
|
||||
pub fn increase_datastore_generation(&self) -> usize {
|
||||
self.shmem
|
||||
.data()
|
||||
|
Reference in New Issue
Block a user