aboutsummaryrefslogtreecommitdiff
path: root/src/block/manager.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-06 14:01:44 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-06 14:01:44 +0200
commit7f2cf0b809f1fc5741990e2bfff94dc3ec41a04f (patch)
treed682dfba3c86d823b0447db21bd7740b2ab3d772 /src/block/manager.rs
parent4539a6c2298cfb4578261060e4a5af739a45c99f (diff)
downloadgarage-7f2cf0b809f1fc5741990e2bfff94dc3ec41a04f.tar.gz
garage-7f2cf0b809f1fc5741990e2bfff94dc3ec41a04f.zip
Safe choice: return Vec<u8> and not some fancy zero-copy type
Diffstat (limited to 'src/block/manager.rs')
-rw-r--r--src/block/manager.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/block/manager.rs b/src/block/manager.rs
index decf33cc..abc5063d 100644
--- a/src/block/manager.rs
+++ b/src/block/manager.rs
@@ -555,11 +555,7 @@ impl BlockManager {
// - Ok(false) -> no block was processed, but we are ready for the next iteration
// - Err(_) -> a Sled error occurred when reading/writing from resync_queue/resync_errors
async fn resync_iter(&self, must_exit: &mut watch::Receiver<bool>) -> Result<bool, db::Error> {
- let next = self
- .resync_queue
- .first()?
- .map(|(k, v)| (k.into_vec(), v.into_vec()));
- if let Some((time_bytes, hash_bytes)) = next {
+ if let Some((time_bytes, hash_bytes)) = self.resync_queue.first()? {
let time_msec = u64::from_be_bytes(time_bytes[0..8].try_into().unwrap());
let now = now_msec();
@@ -567,7 +563,7 @@ impl BlockManager {
let hash = Hash::try_from(&hash_bytes[..]).unwrap();
if let Some(ec) = self.resync_errors.get(hash.as_slice())? {
- let ec = ErrorCounter::decode(ec);
+ let ec = ErrorCounter::decode(&ec);
if now < ec.next_try() {
// if next retry after an error is not yet,
// don't do resync and return early, but still
@@ -608,7 +604,7 @@ impl BlockManager {
warn!("Error when resyncing {:?}: {}", hash, e);
let err_counter = match self.resync_errors.get(hash.as_slice())? {
- Some(ec) => ErrorCounter::decode(ec).add1(now + 1),
+ Some(ec) => ErrorCounter::decode(&ec).add1(now + 1),
None => ErrorCounter::new(now + 1),
};
@@ -972,7 +968,7 @@ impl ErrorCounter {
}
}
- fn decode(data: db::Value<'_>) -> Self {
+ fn decode(data: &db::Value) -> Self {
Self {
errors: u64::from_be_bytes(data[0..8].try_into().unwrap()),
last_try: u64::from_be_bytes(data[8..16].try_into().unwrap()),