[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 06/17] block: introduce bdrv_co_can_bypass_co
From: |
Ming Lei |
Subject: |
[Qemu-devel] [PATCH v1 06/17] block: introduce bdrv_co_can_bypass_co |
Date: |
Tue, 5 Aug 2014 11:33:07 +0800 |
This function is introduced to check if the current block
I/O can be allowed to run without coroutine for sake of
performance.
Signed-off-by: Ming Lei <address@hidden>
---
block.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/block.c b/block.c
index ac184ef..2326dab 100644
--- a/block.c
+++ b/block.c
@@ -4718,6 +4718,44 @@ static void coroutine_fn bdrv_co_do_rw(void *opaque)
qemu_bh_schedule(acb->bh);
}
+static bool bdrv_rw_aligned(BlockDriverState *bs,
+ int64_t offset,
+ int bytes)
+{
+ uint64_t align = MAX(BDRV_SECTOR_SIZE, bs->request_alignment);
+
+ if ((offset & (align - 1)) || ((offset + bytes) & (align - 1))) {
+ return false;
+ } else {
+ return true;
+ }
+}
+
+static bool bdrv_co_can_bypass_co(BlockDriverState *bs,
+ int64_t sector_num,
+ int nb_sectors,
+ BdrvRequestFlags flags,
+ bool is_write)
+{
+ if (flags || bs->copy_on_read || bs->io_limits_enabled) {
+ return false;
+ }
+
+ /* unaligned read is safe */
+ if (!is_write) {
+ return true;
+ }
+
+ if (!bs->enable_write_cache ||
+ bs->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF ||
+ !QLIST_EMPTY(&bs->before_write_notifiers.notifiers)) {
+ return false;
+ } else {
+ return bdrv_rw_aligned(bs, sector_num << BDRV_SECTOR_BITS,
+ nb_sectors << BDRV_SECTOR_BITS);
+ }
+}
+
static BlockDriverAIOCB *bdrv_co_aio_rw_vector(BlockDriverState *bs,
int64_t sector_num,
QEMUIOVector *qiov,
--
1.7.9.5
- Re: [Qemu-devel] [PATCH v1 01/17] qemu/obj_pool.h: introduce object allocation pool, (continued)
- [Qemu-devel] [PATCH v1 02/17] dataplane: use object pool to speed up allocation for virtio blk request, Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 03/17] qemu coroutine: support bypass mode, Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 04/17] block: prepare for supporting selective bypass coroutine, Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 05/17] garbage collector: introduced for support of bypass coroutine, Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 06/17] block: introduce bdrv_co_can_bypass_co,
Ming Lei <=
- [Qemu-devel] [PATCH v1 07/17] block: support to bypass qemu coroutinue, Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 08/17] Revert "raw-posix: drop raw_get_aio_fd() since it is no longer used", Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 09/17] dataplane: enable selective bypassing coroutine, Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 10/17] linux-aio: fix submit aio as a batch, Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 11/17] linux-aio: handling -EAGAIN for !s->io_q.plugged case, Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 12/17] linux-aio: increase max event to 256, Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 13/17] linux-aio: remove 'node' from 'struct qemu_laiocb', Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 14/17] hw/virtio/virtio-blk.h: introduce VIRTIO_BLK_F_MQ, Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 15/17] virtio-blk: support multi queue for non-dataplane, Ming Lei, 2014/08/04
- [Qemu-devel] [PATCH v1 16/17] virtio-blk: dataplane: support multi virtqueue, Ming Lei, 2014/08/04