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