[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/4] Refactor scsi-disk layer for queue'ing writes
From: |
Ryan Harper |
Subject: |
[Qemu-devel] [PATCH 3/4] Refactor scsi-disk layer for queue'ing writes |
Date: |
Fri, 3 Oct 2008 17:05:30 -0500 |
Refactor scsi write path to match the simpler, faster scsi read path. No need
to call into the write completion function to calculate the request buf length.
Signed-off-by: Ryan Harper <address@hidden>
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 16b3215..f2b4814 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -208,25 +208,14 @@ static void scsi_write_complete(void * opaque, int ret)
{
SCSIRequest *r = (SCSIRequest *)opaque;
SCSIDeviceState *s = r->dev;
- uint32_t len;
if (ret) {
fprintf(stderr, "scsi-disc: IO write error\n");
exit(1);
}
-
r->aiocb = NULL;
- if (r->sector_count == 0) {
- scsi_command_complete(r, SENSE_NO_SENSE);
- } else {
- len = r->sector_count * 512;
- if (len > SCSI_DMA_BUF_SIZE) {
- len = SCSI_DMA_BUF_SIZE;
- }
- r->buf_len = len;
- DPRINTF("Write complete tag=0x%x more=%d\n", r->tag, len);
- s->completion(s->opaque, SCSI_REASON_DATA, r->tag, len);
- }
+ DPRINTF("Write complete tag=0x%x more=%d\n", r->tag, r->buf_len);
+ s->completion(s->opaque, SCSI_REASON_DATA, r->tag, r->buf_len);
}
/* Write data to a scsi device. Returns nonzero on failure.
@@ -235,7 +224,7 @@ static int scsi_write_data(SCSIDevice *d, uint32_t tag)
{
SCSIDeviceState *s = d->state;
SCSIRequest *r;
- uint32_t n;
+ uint32_t n, len;
DPRINTF("Write data tag=0x%x\n", tag);
r = scsi_find_request(s, tag);
@@ -244,8 +233,22 @@ static int scsi_write_data(SCSIDevice *d, uint32_t tag)
scsi_command_complete(r, SENSE_HARDWARE_ERROR);
return 1;
}
+ DPRINTF("Write sector_count=%d\n", r->sector_count);
+ if (r->sector_count == 0) {
+ scsi_command_complete(r, SENSE_NO_SENSE);
+ return 0;
+ }
if (r->aiocb)
BADF("Data transfer already in progress\n");
+
+ /* we know the len of the request and with the max size of the scsi buffer,
+ * we can calculate buf_len needed */
+ len = r->sector_count * 512;
+ if (len > SCSI_DMA_BUF_SIZE)
+ len = SCSI_DMA_BUF_SIZE;
+ r->buf_len = len;
+
+ /* number of sectors to submit */
n = r->buf_len / 512;
if (n) {
r->aiocb = bdrv_aio_write(s->bdrv, r->sector, r->dma_buf, n,
- [Qemu-devel] [PATCH 0/4] Improve emulated scsi write performance, Ryan Harper, 2008/10/03
- [Qemu-devel] [PATCH 1/4] lsi_queue_command: add dma direction parameter, Ryan Harper, 2008/10/03
- [Qemu-devel] [PATCH 2/4] Refactor lsi_do_command to queue read and write ops, Ryan Harper, 2008/10/03
- [Qemu-devel] [PATCH 3/4] Refactor scsi-disk layer for queue'ing writes,
Ryan Harper <=
- [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Ryan Harper, 2008/10/03
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Paul Brook, 2008/10/03
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Anthony Liguori, 2008/10/03
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Paul Brook, 2008/10/03
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Avi Kivity, 2008/10/04
- Message not available
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Ryan Harper, 2008/10/04
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Anthony Liguori, 2008/10/04
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Avi Kivity, 2008/10/05
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Ryan Harper, 2008/10/05
- Re: [Qemu-devel] [PATCH 4/4] Reallocate dma buffers in read/write path if needed, Avi Kivity, 2008/10/06