Browse Source

Match Go CopyFile: sync EC volume journal to disk before copying

Go calls ecVolume.Sync() before copying EC volume files to ensure the
.ecj journal is flushed to disk. Added sync_to_disk() to EcVolume and
call it in the CopyFile EC branch.
rust-volume-server
Chris Lu 3 days ago
parent
commit
ff83b808c8
  1. 8
      seaweed-volume/src/server/grpc_server.rs
  2. 8
      seaweed-volume/src/storage/erasure_coding/ec_volume.rs

8
seaweed-volume/src/server/grpc_server.rs

@ -1215,6 +1215,14 @@ impl VolumeServer for VolumeGrpcService {
file_name = v.file_name(&req.ext);
drop(store);
} else {
// Sync EC volume journal to disk before copying (matching Go's ecv.SyncToDisk())
{
let store = self.state.store.read().unwrap();
if let Some(ecv) = store.find_ec_volume(vid) {
let _ = ecv.sync_to_disk();
}
}
// EC volume: search disk locations for the file
let store = self.state.store.read().unwrap();
let mut found_path = None;

8
seaweed-volume/src/storage/erasure_coding/ec_volume.rs

@ -169,6 +169,14 @@ impl EcVolume {
format!("{}.ecj", self.idx_base_name())
}
/// Sync the EC volume's journal file to disk (matching Go's ecv.SyncToDisk()).
pub fn sync_to_disk(&self) -> io::Result<()> {
if let Some(ref ecj_file) = self.ecj_file {
ecj_file.sync_all()?;
}
Ok(())
}
// ---- Shard management ----
/// Add a shard to this volume.

Loading…
Cancel
Save