From: Olaf Hering <olaf@aepfle.de>
To: qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Olaf Hering <olaf@aepfle.de>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH] block: split large discard requests from block frontend
Date: Fri, 1 Apr 2016 14:22:01 +0200 [thread overview]
Message-ID: <1459513321-3776-1-git-send-email-olaf@aepfle.de> (raw)
Large discard requests lead to sign expansion errors in qemu.
Since there is no API to tell a guest about the limitations qmeu
has to split a large request itself.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
---
block/io.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/block/io.c b/block/io.c
index c4869b9..5b6ed58 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2442,7 +2442,7 @@ static void coroutine_fn bdrv_discard_co_entry(void *opaque)
rwco->ret = bdrv_co_discard(rwco->bs, rwco->sector_num, rwco->nb_sectors);
}
-int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
+static int __bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
int nb_sectors)
{
BdrvTrackedRequest req;
@@ -2524,6 +2524,26 @@ out:
return ret;
}
+int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
+ int nb_sectors)
+{
+ int num, ret;
+ int limit = BDRV_REQUEST_MAX_SECTORS;
+ int remaining = nb_sectors;
+ int64_t sector_offset = sector_num;
+
+ do {
+ num = remaining > limit ? limit : remaining;
+ ret = __bdrv_co_discard(bs, sector_offset, num);
+ if (ret < 0)
+ break;
+ remaining -= num;
+ sector_offset += num;
+ } while (remaining > 0);
+
+ return ret;
+}
+
int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors)
{
Coroutine *co;
next reply other threads:[~2016-04-01 12:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-01 12:22 Olaf Hering [this message]
2016-04-01 17:19 ` [Qemu-devel] [Qemu-block] [PATCH] block: split large discard requests from block frontend Max Reitz
2016-04-01 17:49 ` Olaf Hering
2016-05-06 16:44 ` Max Reitz
2016-11-17 13:54 ` Olaf Hering
2016-11-17 16:27 ` Olaf Hering
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1459513321-3776-1-git-send-email-olaf@aepfle.de \
--to=olaf@aepfle.de \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).