From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/8] scsi-disk: make discard asynchronous
Date: Tue, 10 Jul 2012 16:15:03 +0200 [thread overview]
Message-ID: <1341929710-21574-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1341929710-21574-1-git-send-email-pbonzini@redhat.com>
By making discard asynchronous, we can reuse all the error handling
code that is used for other commands.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
Not really related to this series, but it is yet another patch
I had around and it had a lot of conflicts with the ones that
follow, so it's easier to include it.
hw/scsi-disk.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 1e0e80a..016413c 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -168,7 +168,7 @@ static void scsi_disk_load_request(QEMUFile *f, SCSIRequest *req)
qemu_iovec_init_external(&r->qiov, &r->iov, 1);
}
-static void scsi_flush_complete(void * opaque, int ret)
+static void scsi_aio_complete(void *opaque, int ret)
{
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
@@ -221,7 +221,7 @@ static void scsi_write_do_fua(SCSIDiskReq *r)
if (scsi_is_cmd_fua(&r->req.cmd)) {
bdrv_acct_start(s->qdev.conf.bs, &r->acct, 0, BDRV_ACCT_FLUSH);
- r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_flush_complete, r);
+ r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r);
return;
}
@@ -1547,7 +1547,7 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
/* The request is used as the AIO opaque value, so add a ref. */
scsi_req_ref(&r->req);
bdrv_acct_start(s->qdev.conf.bs, &r->acct, 0, BDRV_ACCT_FLUSH);
- r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_flush_complete, r);
+ r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r);
return 0;
case READ_6:
case READ_10:
@@ -1624,15 +1624,13 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
goto fail;
}
- rc = bdrv_discard(s->qdev.conf.bs,
- r->req.cmd.lba * (s->qdev.blocksize / 512),
- len * (s->qdev.blocksize / 512));
- if (rc < 0) {
- /* XXX: better error code ?*/
- goto fail;
- }
-
- break;
+ /* The request is used as the AIO opaque value, so add a ref. */
+ scsi_req_ref(&r->req);
+ r->req.aiocb = bdrv_aio_discard(s->qdev.conf.bs,
+ r->req.cmd.lba * (s->qdev.blocksize / 512),
+ len * (s->qdev.blocksize / 512),
+ scsi_aio_complete, r);
+ return 0;
default:
DPRINTF("Unknown SCSI command (%2.2x)\n", buf[0]);
scsi_check_condition(r, SENSE_CODE(INVALID_OPCODE));
--
1.7.10.4
next prev parent reply other threads:[~2012-07-10 14:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-10 14:15 [Qemu-devel] [PATCH 0/9] scsi-disk: support toggling the write cache Paolo Bonzini
2012-07-10 14:15 ` Paolo Bonzini [this message]
2012-07-10 14:15 ` [Qemu-devel] [PATCH 2/8] scsi-disk: move all non-DMA commands to scsi_disk_emulate_command Paolo Bonzini
2012-07-10 14:15 ` [Qemu-devel] [PATCH 3/8] scsi-disk: split scsi-disk reqops Paolo Bonzini
2012-07-10 14:15 ` [Qemu-devel] [PATCH 4/8] scsi-disk: separate read_data/write_data implementation for emulate_reqops Paolo Bonzini
2012-07-10 14:15 ` [Qemu-devel] [PATCH 5/8] scsi-disk: support emulated TO_DEV requests Paolo Bonzini
2012-07-10 14:15 ` [Qemu-devel] [PATCH 6/8] scsi-disk: fix changeable values for MODE_PAGE_R_W_ERROR Paolo Bonzini
2012-07-10 14:15 ` [Qemu-devel] [PATCH 7/8] scsi-disk: parse MODE SELECT commands and parameters Paolo Bonzini
2012-07-10 14:15 ` [Qemu-devel] [PATCH 8/8] scsi-disk: support toggling the write cache Paolo Bonzini
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=1341929710-21574-2-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).