[SRU,Xenial,1/1] UBUNTU: SAUCE: (no-up) virtio-scsi: Increment reqs counter.

Message ID 7e29efe861a5032a30d8975905f57ee7b33d55b5.1528464636.git.joseph.salisbury@canonical.com
State New
Headers show
Series
  • UBUNTU: SAUCE: (no-up) virtio-scsi: Increment reqs counter.
Related show

Commit Message

Joseph Salisbury June 8, 2018, 5:48 p.m.
From: Felipe Franciosi <felipe@nutanix.com>

BugLink: http://bugs.launchpad.net/bugs/1775235

virtio-scsi itself is broken in a way that it doesn't increment the
'reqs' counter when submitting requests on MQ in certain conditions.
That caused the counter to go to -1 (on the completion of the first
request) and the CPU to hang indefinitely.

Fixes: f1f609d8015e ("UBUNTU: SAUCE: (no-up) virtio-scsi: Fix race in
target free")

Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
---
 drivers/scsi/virtio_scsi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Stefan Bader June 8, 2018, 6:54 p.m. | #1
On 08.06.2018 10:48, Joseph Salisbury wrote:
> From: Felipe Franciosi <felipe@nutanix.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1775235
> 
> virtio-scsi itself is broken in a way that it doesn't increment the
> 'reqs' counter when submitting requests on MQ in certain conditions.
> That caused the counter to go to -1 (on the completion of the first
> request) and the CPU to hang indefinitely.
> 
> Fixes: f1f609d8015e ("UBUNTU: SAUCE: (no-up) virtio-scsi: Fix race in
> target free")
> 
> Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
> Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---

Ok, kind of ugly to have to fix that work-around hack which is already ugly on
its own. But it is what it is...

-Stefan

>  drivers/scsi/virtio_scsi.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index e2da312..b4a41d5 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -588,11 +588,12 @@ static int virtscsi_queuecommand_single(struct Scsi_Host *sh,
>  }
>  
>  static struct virtio_scsi_vq *virtscsi_pick_vq_mq(struct virtio_scsi *vscsi,
> -						  struct scsi_cmnd *sc)
> +						  struct virtio_scsi_target_state *tgt, struct scsi_cmnd *sc)
>  {
>  	u32 tag = blk_mq_unique_tag(sc->request);
>  	u16 hwq = blk_mq_unique_tag_to_hwq(tag);
>  
> +	atomic_inc(&tgt->reqs);
>  	return &vscsi->req_vqs[hwq];
>  }
>  
> @@ -642,7 +643,7 @@ static int virtscsi_queuecommand_multi(struct Scsi_Host *sh,
>  	struct virtio_scsi_vq *req_vq;
>  
>  	if (shost_use_blk_mq(sh))
> -		req_vq = virtscsi_pick_vq_mq(vscsi, sc);
> +		req_vq = virtscsi_pick_vq_mq(vscsi, tgt, sc);
>  	else
>  		req_vq = virtscsi_pick_vq(vscsi, tgt);
>  
>
Khaled Elmously June 8, 2018, 7:02 p.m. | #2
On 2018-06-08 13:48:27 , Joseph Salisbury wrote:
> From: Felipe Franciosi <felipe@nutanix.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1775235
> 
> virtio-scsi itself is broken in a way that it doesn't increment the
> 'reqs' counter when submitting requests on MQ in certain conditions.
> That caused the counter to go to -1 (on the completion of the first
> request) and the CPU to hang indefinitely.
> 
> Fixes: f1f609d8015e ("UBUNTU: SAUCE: (no-up) virtio-scsi: Fix race in
> target free")
> 
> Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
> Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
> ---
>  drivers/scsi/virtio_scsi.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index e2da312..b4a41d5 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -588,11 +588,12 @@ static int virtscsi_queuecommand_single(struct Scsi_Host *sh,
>  }
>  
>  static struct virtio_scsi_vq *virtscsi_pick_vq_mq(struct virtio_scsi *vscsi,
> -						  struct scsi_cmnd *sc)
> +						  struct virtio_scsi_target_state *tgt, struct scsi_cmnd *sc)
>  {
>  	u32 tag = blk_mq_unique_tag(sc->request);
>  	u16 hwq = blk_mq_unique_tag_to_hwq(tag);
>  
> +	atomic_inc(&tgt->reqs);
>  	return &vscsi->req_vqs[hwq];
>  }
>  
> @@ -642,7 +643,7 @@ static int virtscsi_queuecommand_multi(struct Scsi_Host *sh,
>  	struct virtio_scsi_vq *req_vq;
>  
>  	if (shost_use_blk_mq(sh))
> -		req_vq = virtscsi_pick_vq_mq(vscsi, sc);
> +		req_vq = virtscsi_pick_vq_mq(vscsi, tgt, sc);
>  	else
>  		req_vq = virtscsi_pick_vq(vscsi, tgt);
>

Acked-by: Khalid Elmously <khalid.elmously@canonical.com>

Patch

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index e2da312..b4a41d5 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -588,11 +588,12 @@  static int virtscsi_queuecommand_single(struct Scsi_Host *sh,
 }
 
 static struct virtio_scsi_vq *virtscsi_pick_vq_mq(struct virtio_scsi *vscsi,
-						  struct scsi_cmnd *sc)
+						  struct virtio_scsi_target_state *tgt, struct scsi_cmnd *sc)
 {
 	u32 tag = blk_mq_unique_tag(sc->request);
 	u16 hwq = blk_mq_unique_tag_to_hwq(tag);
 
+	atomic_inc(&tgt->reqs);
 	return &vscsi->req_vqs[hwq];
 }
 
@@ -642,7 +643,7 @@  static int virtscsi_queuecommand_multi(struct Scsi_Host *sh,
 	struct virtio_scsi_vq *req_vq;
 
 	if (shost_use_blk_mq(sh))
-		req_vq = virtscsi_pick_vq_mq(vscsi, sc);
+		req_vq = virtscsi_pick_vq_mq(vscsi, tgt, sc);
 	else
 		req_vq = virtscsi_pick_vq(vscsi, tgt);