Patchwork [4/4] ISCSI: If the device we open is a SMC device, then force the use of sg. We dont have any medium changer emulation so only passthrough via real sg or scsi-generic via iscsi would work anyway.

login
register
mail settings
Submitter ronniesahlberg@gmail.com
Date May 26, 2012, 4:56 a.m.
Message ID <1338008201-29078-5-git-send-email-ronniesahlberg@gmail.com>
Download mbox | patch
Permalink /patch/161449/
State New
Headers show

Comments

ronniesahlberg@gmail.com - May 26, 2012, 4:56 a.m.
Forcing sg also makes qemu skip trying to read from the device to guess the image format by reading from the device (find_image_format()).
SMC devices do not implement READ6/10/12/16  so it is noit possible to read from them.

With this patch I can successfully manage a SMC device wiht iscsi in passthrough mode.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
---
 block/iscsi.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
Paolo Bonzini - May 26, 2012, 7:36 a.m.
Il 26/05/2012 06:56, Ronnie Sahlberg ha scritto:
> Forcing sg also makes qemu skip trying to read from the device to guess the image format by reading from the device (find_image_format()).
> SMC devices do not implement READ6/10/12/16  so it is noit possible to read from them.
> 
> With this patch I can successfully manage a SMC device wiht iscsi in passthrough mode.
> 
> Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> ---
>  block/iscsi.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/block/iscsi.c b/block/iscsi.c
> index a015a52..9ce38b5 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -1032,6 +1032,15 @@ static int iscsi_open(BlockDriverState *bs, const char *filename, int flags)
>      if (iscsi_url != NULL) {
>          iscsi_destroy_url(iscsi_url);
>      }
> +
> +    /* Medium changer. We dont have any emulation for this so this must
> +       be sg ioctl compatible. We force it to be sg, otherwise qemu will try
> +       to read from the device to guess the image format.
> +     */
> +    if (iscsilun->type == TYPE_MEDIUM_CHANGER) {
> +            bs->sg = 1;
> +    }
> +
>      return 0;
>  
>  failed:

Modified to also do the same for tapes, applied to scsi-next branch for 1.2.

Paolo
Andreas Färber - May 27, 2012, 1:12 p.m.
Am 26.05.2012 09:36, schrieb Paolo Bonzini:
> Il 26/05/2012 06:56, Ronnie Sahlberg ha scritto:
>> Forcing sg also makes qemu skip trying to read from the device to guess the image format by reading from the device (find_image_format()).
>> SMC devices do not implement READ6/10/12/16  so it is noit possible to read from them.
>>
>> With this patch I can successfully manage a SMC device wiht iscsi in passthrough mode.
>>
>> Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
[...]
> Modified to also do the same for tapes, applied to scsi-next branch for 1.2.

Paolo, it seems you haven't pushed scsi-next since then. I hope you've
also shortened the subject to a humanly bearable length?

Ronnie, please restrict commit message lines to at most 76 characters.
You can check by running `git log` in an 80-char-wide terminal. The
subject line is especially sensitive since this email subject is simply
unreadable. And Patchwork currently looks really ugly in WebKit due to
this patch subject.

https://live.gnome.org/Git/CommitMessages

Andreas
Paolo Bonzini - May 28, 2012, 6:48 a.m.
Il 27/05/2012 15:12, Andreas Färber ha scritto:
>> > Modified to also do the same for tapes, applied to scsi-next branch for 1.2.
> Paolo, it seems you haven't pushed scsi-next since then.

Yeah, I have a pending push request for scsi-next, so I'm waiting till
Anthony applies it before pushing 1.2-only patches (I wasn't expecting
parallel 1.1/1.2 development for SCSI).

> I hope you've
> also shortened the subject to a humanly bearable length?

Yes. :)

Paolo
ronniesahlberg@gmail.com - May 28, 2012, 11:55 a.m.
Paolo


I think I have seen a problem inside libiscsi that could be triggered
by the shortcut.

Can you remove this shortcut completely :

-    /* Try to write as much as we can to the socket
-     * without setting up an event.
-     * Only do this if we are completely logged in, so we know that
-     * the socket is in connected state.
-     */
-    if (iscsi_is_logged_in(iscsi)) {
-        if (iscsi_which_events(iscsi) & POLLOUT) {
-            iscsi_process_write(iscsilun);
-        }
-    }

I think there is a problem inside libiscsi if the socket becomes full
and is no longer writeable and we try to write via this shortcurcuit.
It will take a while until I can verify or fix that issue and before a
new version of libiscsi can be available
so I would feel most comfortable with if we just remove this
optimization from QEMU for now.

It can be added back later once libiscsi is fixed.



regards
ronnie sahlberg


On Mon, May 28, 2012 at 4:48 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 27/05/2012 15:12, Andreas Färber ha scritto:
>>> > Modified to also do the same for tapes, applied to scsi-next branch for 1.2.
>> Paolo, it seems you haven't pushed scsi-next since then.
>
> Yeah, I have a pending push request for scsi-next, so I'm waiting till
> Anthony applies it before pushing 1.2-only patches (I wasn't expecting
> parallel 1.1/1.2 development for SCSI).
>
>> I hope you've
>> also shortened the subject to a humanly bearable length?
>
> Yes. :)
>
> Paolo
Paolo Bonzini - May 28, 2012, 12:05 p.m.
Il 28/05/2012 13:55, ronnie sahlberg ha scritto:
> Paolo
> 
> 
> I think I have seen a problem inside libiscsi that could be triggered
> by the shortcut.
> 
> Can you remove this shortcut completely :
> 
> -    /* Try to write as much as we can to the socket
> -     * without setting up an event.
> -     * Only do this if we are completely logged in, so we know that
> -     * the socket is in connected state.
> -     */
> -    if (iscsi_is_logged_in(iscsi)) {
> -        if (iscsi_which_events(iscsi) & POLLOUT) {
> -            iscsi_process_write(iscsilun);
> -        }
> -    }
> 
> I think there is a problem inside libiscsi if the socket becomes full
> and is no longer writeable and we try to write via this shortcurcuit.
> It will take a while until I can verify or fix that issue and before a
> new version of libiscsi can be available
> so I would feel most comfortable with if we just remove this
> optimization from QEMU for now.
> 
> It can be added back later once libiscsi is fixed.

Done.  Rebased scsi-next, new commit is
f4dfa67f04037c1b1a8f4e4ddc944c5ab308f35b.

Paolo

Patch

diff --git a/block/iscsi.c b/block/iscsi.c
index a015a52..9ce38b5 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1032,6 +1032,15 @@  static int iscsi_open(BlockDriverState *bs, const char *filename, int flags)
     if (iscsi_url != NULL) {
         iscsi_destroy_url(iscsi_url);
     }
+
+    /* Medium changer. We dont have any emulation for this so this must
+       be sg ioctl compatible. We force it to be sg, otherwise qemu will try
+       to read from the device to guess the image format.
+     */
+    if (iscsilun->type == TYPE_MEDIUM_CHANGER) {
+            bs->sg = 1;
+    }
+
     return 0;
 
 failed: