mirror of
https://git.proxmox.com/git/proxmox-backup-qemu
synced 2025-10-04 16:07:54 +00:00
fix backing up images that are not multiples of 'chunk_size'
by removing the client side checks since the backup server has to check those things anyway, there is little benefit of checking it here, but poses a risk that there are two diverging checks for the client and server especially the next to last check (end_offset > device_size) was wrong, since we do not actually check the size of the actual chunk (which would be 'size'), but the generic set chunk size (defaults to 4M) which is obviously wrong (the last chunk is probably smaller) since it is not needed anymore, we can omit to get the 'device_size' fixes an issue where we could not backup an image which was not 4M aligned (or smaller than 4M altogether) Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
5e800b33e7
commit
391ec76798
@ -213,30 +213,14 @@ pub(crate) async fn write_data(
|
||||
|
||||
//println!("dev {}: write {} {}", dev_id, offset, size);
|
||||
|
||||
let (wid, mut upload_queue, zero_chunk_digest, device_size) = {
|
||||
let (wid, mut upload_queue, zero_chunk_digest) = {
|
||||
let mut guard = registry.lock().unwrap();
|
||||
let info = guard.lookup(dev_id)?;
|
||||
|
||||
|
||||
(info.wid, info.upload_queue.clone(), info.zero_chunk_digest, info.device_size)
|
||||
(info.wid, info.upload_queue.clone(), info.zero_chunk_digest)
|
||||
};
|
||||
|
||||
// Note: last chunk may be smaller than chunk_size
|
||||
if size > chunk_size {
|
||||
bail!("write_data: got unexpected chunk size {}", size);
|
||||
}
|
||||
|
||||
if offset & (chunk_size - 1) != 0 {
|
||||
bail!("write_data: offset {} is not correctly aligned", offset);
|
||||
}
|
||||
|
||||
let end_offset = offset + chunk_size;
|
||||
if end_offset > device_size {
|
||||
bail!("write_data: write out of range");
|
||||
} else if end_offset < device_size && size != chunk_size {
|
||||
bail!("write_data: chunk too small {}", size);
|
||||
}
|
||||
|
||||
let upload_future: Box<dyn Future<Output = Result<ChunkUploadInfo, Error>> + Send + Unpin> = {
|
||||
if data.0.is_null() {
|
||||
if size != chunk_size {
|
||||
|
Loading…
Reference in New Issue
Block a user