[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4/6] file-posix: Support BDRV_REQ_NO_FALLBACK for ze
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 4/6] file-posix: Support BDRV_REQ_NO_FALLBACK for zero writes |
Date: |
Fri, 22 Mar 2019 14:21:45 +0100 |
We know that the kernel implements a slow fallback code path for
BLKZEROOUT, so if BDRV_REQ_NO_FALLBACK is given, we shouldn't call it.
The other operations we call in the context of .bdrv_co_pwrite_zeroes
should usually be quick, so no modification should be needed for them.
If we ever notice that there are additional problematic cases, we can
still make these conditional as well.
Signed-off-by: Kevin Wolf <address@hidden>
---
include/block/raw-aio.h | 1 +
block/file-posix.c | 24 ++++++++++++++++--------
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/include/block/raw-aio.h b/include/block/raw-aio.h
index 6799614e56..ba223dd1f1 100644
--- a/include/block/raw-aio.h
+++ b/include/block/raw-aio.h
@@ -40,6 +40,7 @@
/* AIO flags */
#define QEMU_AIO_MISALIGNED 0x1000
#define QEMU_AIO_BLKDEV 0x2000
+#define QEMU_AIO_NO_FALLBACK 0x4000
/* linux-aio.c - Linux native implementation */
diff --git a/block/file-posix.c b/block/file-posix.c
index d102f3b222..db4cccbe51 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -652,7 +652,7 @@ static int raw_open_common(BlockDriverState *bs, QDict
*options,
}
#endif
- bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP;
+ bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK;
ret = 0;
fail:
if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) {
@@ -1500,14 +1500,19 @@ static ssize_t
handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb)
}
#ifdef BLKZEROOUT
- do {
- uint64_t range[2] = { aiocb->aio_offset, aiocb->aio_nbytes };
- if (ioctl(aiocb->aio_fildes, BLKZEROOUT, range) == 0) {
- return 0;
- }
- } while (errno == EINTR);
+ /* The BLKZEROOUT implementation in the kernel doesn't set
+ * BLKDEV_ZERO_NOFALLBACK, so we can't call this if we have to avoid slow
+ * fallbacks. */
+ if (!(aiocb->aio_type & QEMU_AIO_NO_FALLBACK)) {
+ do {
+ uint64_t range[2] = { aiocb->aio_offset, aiocb->aio_nbytes };
+ if (ioctl(aiocb->aio_fildes, BLKZEROOUT, range) == 0) {
+ return 0;
+ }
+ } while (errno == EINTR);
- ret = translate_err(-errno);
+ ret = translate_err(-errno);
+ }
#endif
if (ret == -ENOTSUP) {
@@ -2659,6 +2664,9 @@ raw_do_pwrite_zeroes(BlockDriverState *bs, int64_t
offset, int bytes,
if (blkdev) {
acb.aio_type |= QEMU_AIO_BLKDEV;
}
+ if (flags & BDRV_REQ_NO_FALLBACK) {
+ acb.aio_type |= QEMU_AIO_NO_FALLBACK;
+ }
if (flags & BDRV_REQ_MAY_UNMAP) {
acb.aio_type |= QEMU_AIO_DISCARD;
--
2.20.1
- [Qemu-devel] [PATCH 0/6] block: Fix slow pre-zeroing in qemu-img convert, Kevin Wolf, 2019/03/22
- [Qemu-devel] [PATCH 6/6] qemu-io: Add write -n for BDRV_REQ_NO_FALLBACK, Kevin Wolf, 2019/03/22
- [Qemu-devel] [PATCH 3/6] block: Advertise BDRV_REQ_NO_FALLBACK in filter drivers, Kevin Wolf, 2019/03/22
- [Qemu-devel] [PATCH 2/6] block: Add BDRV_REQ_NO_FALLBACK, Kevin Wolf, 2019/03/22
- [Qemu-devel] [PATCH 5/6] qemu-img: Use BDRV_REQ_NO_FALLBACK for pre-zeroing, Kevin Wolf, 2019/03/22
- [Qemu-devel] [PATCH 4/6] file-posix: Support BDRV_REQ_NO_FALLBACK for zero writes,
Kevin Wolf <=
- [Qemu-devel] [PATCH 1/6] block: Remove error messages in bdrv_make_zero(), Kevin Wolf, 2019/03/22
- Re: [Qemu-devel] [PATCH 0/6] block: Fix slow pre-zeroing in qemu-img convert, Eric Blake, 2019/03/22
- Re: [Qemu-devel] [PATCH 0/6] block: Fix slow pre-zeroing in qemu-img convert, Nir Soffer, 2019/03/22
- Re: [Qemu-devel] [PATCH 0/6] block: Fix slow pre-zeroing in qemu-img convert, Kevin Wolf, 2019/03/25