From 9bf7a8d4e8e24c81eee0ce5d701f45d5042a3f88 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 28 Feb 2012 12:51:32 +0100 Subject: [PATCH 05/12] raw-posix: do not linearize anymore direct I/O on Linux NFS RH-Author: Paolo Bonzini Message-id: <1330433492-21346-1-git-send-email-pbonzini@redhat.com> Patchwork-id: 37666 O-Subject: [RHEL 6.3 qemu-kvm PATCH] raw-posix: do not linearize anymore direct I/O on Linux NFS Bugzilla: 767606 RH-Acked-by: Laszlo Ersek RH-Acked-by: Markus Armbruster RH-Acked-by: Kevin Wolf RH-Acked-by: Luiz Capitulino Bugzilla: 767606 Upstream status: N/A Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=4092755 In bug 711213 we introduced a hack in QEMU (called linearized QEMU hack) where we use bounce buffers for NFS underlying storage because the NFS client does not support vector I/O for performance reasons. However, the NFS client in RHEL6.2 can now support vector I/O (commit 3367130f) and IBM's latest testing indicates that it can achieve the same performance level as the linearized QEMU hack, so we can now safely remove this hack from QEMU. Signed-off-by: Paolo Bonzini --- block/raw-posix.c | 59 +++++++--------------------------------------------- 1 files changed, 8 insertions(+), 51 deletions(-) Signed-off-by: Michal Novotny --- block/raw-posix.c | 59 +++++++--------------------------------------------- 1 files changed, 8 insertions(+), 51 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 1a6d191..256beb9 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -50,10 +50,8 @@ #endif #ifdef __linux__ #include -#include #include #include -#include #endif #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) #include @@ -127,7 +125,6 @@ typedef struct BDRVRawState { #endif uint8_t *aligned_buf; unsigned aligned_buf_size; - bool force_linearize; #ifdef CONFIG_XFS bool is_xfs : 1; #endif @@ -140,38 +137,6 @@ static int64_t raw_getlength(BlockDriverState *bs); static int cdrom_reopen(BlockDriverState *bs); #endif -#if defined(__linux__) -static bool is_vectored_io_slow(int fd, int bdrv_flags) -{ - struct statfs stfs; - int ret; - char *env_flag = getenv("QEMU_FORCE_LINEARIZE"); - - if (env_flag && strcasecmp(env_flag, "off") == 0) { - return false; - } - - do { - ret = fstatfs(fd, &stfs); - } while (ret != 0 && errno == EINTR); - - /* - * Linux NFS client splits vectored direct I/O requests into separate NFS - * requests so it is faster to submit a single buffer instead. - */ - if (!ret && stfs.f_type == NFS_SUPER_MAGIC && - (bdrv_flags & BDRV_O_NOCACHE)) { - return true; - } - return false; -} -#else /* !defined(__linux__) */ -static bool is_vectored_io_slow(int fd, int bdrv_flags) -{ - return false; -} -#endif - static int raw_open_common(BlockDriverState *bs, const char *filename, int bdrv_flags, int open_flags) { @@ -204,7 +169,6 @@ static int raw_open_common(BlockDriverState *bs, const char *filename, } s->fd = fd; s->aligned_buf = NULL; - s->force_linearize = is_vectored_io_slow(fd, bdrv_flags); if ((bdrv_flags & BDRV_O_NOCACHE)) { /* @@ -310,27 +274,20 @@ static BlockDriverAIOCB *raw_aio_submit(BlockDriverState *bs, return NULL; /* - * Check if buffers need to be copied into a single linear buffer. - */ - if (s->force_linearize && qiov->niov > 1) { - type |= QEMU_AIO_MISALIGNED; - } - - /* * If O_DIRECT is used the buffer needs to be aligned on a sector * boundary. Check if this is the case or telll the low-level * driver that it needs to copy the buffer. */ - if (s->aligned_buf && !qiov_is_aligned(bs, qiov)) { - type |= QEMU_AIO_MISALIGNED; - } - + if (s->aligned_buf) { + if (!qiov_is_aligned(bs, qiov)) { + type |= QEMU_AIO_MISALIGNED; #ifdef CONFIG_LINUX_AIO - if (s->use_aio && (type & QEMU_AIO_MISALIGNED) == 0) { - return laio_submit(bs, s->aio_ctx, s->fd, sector_num, qiov, - nb_sectors, cb, opaque, type); - } + } else if (s->use_aio) { + return laio_submit(bs, s->aio_ctx, s->fd, sector_num, qiov, + nb_sectors, cb, opaque, type); #endif + } + } return paio_submit(bs, s->fd, sector_num, qiov, nb_sectors, cb, opaque, type); -- 1.7.7.6