105 lines
3.3 KiB
Diff
105 lines
3.3 KiB
Diff
From 636e32b4c570ddb20266b6672311174353644f0e Mon Sep 17 00:00:00 2001
|
|
From: Keith Busch <kbusch@kernel.org>
|
|
Date: Thu, 29 Sep 2022 13:05:22 -0700
|
|
Subject: [PATCH 1/2] block: move bdrv_qiov_is_aligned to file-posix
|
|
|
|
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
RH-MergeRequest: 411: block: Fix iov_len check in bdrv_qiov_is_aligned()
|
|
RH-Jira: RHEL-60553
|
|
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
|
|
RH-Commit: [1/2] 682c1b81b42959d9d91e0f68cd70e9753e53a279
|
|
|
|
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 | 20 ++++++++++++++++++++
|
|
block/io.c | 20 --------------------
|
|
include/block/block.h | 1 -
|
|
3 files changed, 20 insertions(+), 21 deletions(-)
|
|
|
|
diff --git a/block/file-posix.c b/block/file-posix.c
|
|
index b283093e5b..b404e1544f 100644
|
|
--- a/block/file-posix.c
|
|
+++ b/block/file-posix.c
|
|
@@ -2051,6 +2051,26 @@ 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);
|
|
+
|
|
+ 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 8ae57728a6..639e171eff 100644
|
|
--- a/block/io.c
|
|
+++ b/block/io.c
|
|
@@ -3375,26 +3375,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);
|
|
-
|
|
- 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.h b/include/block/block.h
|
|
index f885f113ef..09b374b496 100644
|
|
--- a/include/block/block.h
|
|
+++ b/include/block/block.h
|
|
@@ -622,7 +622,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.45.2
|
|
|