tape: improve backup logs

This commit is contained in:
Dietmar Maurer 2021-01-11 13:22:31 +01:00
parent 93be18ffd2
commit 31cf625af5
2 changed files with 19 additions and 6 deletions

View File

@ -209,7 +209,7 @@ pub fn backup_snapshot(
let uuid = pool_writer.load_writable_media(worker)?; let uuid = pool_writer.load_writable_media(worker)?;
let (leom, _bytes) = pool_writer.append_chunk_archive(&datastore, &mut chunk_iter)?; let (leom, _bytes) = pool_writer.append_chunk_archive(worker, &datastore, &mut chunk_iter)?;
if leom { if leom {
pool_writer.set_media_status_full(&uuid)?; pool_writer.set_media_status_full(&uuid)?;

View File

@ -1,5 +1,6 @@
use std::collections::HashSet; use std::collections::HashSet;
use std::path::Path; use std::path::Path;
use std::time::SystemTime;
use anyhow::{bail, Error}; use anyhow::{bail, Error};
@ -294,6 +295,7 @@ impl PoolWriter {
/// (4GB). Written chunks are registered in the media catalog. /// (4GB). Written chunks are registered in the media catalog.
pub fn append_chunk_archive( pub fn append_chunk_archive(
&mut self, &mut self,
worker: &WorkerTask,
datastore: &DataStore, datastore: &DataStore,
chunk_iter: &mut std::iter::Peekable<SnapshotChunkIterator>, chunk_iter: &mut std::iter::Peekable<SnapshotChunkIterator>,
) -> Result<(bool, usize), Error> { ) -> Result<(bool, usize), Error> {
@ -314,7 +316,10 @@ impl PoolWriter {
} }
let writer = status.drive.write_file()?; let writer = status.drive.write_file()?;
let start_time = SystemTime::now();
let (saved_chunks, content_uuid, leom, bytes_written) = write_chunk_archive( let (saved_chunks, content_uuid, leom, bytes_written) = write_chunk_archive(
worker,
writer, writer,
datastore, datastore,
chunk_iter, chunk_iter,
@ -325,6 +330,13 @@ impl PoolWriter {
status.bytes_written += bytes_written; status.bytes_written += bytes_written;
let elapsed = start_time.elapsed()?.as_secs_f64();
worker.log(format!(
"wrote {:.2} MB ({} MB/s)",
bytes_written as f64 / (1024.0*1024.0),
(bytes_written as f64)/(1024.0*1024.0*elapsed),
));
let request_sync = if status.bytes_written >= COMMIT_BLOCK_SIZE { true } else { false }; let request_sync = if status.bytes_written >= COMMIT_BLOCK_SIZE { true } else { false };
// register chunks in media_catalog // register chunks in media_catalog
@ -344,6 +356,7 @@ impl PoolWriter {
/// write up to <max_size> of chunks /// write up to <max_size> of chunks
fn write_chunk_archive<'a>( fn write_chunk_archive<'a>(
worker: &WorkerTask,
writer: Box<dyn 'a + TapeWrite>, writer: Box<dyn 'a + TapeWrite>,
datastore: &DataStore, datastore: &DataStore,
chunk_iter: &mut std::iter::Peekable<SnapshotChunkIterator>, chunk_iter: &mut std::iter::Peekable<SnapshotChunkIterator>,
@ -374,7 +387,7 @@ fn write_chunk_archive<'a>(
} }
let blob = datastore.load_chunk(&digest)?; let blob = datastore.load_chunk(&digest)?;
println!("CHUNK {} size {}", proxmox::tools::digest_to_hex(&digest), blob.raw_size()); //println!("CHUNK {} size {}", proxmox::tools::digest_to_hex(&digest), blob.raw_size());
match writer.try_write_chunk(&digest, &blob) { match writer.try_write_chunk(&digest, &blob) {
Ok(true) => { Ok(true) => {
@ -389,7 +402,7 @@ fn write_chunk_archive<'a>(
} }
if writer.bytes_written() > max_size { if writer.bytes_written() > max_size {
println!("Chunk Archive max size reached, closing archive"); worker.log(format!("Chunk Archive max size reached, closing archive"));
break; break;
} }
} }
@ -422,7 +435,7 @@ fn update_media_set_label(
None => { None => {
worker.log(format!("wrinting new media set label")); worker.log(format!("wrinting new media set label"));
drive.write_media_set_label(new_set)?; drive.write_media_set_label(new_set)?;
media_catalog = MediaCatalog::overwrite(status_path, media_id, true)?; media_catalog = MediaCatalog::overwrite(status_path, media_id, false)?;
} }
Some(media_set_label) => { Some(media_set_label) => {
if new_set.uuid == media_set_label.uuid { if new_set.uuid == media_set_label.uuid {
@ -438,7 +451,7 @@ fn update_media_set_label(
); );
drive.write_media_set_label(new_set)?; drive.write_media_set_label(new_set)?;
media_catalog = MediaCatalog::overwrite(status_path, media_id, true)?; media_catalog = MediaCatalog::overwrite(status_path, media_id, false)?;
} }
} }
} }