public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michaelc@cs.wisc.edu>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	"Michael S. Tsirkin" <mst@redhat.com>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Subject: Re: [PATCH 2/2] virtio-scsi: add error handling
Date: Mon, 05 Dec 2011 23:38:36 -0600	[thread overview]
Message-ID: <4EDDAA5C.2050809@cs.wisc.edu> (raw)
In-Reply-To: <1323106159-6562-3-git-send-email-pbonzini@redhat.com>

On 12/05/2011 11:29 AM, Paolo Bonzini wrote:
> +static int virtscsi_device_reset(struct scsi_cmnd *sc)
> +{
> +	struct virtio_scsi *vscsi = shost_priv(sc->device->host);
> +	struct virtio_scsi_cmd *cmd;
> +
> +	sdev_printk(KERN_INFO, sc->device, "device reset\n");
> +	cmd = kmem_cache_zalloc(virtscsi_cmd_cache, GFP_ATOMIC);


Here and in abort you can use GFP_NOIO. No locks are held here and you
just want to make sure the allocation does not cause write outs.

You probably want some cmd preallocated here and in the queuecommand
path, so you can make progress even if memory is hard to come by.
Block/scsi drivers normally use mempools to do this.


> +	if (!cmd)
> +		return FAILED;
> +
> +	cmd->sc = sc;
> +	cmd->req.tmf = (struct virtio_scsi_ctrl_tmf_req){
> +		.type = VIRTIO_SCSI_T_TMF,
> +		.subtype = VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET,
> +		.lun[0] = 1,
> +		.lun[1] = sc->device->id,
> +		.lun[2] = (sc->device->lun >> 8) | 0x40,
> +		.lun[3] = sc->device->lun & 0xff,

Not sure what is going on here. Is lun[8] is supposed to be the scsi lun
value like in the scsi specs? If so you just want

int_to_scsilun(sc->device->lun, lun);


>  static struct scsi_host_template virtscsi_host_template = {
>  	.module = THIS_MODULE,
>  	.name = "Virtio SCSI HBA",
>  	.proc_name = "virtio_scsi",
>  	.queuecommand = virtscsi_queuecommand,
>  	.this_id = -1,
> +	.eh_abort_handler               = virtscsi_abort,
> +	.eh_device_reset_handler        = virtscsi_device_reset,
>  

Tabbing looks off with the rest of your code.

      reply	other threads:[~2011-12-06  5:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-05 17:29 [PATCH v2 0/2] virtio-scsi driver Paolo Bonzini
2011-12-05 17:29 ` [PATCH 1/2] virtio-scsi: first version Paolo Bonzini
2011-12-06 18:09   ` James Bottomley
2011-12-07  9:41     ` Paolo Bonzini
2011-12-07 14:35       ` James Bottomley
2011-12-08 13:09         ` Paolo Bonzini
2011-12-09 20:06           ` James Bottomley
2011-12-10 16:37             ` Paolo Bonzini
2011-12-05 17:29 ` [PATCH 2/2] virtio-scsi: add error handling Paolo Bonzini
2011-12-06  5:38   ` Mike Christie [this message]

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=4EDDAA5C.2050809@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=stefanha@linux.vnet.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox