X-Git-Url: https://git.proxmox.com/?p=pve-qemu.git;a=blobdiff_plain;f=debian%2Fpatches%2Fpve%2F0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch;fp=debian%2Fpatches%2Fpve%2F0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch;h=893104a6907a79569fad0e5c399572aac5287517;hp=0000000000000000000000000000000000000000;hb=5b15e2ecaf054107200a49c7d2509053fb91c9fe;hpb=2775b2e3788bfed64345046ce6a669bcdf28eb43 diff --git a/debian/patches/pve/0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch b/debian/patches/pve/0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch new file mode 100644 index 0000000..893104a --- /dev/null +++ b/debian/patches/pve/0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch @@ -0,0 +1,53 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Stefan Reiter +Date: Wed, 9 Dec 2020 11:46:57 +0100 +Subject: [PATCH] PVE: block/pbs: fast-path reads without allocation if + possible + +...and switch over to g_malloc/g_free while at it to align with other +QEMU code. + +Tracing shows the fast-path is taken almost all the time, though not +100% so the slow one is still necessary. + +Signed-off-by: Stefan Reiter +Signed-off-by: Thomas Lamprecht +--- + block/pbs.c | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +diff --git a/block/pbs.c b/block/pbs.c +index 0b05ea9080..c5eb4d5bad 100644 +--- a/block/pbs.c ++++ b/block/pbs.c +@@ -200,7 +200,16 @@ static coroutine_fn int pbs_co_preadv(BlockDriverState *bs, + BDRVPBSState *s = bs->opaque; + int ret; + char *pbs_error = NULL; +- uint8_t *buf = malloc(bytes); ++ uint8_t *buf; ++ bool inline_buf = true; ++ ++ /* for single-buffer IO vectors we can fast-path the write directly to it */ ++ if (qiov->niov == 1 && qiov->iov->iov_len >= bytes) { ++ buf = qiov->iov->iov_base; ++ } else { ++ inline_buf = false; ++ buf = g_malloc(bytes); ++ } + + if (offset < 0 || bytes < 0) { + fprintf(stderr, "unexpected negative 'offset' or 'bytes' value!\n"); +@@ -223,8 +232,10 @@ static coroutine_fn int pbs_co_preadv(BlockDriverState *bs, + return -EIO; + } + +- qemu_iovec_from_buf(qiov, 0, buf, bytes); +- free(buf); ++ if (!inline_buf) { ++ qemu_iovec_from_buf(qiov, 0, buf, bytes); ++ g_free(buf); ++ } + + return ret; + }