]> git.proxmox.com Git - proxmox-backup.git/commitdiff
backup-client: use 1M chunks, make chunk_size configurable
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 21 Dec 2018 07:36:57 +0000 (08:36 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 21 Dec 2018 07:36:57 +0000 (08:36 +0100)
src/backup/datastore.rs
src/backup/image_index.rs
src/bin/backup-client.rs

index a846f3e4a699ead3ecb6de562d7e14657db82959..de903562a51604ada3b09923335e8e1cd5e6de12 100644 (file)
@@ -27,9 +27,9 @@ impl DataStore {
         })
     }
 
-    pub fn create_image_writer<P: AsRef<Path>>(&mut self, filename: P, size: usize) -> Result<ImageIndexWriter, Error> {
+    pub fn create_image_writer<P: AsRef<Path>>(&mut self, filename: P, size: usize, chunk_size: usize) -> Result<ImageIndexWriter, Error> {
 
-        let index = ImageIndexWriter::create(&mut self.chunk_store, filename.as_ref(), size)?;
+        let index = ImageIndexWriter::create(&mut self.chunk_store, filename.as_ref(), size, chunk_size)?;
 
         Ok(index)
     }
index cfc056ac44c95f309d7dd282bb865aa10849542c..25170dc545b943acace40b6008650ef5e172d8e6 100644 (file)
@@ -150,7 +150,7 @@ impl <'a> Drop for ImageIndexWriter<'a> {
 
 impl <'a> ImageIndexWriter<'a> {
 
-    pub fn create(store: &'a mut ChunkStore, path: &Path, size: usize) -> Result<Self, Error> {
+    pub fn create(store: &'a mut ChunkStore, path: &Path, size: usize, chunk_size: usize) -> Result<Self, Error> {
 
         let full_path = store.relative_path(path);
         let mut tmp_path = full_path.clone();
@@ -162,8 +162,6 @@ impl <'a> ImageIndexWriter<'a> {
             .write(true)
             .open(&tmp_path)?;
 
-        let chunk_size = 64*1024; // fixed size for now??
-
         let header_size = std::mem::size_of::<ImageIndexHeader>();
 
         // todo: use static assertion when available in rust
index 65b66e72baee36ce9e829e96dd0dcc539ab46193..c3604dac70efee3cac82926c99bd0970581c1927 100644 (file)
@@ -43,9 +43,11 @@ fn backup_file(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
         if stat.st_size <= 0 { bail!("got strange file size '{}'", stat.st_size); }
         let size = stat.st_size as usize;
 
-        let mut index = datastore.create_image_writer(&target, size)?;
+        let chunk_size = 1024*1024;
 
-        tools::file_chunker(file, 64*1024, |pos, chunk| {
+        let mut index = datastore.create_image_writer(&target, size, chunk_size)?;
+
+        tools::file_chunker(file, chunk_size, |pos, chunk| {
             index.add_chunk(pos, chunk)?;
             Ok(true)
         })?;