qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv3 0/2] qemu direct io alignment fix
@ 2022-09-29 20:05 Keith Busch
  2022-09-29 20:05 ` [PATCHv3 1/2] block: move bdrv_qiov_is_aligned to file-posix Keith Busch
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Keith Busch @ 2022-09-29 20:05 UTC (permalink / raw)
  To: qemu-block, Kevin Wolf, qemu-devel, Paolo Bonzini
  Cc: Stefan Hajnoczi, Jens Axboe, Damien Le Moal, Maxim Levitsky, kvm,
	Keith Busch

From: Keith Busch <kbusch@kernel.org>

Changes from v2:

  Split the patch so that the function move is separate from the
  functional change. This makes it immediately obvious what criteria is
  changing. (Kevin Wolf)

  Added received Tested-by tag in the changelog. 

Keith Busch (2):
  block: move bdrv_qiov_is_aligned to file-posix
  block: use the request length for iov alignment

 block/file-posix.c       | 22 ++++++++++++++++++++++
 block/io.c               | 21 ---------------------
 include/block/block-io.h |  1 -
 3 files changed, 22 insertions(+), 22 deletions(-)

-- 
2.30.2



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCHv3 1/2] block: move bdrv_qiov_is_aligned to file-posix
  2022-09-29 20:05 [PATCHv3 0/2] qemu direct io alignment fix Keith Busch
@ 2022-09-29 20:05 ` Keith Busch
  2022-09-29 20:05 ` [PATCHv3 2/2] block: use the request length for iov alignment Keith Busch
  2022-09-30 10:18 ` [PATCHv3 0/2] qemu direct io alignment fix Kevin Wolf
  2 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2022-09-29 20:05 UTC (permalink / raw)
  To: qemu-block, Kevin Wolf, qemu-devel, Paolo Bonzini
  Cc: Stefan Hajnoczi, Jens Axboe, Damien Le Moal, Maxim Levitsky, kvm,
	Keith Busch

From: Keith Busch <kbusch@kernel.org>

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>
---
 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 48cd096624..e3f3de2780 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2061,6 +2061,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 0a8cbefe86..96edc7f7cb 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3236,27 +3236,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 fd25ffa9be..492f95fc05 100644
--- a/include/block/block-io.h
+++ b/include/block/block-io.h
@@ -150,7 +150,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.30.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCHv3 2/2] block: use the request length for iov alignment
  2022-09-29 20:05 [PATCHv3 0/2] qemu direct io alignment fix Keith Busch
  2022-09-29 20:05 ` [PATCHv3 1/2] block: move bdrv_qiov_is_aligned to file-posix Keith Busch
@ 2022-09-29 20:05 ` Keith Busch
  2022-09-30 10:18 ` [PATCHv3 0/2] qemu direct io alignment fix Kevin Wolf
  2 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2022-09-29 20:05 UTC (permalink / raw)
  To: qemu-block, Kevin Wolf, qemu-devel, Paolo Bonzini
  Cc: Stefan Hajnoczi, Jens Axboe, Damien Le Moal, Maxim Levitsky, kvm,
	Keith Busch

From: Keith Busch <kbusch@kernel.org>

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>
---
 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 e3f3de2780..af994aba2b 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2068,13 +2068,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.30.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCHv3 0/2] qemu direct io alignment fix
  2022-09-29 20:05 [PATCHv3 0/2] qemu direct io alignment fix Keith Busch
  2022-09-29 20:05 ` [PATCHv3 1/2] block: move bdrv_qiov_is_aligned to file-posix Keith Busch
  2022-09-29 20:05 ` [PATCHv3 2/2] block: use the request length for iov alignment Keith Busch
@ 2022-09-30 10:18 ` Kevin Wolf
  2 siblings, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2022-09-30 10:18 UTC (permalink / raw)
  To: Keith Busch
  Cc: qemu-block, qemu-devel, Paolo Bonzini, Stefan Hajnoczi,
	Jens Axboe, Damien Le Moal, Maxim Levitsky, kvm, Keith Busch

Am 29.09.2022 um 22:05 hat Keith Busch geschrieben:
> From: Keith Busch <kbusch@kernel.org>
> 
> Changes from v2:
> 
>   Split the patch so that the function move is separate from the
>   functional change. This makes it immediately obvious what criteria is
>   changing. (Kevin Wolf)
> 
>   Added received Tested-by tag in the changelog. 
> 
> Keith Busch (2):
>   block: move bdrv_qiov_is_aligned to file-posix
>   block: use the request length for iov alignment

Thanks, applied to the block branch.

Kevin



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-30 10:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-29 20:05 [PATCHv3 0/2] qemu direct io alignment fix Keith Busch
2022-09-29 20:05 ` [PATCHv3 1/2] block: move bdrv_qiov_is_aligned to file-posix Keith Busch
2022-09-29 20:05 ` [PATCHv3 2/2] block: use the request length for iov alignment Keith Busch
2022-09-30 10:18 ` [PATCHv3 0/2] qemu direct io alignment fix Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).