SCSI changes for 2013-12-20
Anthony,
the following changes since commit e157b8fdd412d48eacfbb8c67d3d58780154faa3:
Merge remote-tracking branch 'bonzini/virtio' into staging (2013-12-13 11:10:33 -0800)
are available in the git repository at:
git://github.com/bonzini/qemu.git scsi-next
for you to fetch changes up to 9971fa8f063bdc5ed60aa8117b8de78cef4a9c05:
scsi-disk: add non-zero MAX UNMAP LBA COUNT to block limits VPD page (2013-12-20 23:42:58 +0100)
----------------------------------------------------------------
Paolo Bonzini (1):
scsi-disk: add non-zero MAX UNMAP LBA COUNT to block limits VPD page
Peter Lieven (1):
block/iscsi: use a bh to schedule co reentrance
block/iscsi.c | 11 ++++++++++- hw/scsi/scsi-disk.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.4.2
[Qemu-devel] [PULL 1/2] block/iscsi: use a bh to schedule co reentrance
From: Peter Lieven <[email protected]>
this fixes a potential segfault and performance regression.
If the coroutine is reentered directly in the iscsi_co_generic_cb iscsi_process_{read,write} are interrupted and reentered any time later. One the one hand this could happen after an iscsi_close where the iscsi context is already gone (segfault). On the other hand this limits the number of processed callbacks in each aio_dispatch to one (potential performance regression).
--- block/iscsi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
block/iscsi.c +10 -1
@@ -68,6 +68,7 @@ typedef struct IscsiTask {int do_retry;struct scsi_task *task;Coroutine *co; +QEMUBH *bh; } IscsiTask; typedef struct IscsiAIOCB {
@@ -123,6 +124,13 @@ iscsi_schedule_bh(IscsiAIOCB *acb)qemu_bh_schedule (acb->bh); } +static void iscsi_co_generic_bh_cb (void *opaque) +{ +struct IscsiTask *iTask = opaque; +qemu_bh_delete (iTask->bh); +qemu_coroutine_enter (iTask->co,NULL ); +} +static void iscsi_co_generic_cb (struct iscsi_context *iscsi,int status,void *command_data,void *opaque)
@@ -147,7 +155,8 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status, out:if (iTask->co) { -qemu_coroutine_enter (iTask->co,NULL ); + iTask->bh =qemu_bh_new (iscsi_co_generic_bh_cb, iTask); +qemu_bh_schedule (iTask->bh); } }
Signature · 1 line
1.8.4.2
[Qemu-devel] [PULL 2/2] scsi-disk: add non-zero MAX UNMAP LBA COUNT to block limits VPD page
In reply to Paolo BonziniLinux prefers WRITE SAME to UNMAP if the count is zero, and WRITE SAME does not discard anything unless the device can guarantee that the resulting block is zero.
This fixes thin provisioning on glusterfs.
--- hw/scsi/scsi-disk.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
hw/scsi/scsi-disk.c +14 -0
@@ -47,6 +47,7 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0)#define SCSI_MAX_MODE_LEN 256#define DEFAULT_DISCARD_GRANULARITY 4096 +#define DEFAULT_MAX_UNMAP_SIZE (1 << 30)/* 1 GB */ typedef struct SCSIDiskState SCSIDiskState ;
@@ -74,6 +75,7 @@ struct SCSIDiskStatebool media_event;bool eject_request;uint64_t wwn; +uint64_t max_unmap_size;QEMUBH *bh;char *version;char *serial;
@@ -625,6 +627,8 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) s->qdev.conf.min_io_size / s->qdev.blocksize;unsigned int opt_io_size = s->qdev.conf.opt_io_size / s->qdev.blocksize; +unsigned int max_unmap_sectors = + s->max_unmap_size / s->qdev.blocksize;if (s->qdev.type ==TYPE_ROM ) { DPRINTF("Inquiry (EVPD[%02X] not supported for CDROM\n",
@@ -647,6 +651,12 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) outbuf[14 ] = (opt_io_size >>8 ) &0xff ; outbuf[15 ] = opt_io_size &0xff ; +/* maximum unmap LBA count, hardcoded to 1GB */ + outbuf[20 ] = (max_unmap_sectors >>24 ) &0xff ; + outbuf[21 ] = (max_unmap_sectors >>16 ) &0xff ; + outbuf[22 ] = (max_unmap_sectors >>8 ) &0xff ; + outbuf[23 ] = max_unmap_sectors &0xff ; +/* optimal unmap granularity */ outbuf[28 ] = (unmap_sectors >>24 ) &0xff ; outbuf[29 ] = (unmap_sectors >>16 ) &0xff ;
@@ -2519,6 +2529,8 @@ static Property scsi_hd_properties[] = {DEFINE_PROP_BIT ("dpofua" , SCSIDiskState, features,SCSI_DISK_F_DPOFUA , false),DEFINE_PROP_HEX64 ("wwn" , SCSIDiskState, wwn,0 ), +DEFINE_PROP_UINT64 ("max_unmap_size" , SCSIDiskState, max_unmap_size, +DEFAULT_MAX_UNMAP_SIZE ),DEFINE_BLOCK_CHS_PROPERTIES (SCSIDiskState, qdev.conf), DEFINE_PROP_END_OF_LIST(), };
@@ -2628,6 +2640,8 @@ static Property scsi_disk_properties[] = {DEFINE_PROP_BIT ("dpofua" , SCSIDiskState, features,SCSI_DISK_F_DPOFUA , false),DEFINE_PROP_HEX64 ("wwn" , SCSIDiskState, wwn,0 ), +DEFINE_PROP_UINT64 ("max_unmap_size" , SCSIDiskState, max_unmap_size, +DEFAULT_MAX_UNMAP_SIZE ), DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
1.8.4.2