diff options
author | Fam Zheng | 2014-09-16 09:20:17 +0200 |
---|---|---|
committer | Paolo Bonzini | 2014-09-23 15:40:51 +0200 |
commit | 61e68b3fbd3e2b7beb636bc56f78d9c1ca25e8f9 (patch) | |
tree | 94312f417d4022a681392b1526c590a18924ceb2 /include/hw/scsi | |
parent | Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into ... (diff) | |
download | qemu-61e68b3fbd3e2b7beb636bc56f78d9c1ca25e8f9.tar.gz qemu-61e68b3fbd3e2b7beb636bc56f78d9c1ca25e8f9.tar.xz qemu-61e68b3fbd3e2b7beb636bc56f78d9c1ca25e8f9.zip |
scsi: Optimize scsi_req_alloc
Zeroing sense buffer for each scsi request is not efficient, we can just
leave it uninitialized because sense_len is set to 0.
Move the implicitly zeroed fields to the end of the structure and use a
partial memset.
The explicitly initialized fields (by scsi_req_alloc or scsi_req_new)
are moved to the beginning of the structure, before sense buffer, to
skip the memset.
Also change g_malloc0 to g_slice_alloc.
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/hw/scsi')
-rw-r--r-- | include/hw/scsi/scsi.h | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 2e3a8f987d..6271ad3034 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -50,17 +50,24 @@ struct SCSIRequest { uint32_t tag; uint32_t lun; uint32_t status; + void *hba_private; size_t resid; SCSICommand cmd; + + /* Note: + * - fields before sense are initialized by scsi_req_alloc; + * - sense[] is uninitialized; + * - fields after sense are memset to 0 by scsi_req_alloc. + * */ + + uint8_t sense[SCSI_SENSE_BUF_SIZE]; + uint32_t sense_len; + bool enqueued; + bool io_canceled; + bool retry; + bool dma_started; BlockDriverAIOCB *aiocb; QEMUSGList *sg; - bool dma_started; - uint8_t sense[SCSI_SENSE_BUF_SIZE]; - uint32_t sense_len; - bool enqueued; - bool io_canceled; - bool retry; - void *hba_private; QTAILQ_ENTRY(SCSIRequest) next; }; |