qemu-7.0.0-14

block: Fix memory alignment of requests (rhbz#2174139)
This commit is contained in:
Eduardo Lima (Etrunko) 2023-02-28 16:59:49 -03:00
parent ce7904b88e
commit 09bf21d16d
3 changed files with 149 additions and 1 deletions

View File

@ -0,0 +1,99 @@
From 2b30e95684fec72e1c2db9dd350cb6967181b825 Mon Sep 17 00:00:00 2001
From: Keith Busch <kbusch@kernel.org>
Date: Thu, 29 Sep 2022 13:05:22 -0700
Subject: [PATCH] block: move bdrv_qiov_is_aligned to file-posix
There is only user of bdrv_qiov_is_aligned(), so move the alignment
function to there and make it static.
Signed-off-by: Keith Busch <kbusch@kernel.org>
Message-Id: <20220929200523.3218710-2-kbusch@meta.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit a7c5f67a78569f8c275ea4ea9962e9c79b9d03cb)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/file-posix.c | 21 +++++++++++++++++++++
block/io.c | 21 ---------------------
include/block/block-io.h | 1 -
3 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index 39a3d6d..0185b4e 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2047,6 +2047,27 @@ static int coroutine_fn raw_thread_pool_submit(BlockDriverState *bs,
return thread_pool_submit_co(pool, func, arg);
}
+/*
+ * Check if all memory in this vector is sector aligned.
+ */
+static bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov)
+{
+ int i;
+ size_t alignment = bdrv_min_mem_align(bs);
+ IO_CODE();
+
+ for (i = 0; i < qiov->niov; i++) {
+ if ((uintptr_t) qiov->iov[i].iov_base % alignment) {
+ return false;
+ }
+ if (qiov->iov[i].iov_len % alignment) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
static int coroutine_fn raw_co_prw(BlockDriverState *bs, uint64_t offset,
uint64_t bytes, QEMUIOVector *qiov, int type)
{
diff --git a/block/io.c b/block/io.c
index 3280144..e44fc43 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3296,27 +3296,6 @@ void *qemu_try_blockalign0(BlockDriverState *bs, size_t size)
return mem;
}
-/*
- * Check if all memory in this vector is sector aligned.
- */
-bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov)
-{
- int i;
- size_t alignment = bdrv_min_mem_align(bs);
- IO_CODE();
-
- for (i = 0; i < qiov->niov; i++) {
- if ((uintptr_t) qiov->iov[i].iov_base % alignment) {
- return false;
- }
- if (qiov->iov[i].iov_len % alignment) {
- return false;
- }
- }
-
- return true;
-}
-
void bdrv_io_plug(BlockDriverState *bs)
{
BdrvChild *child;
diff --git a/include/block/block-io.h b/include/block/block-io.h
index 5e3f346..80810e1 100644
--- a/include/block/block-io.h
+++ b/include/block/block-io.h
@@ -141,7 +141,6 @@ void *qemu_blockalign(BlockDriverState *bs, size_t size);
void *qemu_blockalign0(BlockDriverState *bs, size_t size);
void *qemu_try_blockalign(BlockDriverState *bs, size_t size);
void *qemu_try_blockalign0(BlockDriverState *bs, size_t size);
-bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov);
void bdrv_enable_copy_on_read(BlockDriverState *bs);
void bdrv_disable_copy_on_read(BlockDriverState *bs);
--
2.39.2

View File

@ -0,0 +1,42 @@
From cd316ab11b01b3470148612e6df9891faf1fb311 Mon Sep 17 00:00:00 2001
From: Keith Busch <kbusch@kernel.org>
Date: Thu, 29 Sep 2022 13:05:23 -0700
Subject: [PATCH] block: use the request length for iov alignment
An iov length needs to be aligned to the logical block size, which may
be larger than the memory alignment.
Tested-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Message-Id: <20220929200523.3218710-3-kbusch@meta.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 25474d90aa50bd32e0de395a33d8de42dd6f2aef)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/file-posix.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index 0185b4e..6818b0e 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2054,13 +2054,14 @@ static bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov)
{
int i;
size_t alignment = bdrv_min_mem_align(bs);
+ size_t len = bs->bl.request_alignment;
IO_CODE();
for (i = 0; i < qiov->niov; i++) {
if ((uintptr_t) qiov->iov[i].iov_base % alignment) {
return false;
}
- if (qiov->iov[i].iov_len % alignment) {
+ if (qiov->iov[i].iov_len % len) {
return false;
}
}
--
2.39.2

View File

@ -317,7 +317,7 @@ Obsoletes: %{name}-system-unicore32-core <= %{epoch}:%{version}-%{release}
%endif
# To prevent rpmdev-bumpspec breakage
%global baserelease 13
%global baserelease 14
Summary: QEMU is a FAST! processor emulator
Name: qemu
@ -374,6 +374,10 @@ Patch: 0019-hw-acpi-erst.c-Fix-memory-handling-issues.patch
Patch: 0020-hw-display-qxl-Avoid-buffer-overrun-qxl_phys2virt.patch
# linux-user: default to -cpu max (rhbz#2121700)
Patch: 0021-linux-user-use-max-instead-of-qemu32-qemu64-by-default.patch
#block: Fix memory alignment of requests (rhbz#2174139)
Patch: 0022-block-move-bdrv_qiov_is_aligned-to-file-posix.patch
Patch: 0023-block-use-the-request-length-for-iov-alignment.patch
BuildRequires: meson >= %{meson_version}
BuildRequires: zlib-devel
@ -2738,6 +2742,9 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
%changelog
* Tue Feb 28 2023 Eduardo Lima (Etrunko) <etrunko@redhat.com> - 2:7.0.0-14
- block: Fix memory alignment of requests (rhbz#2174139)
* Thu Jan 19 2023 Christophe Fergeau <cfergeau@redhat.com> - 2:7.0.0-13
- linux-user: default to -cpu max (rhbz#2121700)