mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-12 15:26:52 +00:00
use a WriteLock for write operations on fullcopy tables
This commit is contained in:
@@ -196,6 +196,19 @@ impl LayoutHelper {
|
||||
self.current().nodes_of(hash).collect()
|
||||
}
|
||||
|
||||
/// For a given hash, or for all cluster if no hash is given,
|
||||
/// return for each layout version the set of nodes that writes should be sent to
|
||||
/// and for which a quorum of OK responses should be awaited.
|
||||
pub fn write_sets_of(&self, hash: Option<&Hash>) -> Vec<Vec<Uuid>> {
|
||||
self.versions()
|
||||
.iter()
|
||||
.map(|x| match hash {
|
||||
Some(h) => x.nodes_of(h).collect(),
|
||||
None => x.all_nodes().to_vec(),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn ack_map_min(&self) -> u64 {
|
||||
self.ack_map_min
|
||||
}
|
||||
|
||||
@@ -143,20 +143,19 @@ impl LayoutManager {
|
||||
|
||||
// ---- ACK LOCKING ----
|
||||
|
||||
pub fn write_sets_of(self: &Arc<Self>, hash: &Hash) -> WriteLock<Vec<Vec<Uuid>>> {
|
||||
pub fn write_lock_with<T, F>(self: &Arc<Self>, f: F) -> WriteLock<T>
|
||||
where
|
||||
F: FnOnce(&LayoutHelper) -> T,
|
||||
{
|
||||
let layout = self.layout();
|
||||
let version = layout.current().version;
|
||||
let nodes = layout
|
||||
.versions()
|
||||
.iter()
|
||||
.map(|x| x.nodes_of(hash).collect())
|
||||
.collect();
|
||||
let value = f(&layout);
|
||||
layout
|
||||
.ack_lock
|
||||
.get(&version)
|
||||
.unwrap()
|
||||
.fetch_add(1, Ordering::Relaxed);
|
||||
WriteLock::new(version, self, nodes)
|
||||
WriteLock::new(version, self, value)
|
||||
}
|
||||
|
||||
// ---- INTERNALS ---
|
||||
|
||||
Reference in New Issue
Block a user