qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH V2] block/io: optimize bdrv_co_pwritev for small requests
@ 2016-05-24 14:30 Peter Lieven
  2016-05-24 15:07 ` Kevin Wolf
  2016-05-26  6:50 ` Fam Zheng
  0 siblings, 2 replies; 16+ messages in thread
From: Peter Lieven @ 2016-05-24 14:30 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, famz, kwolf, stefanha, mreitz, Peter Lieven

in a read-modify-write cycle a small request might cause
head and tail to fall into the same aligned block. Currently
QEMU reads the same block twice in this case which is
not necessary.

Signed-off-by: Peter Lieven <pl@kamp.de>
---
v1->v2: following Paolos suggestions to simplify the if condition and
        adjusting the comment

 block/io.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/block/io.c b/block/io.c
index 60a6bd8..7459dfb 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1430,6 +1430,14 @@ int coroutine_fn bdrv_co_pwritev(BlockDriverState *bs,
 
         bytes += offset & (align - 1);
         offset = offset & ~(align - 1);
+
+        /* We have read the tail already if the request is smaller
+         * than one aligned block.
+         */
+        if (bytes < align) {
+            qemu_iovec_add(&local_qiov, head_buf + bytes, align - bytes);
+            bytes = align;
+        }
     }
 
     if ((offset + bytes) & (align - 1)) {
-- 
1.9.1

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

end of thread, other threads:[~2016-05-30 10:10 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-24 14:30 [Qemu-devel] [PATCH V2] block/io: optimize bdrv_co_pwritev for small requests Peter Lieven
2016-05-24 15:07 ` Kevin Wolf
2016-05-26  6:50 ` Fam Zheng
2016-05-26  7:10   ` Fam Zheng
2016-05-26  7:55     ` Paolo Bonzini
2016-05-26  8:30       ` Fam Zheng
2016-05-26  9:20         ` Paolo Bonzini
2016-05-27  0:36           ` Fam Zheng
2016-05-27  8:55             ` Kevin Wolf
2016-05-30  6:25               ` Peter Lieven
2016-05-30  8:24                 ` Kevin Wolf
2016-05-30  9:30                   ` Peter Lieven
2016-05-30  9:47                     ` Kevin Wolf
2016-05-30  9:53                       ` Peter Lieven
2016-05-30 10:06                         ` Kevin Wolf
2016-05-30 10:10                           ` Peter Lieven

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).