blob: e1e6d08fa28c88e3808261b8994fbbab971b4f41 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
id = 1748
title = "qcow2: disk size exceeds virtual size"
state = "closed"
created_at = "2023-07-04T11:25:14.573Z"
closed_at = "2023-07-05T02:39:31.176Z"
labels = []
url = "https://gitlab.com/qemu-project/qemu/-/issues/1748"
host-os = "centos8"
host-arch = "x86"
qemu-version = "8.0.50"
guest-os = "centos8"
guest-arch = "x86"
description = """Disk size of qcow2 image file exceeds its virtual size after repeatedly writing, and deleting data in qemu vm."""
reproduce = """1. qemu-img create -f qcow2 tmp.qcow2 32M
2. attach tmp.qcow2 as a device to qemu vm
3. mount the device in qemu vm, and repeatedly writing, and deleting data"""
additional = """xml for attaching tmp.qcow2
```xml
<disk device="disk" type="file">
<target bus="virtio" dev="vdb"/>
<source file="/path/to/tmp.qcow2"/>
<driver type="qcow2" name="qemu" cache="none" discard="unmap"/>
</disk>
```
in fact, set discard="unmap" or not seems has `little impact` on the final result.
reproducible shell script.
```sh
#! /bin/sh
for i in {1..1000}; do
for j in {1..27}; do
dd if=/dev/zero of=/mnt/test-$j bs=1M count=1 &
done
sync
sleep 10
rm -f /mnt/test-*
fstrim /mnt
done
```
MOUNT the device and run this script, problem happens about 30 minutes.
final result looks like:
```sh
# qemu-img info tmp.qcow2 --force
image: tmp.qcow2
file format: qcow2
virtual size: 32 MiB (33554432 bytes)
disk size: 33 MiB
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
lazy refcounts: false
refcount bits: 16
corrupt: false
extended l2: false
Child node '/file':
filename: tmp.qcow2
protocol type: file
file length: 32.3 MiB (33882112 bytes)
disk size: 33 MiB
Format specific information:
extent size hint: 1048576
```"""
|