|
|
1072c8 |
From 7ee01b5ccb7fc660dafaf3fdb1578649d17fbddf Mon Sep 17 00:00:00 2001
|
|
|
1072c8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
1072c8 |
Date: Wed, 26 May 2021 09:05:52 -0400
|
|
|
1072c8 |
Subject: [PATCH 1/4] file-posix: Mitigate file fragmentation with extent size
|
|
|
1072c8 |
hints
|
|
|
1072c8 |
|
|
|
1072c8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
1072c8 |
Message-id: <20210526090552.155820-2-kwolf@redhat.com>
|
|
|
1072c8 |
Patchwork-id: 101638
|
|
|
1072c8 |
O-Subject: [RHEL-8.5.0 qemu-kvm PATCH 1/1] file-posix: Mitigate file fragmentation with extent size hints
|
|
|
1072c8 |
Bugzilla: 1877163
|
|
|
1072c8 |
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
1072c8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
1072c8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
1072c8 |
|
|
|
1072c8 |
Especially when O_DIRECT is used with image files so that the page cache
|
|
|
1072c8 |
indirection can't cause a merge of allocating requests, the file will
|
|
|
1072c8 |
fragment on the file system layer, with a potentially very small
|
|
|
1072c8 |
fragment size (this depends on the requests the guest sent).
|
|
|
1072c8 |
|
|
|
1072c8 |
On Linux, fragmentation can be reduced by setting an extent size hint
|
|
|
1072c8 |
when creating the file (at least on XFS, it can't be set any more after
|
|
|
1072c8 |
the first extent has been allocated), basically giving raw files a
|
|
|
1072c8 |
"cluster size" for allocation.
|
|
|
1072c8 |
|
|
|
1072c8 |
This adds a create option to set the extent size hint, and changes the
|
|
|
1072c8 |
default from not setting a hint to setting it to 1 MB. The main reason
|
|
|
1072c8 |
why qcow2 defaults to smaller cluster sizes is that COW becomes more
|
|
|
1072c8 |
expensive, which is not an issue with raw files, so we can choose a
|
|
|
1072c8 |
larger size. The tradeoff here is only potentially wasted disk space.
|
|
|
1072c8 |
|
|
|
1072c8 |
For qcow2 (or other image formats) over file-posix, the advantage should
|
|
|
1072c8 |
even be greater because they grow sequentially without leaving holes, so
|
|
|
1072c8 |
there won't be wasted space. Setting even larger extent size hints for
|
|
|
1072c8 |
such images may make sense. This can be done with the new option, but
|
|
|
1072c8 |
let's keep the default conservative for now.
|
|
|
1072c8 |
|
|
|
1072c8 |
The effect is very visible with a test that intentionally creates a
|
|
|
1072c8 |
badly fragmented file with qemu-img bench (the time difference while
|
|
|
1072c8 |
creating the file is already remarkable) and then looks at the number of
|
|
|
1072c8 |
extents and the time a simple "qemu-img map" takes.
|
|
|
1072c8 |
|
|
|
1072c8 |
Without an extent size hint:
|
|
|
1072c8 |
|
|
|
1072c8 |
$ ./qemu-img create -f raw -o extent_size_hint=0 ~/tmp/test.raw 10G
|
|
|
1072c8 |
Formatting '/home/kwolf/tmp/test.raw', fmt=raw size=10737418240 extent_size_hint=0
|
|
|
1072c8 |
$ ./qemu-img bench -f raw -t none -n -w ~/tmp/test.raw -c 1000000 -S 8192 -o 0
|
|
|
1072c8 |
Sending 1000000 write requests, 4096 bytes each, 64 in parallel (starting at offset 0, step size 8192)
|
|
|
1072c8 |
Run completed in 25.848 seconds.
|
|
|
1072c8 |
$ ./qemu-img bench -f raw -t none -n -w ~/tmp/test.raw -c 1000000 -S 8192 -o 4096
|
|
|
1072c8 |
Sending 1000000 write requests, 4096 bytes each, 64 in parallel (starting at offset 4096, step size 8192)
|
|
|
1072c8 |
Run completed in 19.616 seconds.
|
|
|
1072c8 |
$ filefrag ~/tmp/test.raw
|
|
|
1072c8 |
/home/kwolf/tmp/test.raw: 2000000 extents found
|
|
|
1072c8 |
$ time ./qemu-img map ~/tmp/test.raw
|
|
|
1072c8 |
Offset Length Mapped to File
|
|
|
1072c8 |
0 0x1e8480000 0 /home/kwolf/tmp/test.raw
|
|
|
1072c8 |
|
|
|
1072c8 |
real 0m1,279s
|
|
|
1072c8 |
user 0m0,043s
|
|
|
1072c8 |
sys 0m1,226s
|
|
|
1072c8 |
|
|
|
1072c8 |
With the new default extent size hint of 1 MB:
|
|
|
1072c8 |
|
|
|
1072c8 |
$ ./qemu-img create -f raw -o extent_size_hint=1M ~/tmp/test.raw 10G
|
|
|
1072c8 |
Formatting '/home/kwolf/tmp/test.raw', fmt=raw size=10737418240 extent_size_hint=1048576
|
|
|
1072c8 |
$ ./qemu-img bench -f raw -t none -n -w ~/tmp/test.raw -c 1000000 -S 8192 -o 0
|
|
|
1072c8 |
Sending 1000000 write requests, 4096 bytes each, 64 in parallel (starting at offset 0, step size 8192)
|
|
|
1072c8 |
Run completed in 11.833 seconds.
|
|
|
1072c8 |
$ ./qemu-img bench -f raw -t none -n -w ~/tmp/test.raw -c 1000000 -S 8192 -o 4096
|
|
|
1072c8 |
Sending 1000000 write requests, 4096 bytes each, 64 in parallel (starting at offset 4096, step size 8192)
|
|
|
1072c8 |
Run completed in 10.155 seconds.
|
|
|
1072c8 |
$ filefrag ~/tmp/test.raw
|
|
|
1072c8 |
/home/kwolf/tmp/test.raw: 178 extents found
|
|
|
1072c8 |
$ time ./qemu-img map ~/tmp/test.raw
|
|
|
1072c8 |
Offset Length Mapped to File
|
|
|
1072c8 |
0 0x1e8480000 0 /home/kwolf/tmp/test.raw
|
|
|
1072c8 |
|
|
|
1072c8 |
real 0m0,061s
|
|
|
1072c8 |
user 0m0,040s
|
|
|
1072c8 |
sys 0m0,014s
|
|
|
1072c8 |
|
|
|
1072c8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1072c8 |
Message-Id: <20200707142329.48303-1-kwolf@redhat.com>
|
|
|
1072c8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
1072c8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1072c8 |
(cherry picked from commit ffa244c84a1a30dff69ecc80b0137a2b6d428ecb)
|
|
|
1072c8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1072c8 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
1072c8 |
---
|
|
|
1072c8 |
block/file-posix.c | 44 ++++++++++++++++++++++++++++++++
|
|
|
1072c8 |
include/block/block_int.h | 1 +
|
|
|
1072c8 |
qapi/block-core.json | 11 +++++---
|
|
|
1072c8 |
tests/qemu-iotests/082.out | 16 ++++++++++++
|
|
|
1072c8 |
tests/qemu-iotests/106 | 7 +++--
|
|
|
1072c8 |
tests/qemu-iotests/175 | 6 ++---
|
|
|
1072c8 |
tests/qemu-iotests/243 | 6 ++---
|
|
|
1072c8 |
tests/qemu-iotests/common.filter | 1 +
|
|
|
1072c8 |
8 files changed, 80 insertions(+), 12 deletions(-)
|
|
|
1072c8 |
|
|
|
1072c8 |
diff --git a/block/file-posix.c b/block/file-posix.c
|
|
|
1072c8 |
index 2d834fbdf6..62a463229f 100644
|
|
|
1072c8 |
--- a/block/file-posix.c
|
|
|
1072c8 |
+++ b/block/file-posix.c
|
|
|
1072c8 |
@@ -30,6 +30,7 @@
|
|
|
1072c8 |
#include "block/block_int.h"
|
|
|
1072c8 |
#include "qemu/module.h"
|
|
|
1072c8 |
#include "qemu/option.h"
|
|
|
1072c8 |
+#include "qemu/units.h"
|
|
|
1072c8 |
#include "trace.h"
|
|
|
1072c8 |
#include "block/thread-pool.h"
|
|
|
1072c8 |
#include "qemu/iov.h"
|
|
|
1072c8 |
@@ -2289,6 +2290,14 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
|
|
1072c8 |
if (!file_opts->has_preallocation) {
|
|
|
1072c8 |
file_opts->preallocation = PREALLOC_MODE_OFF;
|
|
|
1072c8 |
}
|
|
|
1072c8 |
+ if (!file_opts->has_extent_size_hint) {
|
|
|
1072c8 |
+ file_opts->extent_size_hint = 1 * MiB;
|
|
|
1072c8 |
+ }
|
|
|
1072c8 |
+ if (file_opts->extent_size_hint > UINT32_MAX) {
|
|
|
1072c8 |
+ result = -EINVAL;
|
|
|
1072c8 |
+ error_setg(errp, "Extent size hint is too large");
|
|
|
1072c8 |
+ goto out;
|
|
|
1072c8 |
+ }
|
|
|
1072c8 |
|
|
|
1072c8 |
/* Create file */
|
|
|
1072c8 |
fd = qemu_open(file_opts->filename, O_RDWR | O_CREAT | O_BINARY, 0644);
|
|
|
1072c8 |
@@ -2346,6 +2355,27 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
|
|
1072c8 |
}
|
|
|
1072c8 |
#endif
|
|
|
1072c8 |
}
|
|
|
1072c8 |
+#ifdef FS_IOC_FSSETXATTR
|
|
|
1072c8 |
+ /*
|
|
|
1072c8 |
+ * Try to set the extent size hint. Failure is not fatal, and a warning is
|
|
|
1072c8 |
+ * only printed if the option was explicitly specified.
|
|
|
1072c8 |
+ */
|
|
|
1072c8 |
+ {
|
|
|
1072c8 |
+ struct fsxattr attr;
|
|
|
1072c8 |
+ result = ioctl(fd, FS_IOC_FSGETXATTR, &attr);
|
|
|
1072c8 |
+ if (result == 0) {
|
|
|
1072c8 |
+ attr.fsx_xflags |= FS_XFLAG_EXTSIZE;
|
|
|
1072c8 |
+ attr.fsx_extsize = file_opts->extent_size_hint;
|
|
|
1072c8 |
+ result = ioctl(fd, FS_IOC_FSSETXATTR, &attr);
|
|
|
1072c8 |
+ }
|
|
|
1072c8 |
+ if (result < 0 && file_opts->has_extent_size_hint &&
|
|
|
1072c8 |
+ file_opts->extent_size_hint)
|
|
|
1072c8 |
+ {
|
|
|
1072c8 |
+ warn_report("Failed to set extent size hint: %s",
|
|
|
1072c8 |
+ strerror(errno));
|
|
|
1072c8 |
+ }
|
|
|
1072c8 |
+ }
|
|
|
1072c8 |
+#endif
|
|
|
1072c8 |
|
|
|
1072c8 |
/* Resize and potentially preallocate the file to the desired
|
|
|
1072c8 |
* final size */
|
|
|
1072c8 |
@@ -2381,6 +2411,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
|
|
1072c8 |
{
|
|
|
1072c8 |
BlockdevCreateOptions options;
|
|
|
1072c8 |
int64_t total_size = 0;
|
|
|
1072c8 |
+ int64_t extent_size_hint = 0;
|
|
|
1072c8 |
+ bool has_extent_size_hint = false;
|
|
|
1072c8 |
bool nocow = false;
|
|
|
1072c8 |
PreallocMode prealloc;
|
|
|
1072c8 |
char *buf = NULL;
|
|
|
1072c8 |
@@ -2392,6 +2424,11 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
|
|
1072c8 |
/* Read out options */
|
|
|
1072c8 |
total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
|
|
|
1072c8 |
BDRV_SECTOR_SIZE);
|
|
|
1072c8 |
+ if (qemu_opt_get(opts, BLOCK_OPT_EXTENT_SIZE_HINT)) {
|
|
|
1072c8 |
+ has_extent_size_hint = true;
|
|
|
1072c8 |
+ extent_size_hint =
|
|
|
1072c8 |
+ qemu_opt_get_size_del(opts, BLOCK_OPT_EXTENT_SIZE_HINT, -1);
|
|
|
1072c8 |
+ }
|
|
|
1072c8 |
nocow = qemu_opt_get_bool(opts, BLOCK_OPT_NOCOW, false);
|
|
|
1072c8 |
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
|
|
|
1072c8 |
prealloc = qapi_enum_parse(&PreallocMode_lookup, buf,
|
|
|
1072c8 |
@@ -2411,6 +2448,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
|
|
1072c8 |
.preallocation = prealloc,
|
|
|
1072c8 |
.has_nocow = true,
|
|
|
1072c8 |
.nocow = nocow,
|
|
|
1072c8 |
+ .has_extent_size_hint = has_extent_size_hint,
|
|
|
1072c8 |
+ .extent_size_hint = extent_size_hint,
|
|
|
1072c8 |
},
|
|
|
1072c8 |
};
|
|
|
1072c8 |
return raw_co_create(&options, errp);
|
|
|
1072c8 |
@@ -2902,6 +2941,11 @@ static QemuOptsList raw_create_opts = {
|
|
|
1072c8 |
#endif
|
|
|
1072c8 |
", full)"
|
|
|
1072c8 |
},
|
|
|
1072c8 |
+ {
|
|
|
1072c8 |
+ .name = BLOCK_OPT_EXTENT_SIZE_HINT,
|
|
|
1072c8 |
+ .type = QEMU_OPT_SIZE,
|
|
|
1072c8 |
+ .help = "Extent size hint for the image file, 0 to disable"
|
|
|
1072c8 |
+ },
|
|
|
1072c8 |
{ /* end of list */ }
|
|
|
1072c8 |
}
|
|
|
1072c8 |
};
|
|
|
1072c8 |
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
|
|
1072c8 |
index 41f13ecbed..4b23da2eb0 100644
|
|
|
1072c8 |
--- a/include/block/block_int.h
|
|
|
1072c8 |
+++ b/include/block/block_int.h
|
|
|
1072c8 |
@@ -53,6 +53,7 @@
|
|
|
1072c8 |
#define BLOCK_OPT_ADAPTER_TYPE "adapter_type"
|
|
|
1072c8 |
#define BLOCK_OPT_REDUNDANCY "redundancy"
|
|
|
1072c8 |
#define BLOCK_OPT_NOCOW "nocow"
|
|
|
1072c8 |
+#define BLOCK_OPT_EXTENT_SIZE_HINT "extent_size_hint"
|
|
|
1072c8 |
#define BLOCK_OPT_OBJECT_SIZE "object_size"
|
|
|
1072c8 |
#define BLOCK_OPT_REFCOUNT_BITS "refcount_bits"
|
|
|
1072c8 |
#define BLOCK_OPT_DATA_FILE "data_file"
|
|
|
1072c8 |
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
|
|
1072c8 |
index 289320902d..c7aa919fa3 100644
|
|
|
1072c8 |
--- a/qapi/block-core.json
|
|
|
1072c8 |
+++ b/qapi/block-core.json
|
|
|
1072c8 |
@@ -4272,14 +4272,17 @@
|
|
|
1072c8 |
# falloc (if defined CONFIG_POSIX_FALLOCATE),
|
|
|
1072c8 |
# full (if defined CONFIG_POSIX))
|
|
|
1072c8 |
# @nocow Turn off copy-on-write (valid only on btrfs; default: off)
|
|
|
1072c8 |
+# @extent-size-hint: Extent size hint to add to the image file; 0 for not
|
|
|
1072c8 |
+# adding an extent size hint (default: 1 MB, since 5.1)
|
|
|
1072c8 |
#
|
|
|
1072c8 |
# Since: 2.12
|
|
|
1072c8 |
##
|
|
|
1072c8 |
{ 'struct': 'BlockdevCreateOptionsFile',
|
|
|
1072c8 |
- 'data': { 'filename': 'str',
|
|
|
1072c8 |
- 'size': 'size',
|
|
|
1072c8 |
- '*preallocation': 'PreallocMode',
|
|
|
1072c8 |
- '*nocow': 'bool' } }
|
|
|
1072c8 |
+ 'data': { 'filename': 'str',
|
|
|
1072c8 |
+ 'size': 'size',
|
|
|
1072c8 |
+ '*preallocation': 'PreallocMode',
|
|
|
1072c8 |
+ '*nocow': 'bool',
|
|
|
1072c8 |
+ '*extent-size-hint': 'size'} }
|
|
|
1072c8 |
|
|
|
1072c8 |
##
|
|
|
1072c8 |
# @BlockdevCreateOptionsGluster:
|
|
|
1072c8 |
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
|
|
|
1072c8 |
index 9d4ed4dc9d..7a87946fa2 100644
|
|
|
1072c8 |
--- a/tests/qemu-iotests/082.out
|
|
|
1072c8 |
+++ b/tests/qemu-iotests/082.out
|
|
|
1072c8 |
@@ -59,6 +59,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -82,6 +83,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -105,6 +107,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -128,6 +131,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -151,6 +155,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -174,6 +179,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -197,6 +203,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -220,6 +227,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -339,6 +347,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -362,6 +371,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -385,6 +395,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -408,6 +419,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -431,6 +443,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -454,6 +467,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -477,6 +491,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
@@ -500,6 +515,7 @@ Supported options:
|
|
|
1072c8 |
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
|
|
|
1072c8 |
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
|
|
|
1072c8 |
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
|
|
|
1072c8 |
+ extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
|
|
|
1072c8 |
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
|
|
|
1072c8 |
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
|
|
|
1072c8 |
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
1072c8 |
diff --git a/tests/qemu-iotests/106 b/tests/qemu-iotests/106
|
|
|
1072c8 |
index ac47eaa0f5..ee6f51d08b 100755
|
|
|
1072c8 |
--- a/tests/qemu-iotests/106
|
|
|
1072c8 |
+++ b/tests/qemu-iotests/106
|
|
|
1072c8 |
@@ -51,7 +51,10 @@ for create_mode in off falloc full; do
|
|
|
1072c8 |
echo
|
|
|
1072c8 |
echo "--- create_mode=$create_mode growth_mode=$growth_mode ---"
|
|
|
1072c8 |
|
|
|
1072c8 |
- IMGOPTS="preallocation=$create_mode" _make_test_img ${CREATION_SIZE}K
|
|
|
1072c8 |
+ # Our calculation below assumes kilobytes as unit for the actual size.
|
|
|
1072c8 |
+ # Disable the extent size hint because it would give us a result in
|
|
|
1072c8 |
+ # megabytes.
|
|
|
1072c8 |
+ IMGOPTS="preallocation=$create_mode,extent_size_hint=0" _make_test_img ${CREATION_SIZE}K
|
|
|
1072c8 |
$QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K
|
|
|
1072c8 |
|
|
|
1072c8 |
expected_size=0
|
|
|
1072c8 |
@@ -98,7 +101,7 @@ for growth_mode in falloc full; do
|
|
|
1072c8 |
# plain int. We should use the correct type for the result, and
|
|
|
1072c8 |
# this tests we do.
|
|
|
1072c8 |
|
|
|
1072c8 |
- _make_test_img 2G
|
|
|
1072c8 |
+ _make_test_img -o "extent_size_hint=0" 2G
|
|
|
1072c8 |
$QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K
|
|
|
1072c8 |
|
|
|
1072c8 |
actual_size=$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'disk size')
|
|
|
1072c8 |
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
|
|
|
1072c8 |
index 55db2803ed..8a8494aeb6 100755
|
|
|
1072c8 |
--- a/tests/qemu-iotests/175
|
|
|
1072c8 |
+++ b/tests/qemu-iotests/175
|
|
|
1072c8 |
@@ -89,20 +89,20 @@ min_blocks=$(stat -c '%b' "$TEST_DIR/empty")
|
|
|
1072c8 |
|
|
|
1072c8 |
echo
|
|
|
1072c8 |
echo "== creating image with default preallocation =="
|
|
|
1072c8 |
-_make_test_img $size | _filter_imgfmt
|
|
|
1072c8 |
+_make_test_img -o extent_size_hint=0 $size | _filter_imgfmt
|
|
|
1072c8 |
stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
|
|
|
1072c8 |
|
|
|
1072c8 |
for mode in off full falloc; do
|
|
|
1072c8 |
echo
|
|
|
1072c8 |
echo "== creating image with preallocation $mode =="
|
|
|
1072c8 |
- IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt
|
|
|
1072c8 |
+ IMGOPTS="preallocation=$mode,extent_size_hint=0" _make_test_img $size | _filter_imgfmt
|
|
|
1072c8 |
stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
|
|
|
1072c8 |
done
|
|
|
1072c8 |
|
|
|
1072c8 |
for new_size in 4096 1048576; do
|
|
|
1072c8 |
echo
|
|
|
1072c8 |
echo "== resize empty image with block_resize =="
|
|
|
1072c8 |
- _make_test_img 0 | _filter_imgfmt
|
|
|
1072c8 |
+ _make_test_img -o extent_size_hint=0 0 | _filter_imgfmt
|
|
|
1072c8 |
_block_resize $TEST_IMG $new_size >/dev/null
|
|
|
1072c8 |
stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $new_size
|
|
|
1072c8 |
done
|
|
|
1072c8 |
diff --git a/tests/qemu-iotests/243 b/tests/qemu-iotests/243
|
|
|
1072c8 |
index e563761307..104c7256c4 100755
|
|
|
1072c8 |
--- a/tests/qemu-iotests/243
|
|
|
1072c8 |
+++ b/tests/qemu-iotests/243
|
|
|
1072c8 |
@@ -47,7 +47,7 @@ for mode in off metadata falloc full; do
|
|
|
1072c8 |
echo "=== preallocation=$mode ==="
|
|
|
1072c8 |
echo
|
|
|
1072c8 |
|
|
|
1072c8 |
- IMGOPTS="preallocation=$mode" _make_test_img 64M
|
|
|
1072c8 |
+ IMGOPTS="preallocation=$mode,extent_size_hint=0" _make_test_img 64M
|
|
|
1072c8 |
|
|
|
1072c8 |
printf "File size: "
|
|
|
1072c8 |
du -b $TEST_IMG | cut -f1
|
|
|
1072c8 |
@@ -64,7 +64,7 @@ for mode in off metadata falloc full; do
|
|
|
1072c8 |
echo "=== External data file: preallocation=$mode ==="
|
|
|
1072c8 |
echo
|
|
|
1072c8 |
|
|
|
1072c8 |
- IMGOPTS="data_file=$TEST_IMG.data,preallocation=$mode" _make_test_img 64M
|
|
|
1072c8 |
+ IMGOPTS="data_file=$TEST_IMG.data,preallocation=$mode,extent_size_hint=0" _make_test_img 64M
|
|
|
1072c8 |
|
|
|
1072c8 |
echo -n "qcow2 file size: "
|
|
|
1072c8 |
du -b $TEST_IMG | cut -f1
|
|
|
1072c8 |
@@ -75,7 +75,7 @@ for mode in off metadata falloc full; do
|
|
|
1072c8 |
echo -n "qcow2 disk usage: "
|
|
|
1072c8 |
[ $(du -B1 $TEST_IMG | cut -f1) -lt 1048576 ] && echo "low" || echo "high"
|
|
|
1072c8 |
echo -n "data disk usage: "
|
|
|
1072c8 |
- [ $(du -B1 $TEST_IMG.data | cut -f1) -lt 1048576 ] && echo "low" || echo "high"
|
|
|
1072c8 |
+ [ $(du -B1 $TEST_IMG.data | cut -f1) -lt 2097152 ] && echo "low" || echo "high"
|
|
|
1072c8 |
|
|
|
1072c8 |
done
|
|
|
1072c8 |
|
|
|
1072c8 |
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
|
|
|
1072c8 |
index c8e8663665..f29c1d3238 100644
|
|
|
1072c8 |
--- a/tests/qemu-iotests/common.filter
|
|
|
1072c8 |
+++ b/tests/qemu-iotests/common.filter
|
|
|
1072c8 |
@@ -146,6 +146,7 @@ _filter_img_create()
|
|
|
1072c8 |
-e "s# refcount_bits=[0-9]\\+##g" \
|
|
|
1072c8 |
-e "s# key-secret=[a-zA-Z0-9]\\+##g" \
|
|
|
1072c8 |
-e "s# iter-time=[0-9]\\+##g" \
|
|
|
1072c8 |
+ -e "s# extent_size_hint=[0-9]\\+##g" \
|
|
|
1072c8 |
-e "s# force_size=\\(on\\|off\\)##g"
|
|
|
1072c8 |
}
|
|
|
1072c8 |
|
|
|
1072c8 |
--
|
|
|
1072c8 |
2.27.0
|
|
|
1072c8 |
|