qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCHv3] iscsi: add iscsi_truncate support


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCHv3] iscsi: add iscsi_truncate support
Date: Mon, 18 Feb 2013 14:01:52 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

Il 18/02/2013 13:58, Peter Lieven ha scritto:
> 
> -    switch (iscsilun->type) {
> -    case TYPE_DISK:
> -        task = iscsi_readcapacity16_sync(iscsi, iscsilun->lun);
> -        if (task == NULL || task->status != SCSI_STATUS_GOOD) {
> -            error_report("iSCSI: failed to send readcapacity16 command.");
> -            ret = -EINVAL;
> -            goto out;
> -        }
> -        rc16 = scsi_datain_unmarshall(task);
> -        if (rc16 == NULL) {
> -            error_report("iSCSI: Failed to unmarshall readcapacity16
> data.");
> -            ret = -EINVAL;
> +    if (iscsilun->type == TYPE_DISK) {
> +        if ((ret = iscsi_disk_readcapacity16_sync(iscsilun))) {
>              goto out;
>          }
> -        iscsilun->block_size = rc16->block_length;
> -        iscsilun->num_blocks = rc16->returned_lba + 1;
> -        break;
> -    case TYPE_ROM:
> +    }
> +    if (iscsilun->type == TYPE_ROM) {
>          task = iscsi_readcapacity10_sync(iscsi, iscsilun->lun, 0, 0);
>          if (task == NULL || task->status != SCSI_STATUS_GOOD) {
>              error_report("iSCSI: failed to send readcapacity10 command.");
> @@ -964,10 +981,7 @@ static int iscsi_open(BlockDriverState *bs, const
> char *filename, int flags)
>          } else {
>              iscsilun->num_blocks = rc10->lba + 1;
>          }
> -        break;
> -    default:
> -        break;
> -    }
> +    }

I didn't write to *remove* the switch statement, I wrote to *move* it
into a new function and use it from iscsi_truncate.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]