From d51876cb61bdbb4c0b34adeb25074a80a7d32ff6 Mon Sep 17 00:00:00 2001 From: liuxiangdong Date: Fri, 21 Feb 2025 15:05:39 +0800 Subject: [PATCH] qcow2: do not merge discard task Call the `fallocate` tasks less time in large block space than multiple consecutive small block space. However, the merging algorithm with O(n^2) complexity leads to excessive merging time in discrete data situations. Block the merging algorithm here first, and consider using other solutions later. Signed-off-by: liuxiangdong --- block_backend/src/qcow2/refcount.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/block_backend/src/qcow2/refcount.rs b/block_backend/src/qcow2/refcount.rs index 6e403da5d..1c7ff10e2 100644 --- a/block_backend/src/qcow2/refcount.rs +++ b/block_backend/src/qcow2/refcount.rs @@ -500,18 +500,8 @@ impl RefCount { /// Add discard task to the list. fn update_discard_list(&mut self, offset: u64, nbytes: u64) -> Result<()> { - let mut discard_task = DiscardTask { offset, nbytes }; - let len = self.discard_list.len(); - let mut discard_list: Vec = Vec::with_capacity(len + 1); - for task in self.discard_list.iter() { - if discard_task.is_overlap(task) { - discard_task.merge_task(task); - } else { - discard_list.push(task.clone()); - } - } - discard_list.push(discard_task); - self.discard_list = discard_list; + let discard_task = DiscardTask { offset, nbytes }; + self.discard_list.push(discard_task); Ok(()) } -- Gitee