aboutsummaryrefslogtreecommitdiff
path: root/src/model/block.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-11-03 22:07:43 +0100
committerAlex Auvolat <alex@adnab.me>2021-11-08 15:47:47 +0100
commitad7ab3141141d292f6f925d1712f0ebf4f906692 (patch)
treec01937054552d821b44ebbe76721bf63a11c5130 /src/model/block.rs
parent74a7a550eb5c076d21185d44a1bdb60577a47779 (diff)
downloadgarage-ad7ab3141141d292f6f925d1712f0ebf4f906692.tar.gz
garage-ad7ab3141141d292f6f925d1712f0ebf4f906692.zip
Implement GC delay for table data
Diffstat (limited to 'src/model/block.rs')
-rw-r--r--src/model/block.rs10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/model/block.rs b/src/model/block.rs
index 3f40aaab..8b1919bb 100644
--- a/src/model/block.rs
+++ b/src/model/block.rs
@@ -1,3 +1,4 @@
+use std::convert::TryInto;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::Duration;
@@ -422,7 +423,7 @@ impl BlockManager {
async fn resync_iter(&self, must_exit: &mut watch::Receiver<bool>) -> Result<bool, Error> {
if let Some((time_bytes, hash_bytes)) = self.resync_queue.pop_min()? {
- let time_msec = u64_from_be_bytes(&time_bytes[0..8]);
+ let time_msec = u64::from_be_bytes(time_bytes[0..8].try_into().unwrap());
let now = now_msec();
if now >= time_msec {
let hash = Hash::try_from(&hash_bytes[..]).unwrap();
@@ -705,13 +706,6 @@ impl BlockManagerLocked {
}
}
-fn u64_from_be_bytes<T: AsRef<[u8]>>(bytes: T) -> u64 {
- assert!(bytes.as_ref().len() == 8);
- let mut x8 = [0u8; 8];
- x8.copy_from_slice(bytes.as_ref());
- u64::from_be_bytes(x8)
-}
-
/// Describes the state of the reference counter for a block
#[derive(Clone, Copy, Debug)]
enum RcEntry {