diff options
author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2012-05-26 14:56:38 +1000 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-05-28 14:04:15 +0200 |
commit | 6bcd1346bbfb051820e1c55bd4f04766f556bcdf (patch) | |
tree | 6a62436d7dba8db13bbf3b3bc2fbcc27325ad17a /block/iscsi.c | |
parent | dbfff6d776670cca751b904063c9173a23ae8c75 (diff) |
ISCSI: Only call READCAPACITY16 for SBC devices, use READCAPACITY10 for MMC
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Diffstat (limited to 'block/iscsi.c')
-rw-r--r-- | block/iscsi.c | 64 |
1 files changed, 59 insertions, 5 deletions
diff --git a/block/iscsi.c b/block/iscsi.c index 91cca83c5b..472c8539cb 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -510,6 +510,42 @@ iscsi_readcapacity16_cb(struct iscsi_context *iscsi, int status, } static void +iscsi_readcapacity10_cb(struct iscsi_context *iscsi, int status, + void *command_data, void *opaque) +{ + struct IscsiTask *itask = opaque; + struct scsi_readcapacity10 *rc10; + struct scsi_task *task = command_data; + + if (status != 0) { + error_report("iSCSI: Failed to read capacity of iSCSI lun. %s", + iscsi_get_error(iscsi)); + itask->status = 1; + itask->complete = 1; + scsi_free_scsi_task(task); + return; + } + + rc10 = scsi_datain_unmarshall(task); + if (rc10 == NULL) { + error_report("iSCSI: Failed to unmarshall readcapacity10 data."); + itask->status = 1; + itask->complete = 1; + scsi_free_scsi_task(task); + return; + } + + itask->iscsilun->block_size = rc10->block_size; + itask->iscsilun->num_blocks = rc10->lba + 1; + itask->bs->total_sectors = itask->iscsilun->num_blocks * + itask->iscsilun->block_size / BDRV_SECTOR_SIZE ; + + itask->status = 0; + itask->complete = 1; + scsi_free_scsi_task(task); +} + +static void iscsi_inquiry_cb(struct iscsi_context *iscsi, int status, void *command_data, void *opaque) { @@ -537,13 +573,31 @@ iscsi_inquiry_cb(struct iscsi_context *iscsi, int status, void *command_data, scsi_free_scsi_task(task); - task = iscsi_readcapacity16_task(iscsi, itask->iscsilun->lun, + switch (itask->iscsilun->type) { + case TYPE_DISK: + task = iscsi_readcapacity16_task(iscsi, itask->iscsilun->lun, iscsi_readcapacity16_cb, opaque); - if (task == NULL) { - error_report("iSCSI: failed to send readcapacity16 command."); - itask->status = 1; + if (task == NULL) { + error_report("iSCSI: failed to send readcapacity16 command."); + itask->status = 1; + itask->complete = 1; + return; + } + break; + case TYPE_ROM: + task = iscsi_readcapacity10_task(iscsi, itask->iscsilun->lun, + 0, 0, + iscsi_readcapacity10_cb, opaque); + if (task == NULL) { + error_report("iSCSI: failed to send readcapacity16 command."); + itask->status = 1; + itask->complete = 1; + return; + } + break; + default: + itask->status = 0; itask->complete = 1; - return; } } |