All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cong Meng <mc@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: stefanha@linux.vnet.ibm.com, zwanp@cn.ibm.com,
	linuxram@us.ibm.com, qemu-devel@nongnu.org,
	linux-kernel@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v1] virtio-scsi: get and set the queue limits for sg device
Date: Tue, 21 Aug 2012 17:42:17 +0800	[thread overview]
Message-ID: <503357F9.2020606@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAJSP0QXwFZdoDsizTozmXa2P=iRT7RQ_yQcVRC4FemiSpKG_bA@mail.gmail.com>



On Tue 21 Aug 2012 04:53:59 PM CST, Stefan Hajnoczi wrote:
> On Tue, Aug 21, 2012 at 9:26 AM, Cong Meng <mc@linux.vnet.ibm.com> wrote:
>> Each virtio scsi HBA has global request queue limits. But the passthrough
>> LUNs (scsi-generic) come from different host HBAs may have different request
>> queue limits. If the guest sends commands that exceed the host limits, the
>> commands will be rejected by host HAB.
>>
>> This patch addresses this issue by getting the per-LUN queue limits via the the
>> newly added virtio control request, then setting them properly.
>>
>> Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>
>> ---
>>   drivers/scsi/virtio_scsi.c  |  113 +++++++++++++++++++++++++++++++++++++------
>>   include/linux/virtio_scsi.h |   18 +++++++
>>   2 files changed, 116 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
>> index 173cb39..ec5066f 100644
>> --- a/drivers/scsi/virtio_scsi.c
>> +++ b/drivers/scsi/virtio_scsi.c
>> @@ -35,12 +35,14 @@ struct virtio_scsi_cmd {
>>                  struct virtio_scsi_cmd_req       cmd;
>>                  struct virtio_scsi_ctrl_tmf_req  tmf;
>>                  struct virtio_scsi_ctrl_an_req   an;
>> +               struct virtio_scsi_ctrl_lq_req   lq;
>>          } req;
>>          union {
>>                  struct virtio_scsi_cmd_resp      cmd;
>>                  struct virtio_scsi_ctrl_tmf_resp tmf;
>>                  struct virtio_scsi_ctrl_an_resp  an;
>>                  struct virtio_scsi_event         evt;
>> +               struct virtio_scsi_ctrl_lq_resp  lq;
>>          } resp;
>>   } ____cacheline_aligned_in_smp;
>>
>> @@ -469,6 +471,46 @@ out:
>>          return ret;
>>   }
>>
>> +static u32 virtscsi_lun_query(struct scsi_device *sdev, u32 *value, u32 subtype)
>> +{
>> +       struct Scsi_Host *shost = sdev->host;
>> +       struct virtio_scsi *vscsi = shost_priv(shost);
>> +       DECLARE_COMPLETION_ONSTACK(comp);
>> +       struct virtio_scsi_cmd *cmd;
>> +       struct virtio_scsi_target_state *tgt = vscsi->tgt[sdev->id];
>> +       unsigned int ret = VIRTIO_SCSI_S_FAILURE;
>> +
>> +       cmd = mempool_alloc(virtscsi_cmd_pool, GFP_ATOMIC);
>> +       if (!cmd)
>> +               goto out;
>> +
>> +       memset(cmd, 0, sizeof(*cmd));
>> +       cmd->comp = &comp;
>> +       cmd->req.lq = (struct virtio_scsi_ctrl_lq_req){
>> +               .type = VIRTIO_SCSI_T_LUN_QUERY,
>> +               .subtype = subtype,
>> +               .lun[0] = 1,
>> +               .lun[1] = sdev->id,
>> +               .lun[2] = (sdev->lun >> 8) | 0x40,
>> +               .lun[3] = sdev->lun & 0xff,
>
> The LUN addressing code has been duplicated several times now.  How
> about replacing it with something like

sure. I will include it.

Thnaks.
Cong.

>
> static void virtio_scsi_set_lun(u8 *lun, struct scsi_device *sdev)
> {
>      lun[0] = 1;
>      lun[1] = sdev->id;
>      lun[2] = (sdev->lun >> 8) | 0x40;
>      lun[3] = sdev->lun & 0xff;
>      lun[4] = lun[5] = lun[6] = lun[7] = 0;
> }
>

WARNING: multiple messages have this Message-ID (diff)
From: Cong Meng <mc@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	stefanha@linux.vnet.ibm.com, linux-kernel@vger.kernel.org,
	zwanp@cn.ibm.com, linuxram@us.ibm.com, qemu-devel@nongnu.org,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v1] virtio-scsi: get and set the queue limits for sg device
Date: Tue, 21 Aug 2012 17:42:17 +0800	[thread overview]
Message-ID: <503357F9.2020606@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAJSP0QXwFZdoDsizTozmXa2P=iRT7RQ_yQcVRC4FemiSpKG_bA@mail.gmail.com>



On Tue 21 Aug 2012 04:53:59 PM CST, Stefan Hajnoczi wrote:
> On Tue, Aug 21, 2012 at 9:26 AM, Cong Meng <mc@linux.vnet.ibm.com> wrote:
>> Each virtio scsi HBA has global request queue limits. But the passthrough
>> LUNs (scsi-generic) come from different host HBAs may have different request
>> queue limits. If the guest sends commands that exceed the host limits, the
>> commands will be rejected by host HAB.
>>
>> This patch addresses this issue by getting the per-LUN queue limits via the the
>> newly added virtio control request, then setting them properly.
>>
>> Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>
>> ---
>>   drivers/scsi/virtio_scsi.c  |  113 +++++++++++++++++++++++++++++++++++++------
>>   include/linux/virtio_scsi.h |   18 +++++++
>>   2 files changed, 116 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
>> index 173cb39..ec5066f 100644
>> --- a/drivers/scsi/virtio_scsi.c
>> +++ b/drivers/scsi/virtio_scsi.c
>> @@ -35,12 +35,14 @@ struct virtio_scsi_cmd {
>>                  struct virtio_scsi_cmd_req       cmd;
>>                  struct virtio_scsi_ctrl_tmf_req  tmf;
>>                  struct virtio_scsi_ctrl_an_req   an;
>> +               struct virtio_scsi_ctrl_lq_req   lq;
>>          } req;
>>          union {
>>                  struct virtio_scsi_cmd_resp      cmd;
>>                  struct virtio_scsi_ctrl_tmf_resp tmf;
>>                  struct virtio_scsi_ctrl_an_resp  an;
>>                  struct virtio_scsi_event         evt;
>> +               struct virtio_scsi_ctrl_lq_resp  lq;
>>          } resp;
>>   } ____cacheline_aligned_in_smp;
>>
>> @@ -469,6 +471,46 @@ out:
>>          return ret;
>>   }
>>
>> +static u32 virtscsi_lun_query(struct scsi_device *sdev, u32 *value, u32 subtype)
>> +{
>> +       struct Scsi_Host *shost = sdev->host;
>> +       struct virtio_scsi *vscsi = shost_priv(shost);
>> +       DECLARE_COMPLETION_ONSTACK(comp);
>> +       struct virtio_scsi_cmd *cmd;
>> +       struct virtio_scsi_target_state *tgt = vscsi->tgt[sdev->id];
>> +       unsigned int ret = VIRTIO_SCSI_S_FAILURE;
>> +
>> +       cmd = mempool_alloc(virtscsi_cmd_pool, GFP_ATOMIC);
>> +       if (!cmd)
>> +               goto out;
>> +
>> +       memset(cmd, 0, sizeof(*cmd));
>> +       cmd->comp = &comp;
>> +       cmd->req.lq = (struct virtio_scsi_ctrl_lq_req){
>> +               .type = VIRTIO_SCSI_T_LUN_QUERY,
>> +               .subtype = subtype,
>> +               .lun[0] = 1,
>> +               .lun[1] = sdev->id,
>> +               .lun[2] = (sdev->lun >> 8) | 0x40,
>> +               .lun[3] = sdev->lun & 0xff,
>
> The LUN addressing code has been duplicated several times now.  How
> about replacing it with something like

sure. I will include it.

Thnaks.
Cong.

>
> static void virtio_scsi_set_lun(u8 *lun, struct scsi_device *sdev)
> {
>      lun[0] = 1;
>      lun[1] = sdev->id;
>      lun[2] = (sdev->lun >> 8) | 0x40;
>      lun[3] = sdev->lun & 0xff;
>      lun[4] = lun[5] = lun[6] = lun[7] = 0;
> }
>


WARNING: multiple messages have this Message-ID (diff)
From: Cong Meng <mc@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: stefanha@linux.vnet.ibm.com, zwanp@cn.ibm.com,
	linuxram@us.ibm.com, qemu-devel@nongnu.org,
	linux-kernel@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	virtualization@lists.linux-foundation.org
Subject: Re: [Qemu-devel] [PATCH v1] virtio-scsi: get and set the queue limits for sg device
Date: Tue, 21 Aug 2012 17:42:17 +0800	[thread overview]
Message-ID: <503357F9.2020606@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAJSP0QXwFZdoDsizTozmXa2P=iRT7RQ_yQcVRC4FemiSpKG_bA@mail.gmail.com>



On Tue 21 Aug 2012 04:53:59 PM CST, Stefan Hajnoczi wrote:
> On Tue, Aug 21, 2012 at 9:26 AM, Cong Meng <mc@linux.vnet.ibm.com> wrote:
>> Each virtio scsi HBA has global request queue limits. But the passthrough
>> LUNs (scsi-generic) come from different host HBAs may have different request
>> queue limits. If the guest sends commands that exceed the host limits, the
>> commands will be rejected by host HAB.
>>
>> This patch addresses this issue by getting the per-LUN queue limits via the the
>> newly added virtio control request, then setting them properly.
>>
>> Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>
>> ---
>>   drivers/scsi/virtio_scsi.c  |  113 +++++++++++++++++++++++++++++++++++++------
>>   include/linux/virtio_scsi.h |   18 +++++++
>>   2 files changed, 116 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
>> index 173cb39..ec5066f 100644
>> --- a/drivers/scsi/virtio_scsi.c
>> +++ b/drivers/scsi/virtio_scsi.c
>> @@ -35,12 +35,14 @@ struct virtio_scsi_cmd {
>>                  struct virtio_scsi_cmd_req       cmd;
>>                  struct virtio_scsi_ctrl_tmf_req  tmf;
>>                  struct virtio_scsi_ctrl_an_req   an;
>> +               struct virtio_scsi_ctrl_lq_req   lq;
>>          } req;
>>          union {
>>                  struct virtio_scsi_cmd_resp      cmd;
>>                  struct virtio_scsi_ctrl_tmf_resp tmf;
>>                  struct virtio_scsi_ctrl_an_resp  an;
>>                  struct virtio_scsi_event         evt;
>> +               struct virtio_scsi_ctrl_lq_resp  lq;
>>          } resp;
>>   } ____cacheline_aligned_in_smp;
>>
>> @@ -469,6 +471,46 @@ out:
>>          return ret;
>>   }
>>
>> +static u32 virtscsi_lun_query(struct scsi_device *sdev, u32 *value, u32 subtype)
>> +{
>> +       struct Scsi_Host *shost = sdev->host;
>> +       struct virtio_scsi *vscsi = shost_priv(shost);
>> +       DECLARE_COMPLETION_ONSTACK(comp);
>> +       struct virtio_scsi_cmd *cmd;
>> +       struct virtio_scsi_target_state *tgt = vscsi->tgt[sdev->id];
>> +       unsigned int ret = VIRTIO_SCSI_S_FAILURE;
>> +
>> +       cmd = mempool_alloc(virtscsi_cmd_pool, GFP_ATOMIC);
>> +       if (!cmd)
>> +               goto out;
>> +
>> +       memset(cmd, 0, sizeof(*cmd));
>> +       cmd->comp = &comp;
>> +       cmd->req.lq = (struct virtio_scsi_ctrl_lq_req){
>> +               .type = VIRTIO_SCSI_T_LUN_QUERY,
>> +               .subtype = subtype,
>> +               .lun[0] = 1,
>> +               .lun[1] = sdev->id,
>> +               .lun[2] = (sdev->lun >> 8) | 0x40,
>> +               .lun[3] = sdev->lun & 0xff,
>
> The LUN addressing code has been duplicated several times now.  How
> about replacing it with something like

sure. I will include it.

Thnaks.
Cong.

>
> static void virtio_scsi_set_lun(u8 *lun, struct scsi_device *sdev)
> {
>      lun[0] = 1;
>      lun[1] = sdev->id;
>      lun[2] = (sdev->lun >> 8) | 0x40;
>      lun[3] = sdev->lun & 0xff;
>      lun[4] = lun[5] = lun[6] = lun[7] = 0;
> }
>

  reply	other threads:[~2012-08-21  9:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-21  8:26 [PATCH v1] virtio-scsi: get and set the queue limits for sg device Cong Meng
2012-08-21  8:26 ` [Qemu-devel] " Cong Meng
2012-08-21  8:26 ` Cong Meng
2012-08-21  8:53 ` Stefan Hajnoczi
2012-08-21  8:53   ` [Qemu-devel] " Stefan Hajnoczi
2012-08-21  8:53   ` Stefan Hajnoczi
2012-08-21  9:42   ` Cong Meng [this message]
2012-08-21  9:42     ` [Qemu-devel] " Cong Meng
2012-08-21  9:42     ` Cong Meng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=503357F9.2020606@linux.vnet.ibm.com \
    --to=mc@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxram@us.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@linux.vnet.ibm.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=zwanp@cn.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.