linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: jgross@suse.com
Cc: xen-devel@lists.xen.org, linux-scsi@vger.kernel.org,
	target-devel@vger.kernel.org, JBottomley@parallels.com,
	konrad.wilk@oracle.com, hch@infradead.org,
	david.vrabel@citrix.com, JBeulich@suse.com
Subject: Re: [PATCH V4 2/4] Introduce xen-scsifront module
Date: Mon, 11 Aug 2014 02:54:24 -0700	[thread overview]
Message-ID: <20140811095424.GB5952@infradead.org> (raw)
In-Reply-To: <1407484194-31876-3-git-send-email-jgross@suse.com>

> +	BUG_ON(sc->cmd_len > VSCSIIF_MAX_COMMAND_SIZE);
> +
> +	if (sc->cmd_len)

I can't see how you can get a zero cmd_len here.

> +static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act)

Please add a comment explaining your unusual EH strategy here.

> +static void scsifront_free(struct vscsifrnt_info *info)
> +{
> +	if (info->host && info->host_active) {
> +		/* Scsi_host not yet removed */
> +		scsi_remove_host(info->host);
> +		info->host_active = 0;
> +	}
> +
> +	if (info->ring_ref != GRANT_INVALID_REF) {
> +		gnttab_end_foreign_access(info->ring_ref, 0,
> +					  (unsigned long)info->ring.sring);
> +		info->ring_ref = GRANT_INVALID_REF;
> +		info->ring.sring = NULL;
> +	}
> +
> +	if (info->irq)
> +		unbind_from_irqhandler(info->irq, info);
> +	info->irq = 0;
> +	info->evtchn = 0;
> +
> +	if (info->host)
> +		scsi_host_put(info->host);
> +}

I don't think most of the ifs should be here, just use proper symmetric
goto unwinding in the initialization error path instead.

The way this function can be called from different levels of the
callstack on init failure is very confusing.

> +		switch (op) {
> +		case VSCSIFRONT_OP_ADD_LUN:
> +			if (device_state == XenbusStateInitialised) {
> +				sdev = __scsi_add_device(info->host, chn, tgt,
> +							lun, NULL);
> +				err = (IS_ERR(sdev) || !sdev->hostdata);
> +				if (!IS_ERR(sdev)) {
> +					sdev->hostdata = NULL;
> +					scsi_device_put(sdev);
> +				}

Given that you put the device immediatly you should be using
scsi_add_device instead of __scsi_add_device.  Also all the messing
with ->hostdata from ->slave_alloc looks wrong.  For one thing every
setup done ->slave_alloc should be paired with teardown in
->slave_destroy.  Second I don't see any need for that.

> +				} else {
> +					xenbus_printf(XBT_NIL, dev->nodename,
> +						      state_str, "%d",
> +						      XenbusStateConnected);
> +				}

Just print this message in ->slave_configure. 

  reply	other threads:[~2014-08-11  9:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-08  7:49 Add XEN pvSCSI support jgross
2014-08-08  7:49 ` [PATCH V4 1/4] Add XEN pvSCSI protocol description jgross
2014-08-08  7:49 ` [PATCH V4 2/4] Introduce xen-scsifront module jgross
2014-08-11  9:54   ` Christoph Hellwig [this message]
2014-08-11 10:27     ` [Xen-devel] " Juergen Gross
2014-08-11 17:50       ` Christoph Hellwig
2014-08-12 11:32         ` Juergen Gross
2014-08-08  7:49 ` [PATCH V4 3/4] Introduce XEN scsiback module jgross
2014-08-11 18:14   ` Christoph Hellwig
2014-08-12 12:29     ` [Xen-devel] " Juergen Gross
2014-08-12 12:52       ` Juergen Gross
2014-08-12 21:13   ` Nicholas A. Bellinger
2014-08-13  7:02     ` Juergen Gross
2014-08-14  4:34       ` Re: [Xen-devel] " Juergen Gross
2014-08-17  2:33         ` Nicholas A. Bellinger
2014-08-17  2:15       ` Nicholas A. Bellinger
2014-08-14  8:53     ` Re: [Xen-devel] " Juergen Gross
2014-08-14 10:14       ` Juergen Gross
2014-08-17  2:38         ` Nicholas A. Bellinger
2014-08-18  9:06           ` Juergen Gross
2014-08-08  7:49 ` [PATCH V4 4/4] add xen pvscsi maintainer jgross

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=20140811095424.GB5952@infradead.org \
    --to=hch@infradead.org \
    --cc=JBeulich@suse.com \
    --cc=JBottomley@parallels.com \
    --cc=david.vrabel@citrix.com \
    --cc=jgross@suse.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=target-devel@vger.kernel.org \
    --cc=xen-devel@lists.xen.org \
    /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;
as well as URLs for NNTP newsgroup(s).